parameters: (self, fname)
docstring: Generates a CSV scene file for this WarehouseScene.
docstring_summary: Generates a CSV scene file for this WarehouseScene.
docstring_tokens: Generates a CSV scene file for this WarehouseScene .
function: def generateCSV(self, fname):
          '''Generates a CSV scene file for this WarehouseScene.'''
  
          # First, we need to extract all the basic information available in the kml files
          objdata = {}
          for objid in self._db:
              objdata[objid] = extract_kml_info(objid, self._work_dir)
              model_scale = compute_scale(objid, self._work_dir)
              kml_scale = objdata[objid].scale
              objdata[objid].scale = ModelScale(model_scale.x * kml_scale.x, model_scale.y * kml_scale.y, model_scale.z * kml_scale.z)
  
          # Next, figure out where to center things
          avg_lat = average([obj.pos.lat for obj in objdata.values()])
          avg_long = average([obj.pos.long for obj in objdata.values()])
  
          # Based on our central point, we need to compute where
          # everything is in relation to it. We also need to take care
          # of rotating everything so that the specified lat,long's
          # normal is y-up
          earth_rad = 6371000.0 # meters
  
          print avg_lat, avg_long
  
          avg_theta = math.radians(avg_long)
          avg_phi = math.radians(90 - avg_lat)
  
          # Generate quaternion for rotating points into the central point's frame
          rot_center = \
              euclid.Quaternion.new_rotate_axis(-avg_phi, euclid.Vector3(0, 0, -1)) * \
              euclid.Quaternion.new_rotate_axis(-avg_theta, euclid.Vector3(0, -1, 0))
  
          # Now we have all the info we need to create the scene
          with open(fname, 'w') as fout:
              print >>fout, '"objtype","pos_x","pos_y","pos_z","orient_x","orient_y","orient_z","orient_w","meshURI","scale"'
              # In these scenes, we always need lights added
              print >>fout, '"mesh",0,0,0,0,0,0,1,"meerkat:///ewencp/DirectionalLights.dae",1'
              for objid in self._db:
                  obj = objdata[objid]
  
                  # Get in spherical coordinates
                  theta = math.radians(obj.pos.long)
                  phi = math.radians(90 - obj.pos.lat)
                  # Get in cartesian coords
                  pos = euclid.Vector3(
                      x = earth_rad * math.cos(theta) * math.sin(phi),
                      y = earth_rad * math.cos(phi),
                      z = earth_rad * math.sin(theta) * math.sin(phi)
                      )
  
                  # Rotate into position
                  pos = rot_center * pos
                  # And translate to the "center of the earth," i.e. the origin,
                  # in order to get things in a sane coordinate system
                  pos.y -= earth_rad
  
                  rot = [0,0,0,1]
                  mesh = "meerkat:///ewencp/%s.dae" % (objid)
                  # obj.scale contains the extents, compute a radius
                  size = obj.scale.radius()
                  print >>fout, '"mesh",%f,%f,%f,%f,%f,%f,%f,"%s",%f' % (pos[0], pos[1], pos[2], rot[0], rot[1], rot[2], rot[3], mesh, size)
function_tokens: def generateCSV ( self , fname ) : # First, we need to extract all the basic information available in the kml files objdata = { } for objid in self . _db : objdata [ objid ] = extract_kml_info ( objid , self . _work_dir ) model_scale = compute_scale ( objid , self . _work_dir ) kml_scale = objdata [ objid ] . scale objdata [ objid ] . scale = ModelScale ( model_scale . x * kml_scale . x , model_scale . y * kml_scale . y , model_scale . z * kml_scale . z ) # Next, figure out where to center things avg_lat = average ( [ obj . pos . lat for obj in objdata . values ( ) ] ) avg_long = average ( [ obj . pos . long for obj in objdata . values ( ) ] ) # Based on our central point, we need to compute where # everything is in relation to it. We also need to take care # of rotating everything so that the specified lat,long's # normal is y-up earth_rad = 6371000.0 # meters print avg_lat , avg_long avg_theta = math . radians ( avg_long ) avg_phi = math . radians ( 90 - avg_lat ) # Generate quaternion for rotating points into the central point's frame rot_center = euclid . Quaternion . new_rotate_axis ( - avg_phi , euclid . Vector3 ( 0 , 0 , - 1 ) ) * euclid . Quaternion . new_rotate_axis ( - avg_theta , euclid . Vector3 ( 0 , - 1 , 0 ) ) # Now we have all the info we need to create the scene with open ( fname , 'w' ) as fout : print >> fout , '"objtype","pos_x","pos_y","pos_z","orient_x","orient_y","orient_z","orient_w","meshURI","scale"' # In these scenes, we always need lights added print >> fout , '"mesh",0,0,0,0,0,0,1,"meerkat:///ewencp/DirectionalLights.dae",1' for objid in self . _db : obj = objdata [ objid ] # Get in spherical coordinates theta = math . radians ( obj . pos . long ) phi = math . radians ( 90 - obj . pos . lat ) # Get in cartesian coords pos = euclid . Vector3 ( x = earth_rad * math . cos ( theta ) * math . sin ( phi ) , y = earth_rad * math . cos ( phi ) , z = earth_rad * math . sin ( theta ) * math . sin ( phi ) ) # Rotate into position pos = rot_center * pos # And translate to the "center of the earth," i.e. the origin, # in order to get things in a sane coordinate system pos . y -= earth_rad rot = [ 0 , 0 , 0 , 1 ] mesh = "meerkat:///ewencp/%s.dae" % ( objid ) # obj.scale contains the extents, compute a radius size = obj . scale . radius ( ) print >> fout , '"mesh",%f,%f,%f,%f,%f,%f,%f,"%s",%f' % ( pos [ 0 ] , pos [ 1 ] , pos [ 2 ] , rot [ 0 ] , rot [ 1 ] , rot [ 2 ] , rot [ 3 ] , mesh , size )