def update(self): new_vehicles = self.frame.get_new(Vehicle) #print "new:", new_vehicles for v in new_vehicles: assetid = UUID(choice(self.assets["Sedan"].values())) result = self.rc.CreateObject( assetid, objectid=v.ID, name=v.Name, async=True, pos = [v.Position.X, v.Position.Y, v.Position.Z], vel = [v.Velocity.X, v.Velocity.Y, v.Velocity.Z]) self.logger.info("New vehicle: %s", v.ID) #if not result: # self.logger.error("could not create vehicle %s", v.ID) mod_vehicles = self.frame.get_mod(Vehicle) update_list = [] for v in mod_vehicles: #self.logger.info("Vehicle %s is in %s", v.ID, v.Position) #self.logger.info("[%s] Pulller Position: %s", self.step, v.Position) vpos = [v.Position.X, v.Position.Y, v.Position.Z] vvel = [v.Velocity.X, v.Velocity.Y, v.Velocity.Z] vrot = Quaternion.FromVector3(v.Velocity).ToList() update_list.append(OpenSimRemoteControl.BulkUpdateItem(v.ID, vpos, vvel, vrot)) #if not result: # self.logger.error("error updating vehicle %s", v.ID) del_vehicles = self.frame.get_deleted(Vehicle) for v in del_vehicles: self.logger.info("Deleting vehicle %s", v.ID) result = self.rc.DeleteObject(v.ID, async=False) result = self.rc.BulkDynamics(update_list, False) self.step += 1
def __init__(self): self.Name = "" self.Position = Vector3(0, 0, 0) self.Route = "" self.Target = "" self.Velocity = Vector3(0, 0, 0) self.Rotation = Quaternion(0, 0, 0, 0) self.Type = ""
def initialize(self): self.AuthByUserName() new_vehicles = self.frame.get(Vehicle) update_list = [] for v in new_vehicles: assetid = UUID(choice(self.assets["Sedan"].values())) result = self.rc.CreateObject( assetid, objectid=v.ID, name=v.Name, async=True, pos = [v.Position.X, v.Position.Y, v.Position.Z], vel = [v.Velocity.X, v.Velocity.Y, v.Velocity.Z]) self.logger.info("New vehicle: %s", v.ID) vpos = [v.Position.X, v.Position.Y, v.Position.Z] vvel = [v.Velocity.X, v.Velocity.Y, v.Velocity.Z] vrot = Quaternion.FromVector3(v.Velocity).ToList() update_list.append(OpenSimRemoteControl.BulkUpdateItem(v.ID, vpos, vvel, vrot)) result = self.rc.BulkDynamics(update_list, False)
def __NormalizeAngle(self, heading): # convert to radians heading = (2.0 * heading * math.pi) / 360.0 return Quaternion.FromHeading(heading)
def __init__(self): self.Position = Vector3() self.Velocity = Vector3() self.Acceleration = Vector3() self.Rotation = Quaternion() self.UpdateTime = 0