def __init__(self, height, mie_coef=0.0, mie_scale_height=0.0, mie_phase_asymmetry=0.0, rayleigh_coef=None, rayleigh_scale_height=0.0, absorption_coef=None, shape=None, appearance=None, shader=None): Atmosphere.__init__(self, shape=shape, appearance=appearance, shader=shader) self.height = height self.mie_coef = mie_coef self.mie_scale_height = mie_scale_height self.mie_phase_asymmetry = mie_phase_asymmetry if rayleigh_coef is None: self.rayleigh_coef = LVector3d() else: self.rayleigh_coef = LVector3d(*rayleigh_coef) self.rayleigh_scale_height = rayleigh_scale_height if absorption_coef is None: self.absorption_coef = LVector3d() else: self.absorption_coef = LVector3d(*absorption_coef) self.blend = TransparencyBlend.TB_AlphaAdditive
def __init__(self, name, ship_object, radius): ShipBase.__init__(self, name) self.ship_object = ship_object self.radius = radius #TODO: Should be refactored with StellarBody ! self.shown = True self.visible = True self.resolved = True self.oid_color = LColor() self.world_body_center_offset = LVector3d() self.model_body_center_offset = LVector3d() self.light_color = LColor(1, 1, 1, 1) self.rel_position = None self.scene_rel_position = None self.distance_to_obs = None self.vector_to_obs = None self.vector_to_star = None self.star = None self.directional_light = None self.light_source = None self.scene_position = None self.scene_distance = None self.scene_scale_factor = None self.scene_orientation = None self.ship_object.set_parent(self) #TODO: Temporary workaround as some code need the shape to have an owner self.ship_object.set_owner(self) self.ship_object.set_scale(LVector3d(self.radius, self.radius, self.radius)) self.shadow_caster = None self.create_own_shadow_caster = True
def __init__(self, position=None, right_asc=0.0, right_asc_unit=units.Deg, declination=0.0, declination_unit=units.Deg, distance=0.0, distance_unit=units.Ly, frame=None): Orbit.__init__(self, frame) if position is None: self.right_asc = right_asc * right_asc_unit self.declination = declination * declination_unit distance = distance * distance_unit else: self.right_asc = None self.declination = None if not isinstance(position, LPoint3d): position = LPoint3d(*position) if position is None: inclination = pi / 2 - self.declination ascending_node = self.right_asc + pi / 2 inclination_quat = LQuaterniond() inclination_quat.setFromAxisAngleRad(inclination, LVector3d.unitX()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad(ascending_node, LVector3d.unitZ()) self.orientation = inclination_quat * ascending_node_quat * J2000EquatorialReferenceFrame.orientation position = self.orientation.xform(LVector3d(0, 0, distance)) self.global_position = position self.position = LPoint3d() self.rotation = LQuaterniond()
def __init__(self, rotation=None, inclination=0.0, ascending_node=0.0, right_asc=None, right_asc_unit=units.Deg, declination=None, declination_unit=units.Deg, frame=None): Rotation.__init__(self, frame) if rotation is None: if right_asc is None: self.inclination = inclination * math.pi / 180 self.ascending_node = ascending_node * math.pi / 180 inclination_quat = LQuaterniond() inclination_quat.setFromAxisAngleRad(self.inclination, LVector3d.unitX()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad( self.ascending_node, LVector3d.unitZ()) rotation = inclination_quat * ascending_node_quat else: right_asc = right_asc * right_asc_unit declination = declination * declination_unit self.inclination = math.pi / 2 - declination self.ascending_node = right_asc + math.pi / 2 inclination_quat = LQuaterniond() inclination_quat.setFromAxisAngleRad(self.inclination, LVector3d.unitX()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad( self.ascending_node, LVector3d.unitZ()) rotation = inclination_quat * ascending_node_quat self.axis_rotation = rotation self.rotation = LQuaterniond()
def __init__(self, height, mie_coef=0.0, mie_scale_height=0.0, mie_phase_asymmetry=0.0, rayleigh_coef=None, rayleigh_scale_height=0.0, absorption_coef=None, appearance=None, shader=None): Atmosphere.__init__(self, appearance=appearance, shader=shader) self.height = height self.mie_coef = mie_coef self.mie_scale_height = mie_scale_height self.mie_phase_asymmetry = mie_phase_asymmetry if rayleigh_coef is None: self.rayleigh_coef = LVector3d() else: self.rayleigh_coef = LVector3d(*rayleigh_coef) self.rayleigh_scale_height = rayleigh_scale_height if absorption_coef is None: self.absorption_coef = LVector3d() else: self.absorption_coef = LVector3d(*absorption_coef) self.alpha_mode = ColorBlendAttrib.OIncomingAlpha
def _boundaries_without_priming(self) -> BoundingBox3D: """Return this Model's boundaries without the priming layer.""" if self.index_to_layer: layer_points_min, layer_points_max = zip( *[(layer.boundaries.point_min, layer.boundaries.point_max) for layer in self._layer_to_z.keys()]) layers_min = reduce(lambda a, b: a.fmin(b), layer_points_min) layers_max = reduce(lambda a, b: a.fmax(b), layer_points_max) point_min = LVector3d( x=layers_min.x, y=layers_min.y, z=0, ) point_max = LVector3d( x=layers_max.x, y=layers_max.y, z=max(self._layer_to_z.values()), ) return BoundingBox3D(point_min=point_min, point_max=point_max) # No layers return BoundingBox3D.null_object()
def update_instance(self, camera_pos, orientation): body = self.parent if body.is_emissive() and (not body.resolved or isinstance(body, DeepSpaceObject)): if body.scene_position != None: self.instance.setPos(*body.scene_position) scale = abs(self.context.observer.pixel_size * body.get_label_size() * body.scene_distance) else: scale = 0.0 else: offset = body.get_apparent_radius() * 1.01 rel_front_pos = body.rel_position - orientation.xform(LPoint3d(0, offset, 0)) vector_to_obs = LVector3d(-rel_front_pos) distance_to_obs = vector_to_obs.length() vector_to_obs /= distance_to_obs position, distance, scale_factor = self.get_real_pos_rel(rel_front_pos, distance_to_obs, vector_to_obs) self.instance.setPos(*position) scale = abs(self.context.observer.pixel_size * body.get_label_size() * distance) color = body.get_label_color() * self.fade self.look_at.set_pos(LVector3(*(orientation.xform(LVector3d.forward())))) self.label_instance.look_at(self.look_at, LVector3(), LVector3(*(orientation.xform(LVector3d.up())))) color[3] = 1.0 self.label.setTextColor(color) if scale < 1e-7: print("Label too far", self.get_name()) scale = 1e-7 self.instance.setScale(scale)
def __init__(self, body=None, right_asc=0.0, right_asc_unit=units.Deg, declination=0.0, declination_unit=units.Deg, longitude_at_node=0.0, longitude_at_nod_units=units.Deg): RelativeReferenceFrame.__init__(self, body) self.right_asc = right_asc * right_asc_unit self.declination = declination * declination_unit self.longitude_at_node = longitude_at_node * longitude_at_nod_units inclination = pi / 2 - self.declination ascending_node = self.right_asc + pi / 2 inclination_quat = LQuaterniond() inclination_quat.setFromAxisAngleRad(inclination, LVector3d.unitX()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad(ascending_node, LVector3d.unitZ()) longitude_quad = LQuaterniond() longitude_quad.setFromAxisAngleRad(self.longitude_at_node, LVector3d.unitZ()) self.orientation = longitude_quad * inclination_quat * ascending_node_quat * J2000EquatorialReferenceFrame.orientation
def __init__(self, names, orbit=None, rotation=None, body_class=None, point_color=None, description=''): LabelledObject.__init__(self, names) self.description = description self.system = None self.body_class = body_class if orbit is None: orbit = FixedOrbit() self.orbit = orbit if rotation is None: rotation = UnknownRotation() self.rotation = rotation if point_color is None: point_color = LColor(1.0, 1.0, 1.0, 1.0) self.point_color = srgb_to_linear(point_color) self.abs_magnitude = 99.0 self.oid = None self.oid_color = None #Flags self.visible = False self.resolved = False self.in_view = False self.selected = False self.update_id = 0 self.visibility_override = False #Cached values self._position = LPoint3d() self._global_position = LPoint3d() self._local_position = LPoint3d() self._orientation = LQuaterniond() self._equatorial = LQuaterniond() self._app_magnitude = None self._extend = 0.0 #Scene parameters self.rel_position = None self.distance_to_obs = None self.vector_to_obs = None self.distance_to_star = None self.vector_to_star = None self.height_under = 0.0 self.star = None self.light_color = (1.0, 1.0, 1.0, 1.0) self.visible_size = 0.0 self.scene_position = None self.scene_orientation = None self.scene_scale_factor = None self.world_body_center_offset = LVector3d() self.model_body_center_offset = LVector3d() self.projected_world_body_center_offset = LVector3d() #Components self.orbit_object = None self.rotation_axis = None self.reference_axis = None self.init_annotations = False self.init_components = False self.update_frozen = False #TODO: Should be done properly self.orbit.body = self self.rotation.body = self objectsDB.add(self)
def calc_orientation_from_incl_an(inclination, ascending_node, flipped=False): inclination_quat = LQuaterniond() if flipped: inclination += pi inclination_quat.setFromAxisAngleRad(inclination, LVector3d.unitX()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad(ascending_node, LVector3d.unitZ()) return inclination_quat * ascending_node_quat
def create_drag_params(self, target): center = target.get_rel_position_to(self.observer.camera_global_pos) self.dragCenter = self.observer.camera_frame.get_rel_position(center) dragPosition = self.observer.get_frame_camera_pos() self.dragDir = self.dragCenter - dragPosition self.dragOrientation = self.observer.get_frame_camera_rot() self.dragZAxis = self.dragOrientation.xform(LVector3d.up()) self.dragXAxis = self.dragOrientation.xform(LVector3d.right())
def update_shader_shape_static(self, shape, appearance): parameters = shape.owner.atmosphere planet_radius = shape.owner.get_apparent_radius() if self.atmosphere: #render.cpp 7193 radius = planet_radius + shape.owner.atmosphere.height #renderglsl.cpp 557 atmosphereRadius = radius + -parameters.mie_scale_height * log( self.AtmosphereExtinctionThreshold) atmPlanetRadius = radius objRadius = atmosphereRadius else: radius = planet_radius #rendercontext.cpp 785 atmPlanetRadius = radius objRadius = radius #shadermanager.cpp 3446 skySphereRadius = atmPlanetRadius + -parameters.mie_scale_height * log( self.AtmosphereExtinctionThreshold) mieCoeff = parameters.mie_coef * objRadius rayleighCoeff = parameters.rayleigh_coef * objRadius absorptionCoeff = parameters.absorption_coef * objRadius r = skySphereRadius / objRadius atmosphereRadius = LVector3d(r, r * r, atmPlanetRadius / objRadius) mieScaleHeight = objRadius / parameters.mie_scale_height # The scattering shaders use the Schlick approximation to the # Henyey-Greenstein phase function because it's slightly faster # to compute. Convert the HG asymmetry parameter to the Schlick # parameter. g = parameters.mie_phase_asymmetry miePhaseAsymmetry = 1.55 * g - 0.55 * g * g * g rayleighScaleHeight = 0.0 # Precompute sum and inverse sum of scattering coefficients to save work # in the vertex shader. scatterCoeffSum = rayleighCoeff + LVector3d(mieCoeff, mieCoeff, mieCoeff) invScatterCoeffSum = LVector3d(1.0 / scatterCoeffSum[0], 1.0 / scatterCoeffSum[1], 1.0 / scatterCoeffSum[2]) extinctionCoeff = scatterCoeffSum + absorptionCoeff shape.instance.setShaderInput("atmosphereRadius", *atmosphereRadius) shape.instance.setShaderInput("mieCoeff", mieCoeff) shape.instance.setShaderInput("mieH", mieScaleHeight) shape.instance.setShaderInput("mieK", miePhaseAsymmetry) shape.instance.setShaderInput("rayleighCoeff", *rayleighCoeff) shape.instance.setShaderInput("rayleighH", rayleighScaleHeight) # Color of sun shape.instance.setShaderInput("scatterCoeffSum", *scatterCoeffSum) shape.instance.setShaderInput("invScatterCoeffSum", *invScatterCoeffSum) shape.instance.setShaderInput("extinctionCoeff", *extinctionCoeff)
class CelestiaBodyFixedReferenceFrame(RelativeReferenceFrame): rotY180 = LQuaterniond() rotY180.set_from_axis_angle(180, LVector3d(0, 1, 0)) rotZ90 = LQuaterniond() rotZ90.set_from_axis_angle(-90, LVector3d(0, 0, 1)) def get_orientation(self): rot = self.body.get_sync_rotation() return rot
def get_normals_under(self, position): if self.surface is not None: (x, y, distance) = self.spherical_to_longlat(self.cartesian_to_spherical(position)) vectors = self.surface.get_normals_at(x, y) else: vectors = (LVector3d.up(), LVector3d.forward(), LVector3d.left()) sync_frame = SynchroneReferenceFrame(self) return (sync_frame.get_orientation().xform(vectors[0]), sync_frame.get_orientation().xform(vectors[1]), sync_frame.get_orientation().xform(vectors[2]))
def OnSelectClick(self): if self.base.mouseWatcherNode.hasMouse(): self.mouseSelectClick = True mpos = self.base.mouseWatcherNode.getMouse() self.startX = mpos.getX() self.startY = mpos.getY() self.dragCenter = self.observer.get_camera_pos() self.dragOrientation = self.observer.get_camera_rot() self.dragZAxis = self.dragOrientation.xform(LVector3d.up()) self.dragXAxis = self.dragOrientation.xform(LVector3d.right())
def update_rotation(self): inclination_quat = LQuaterniond() inclination_quat.setFromAxisAngleRad(self.inclination, LVector3d.unitX()) arg_of_periapsis_quat = LQuaterniond() arg_of_periapsis_quat.setFromAxisAngleRad(self.arg_of_periapsis, LVector3d.unitZ()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad(self.ascending_node, LVector3d.unitZ()) self.rotation = arg_of_periapsis_quat * inclination_quat * ascending_node_quat
def align_on_equatorial(self, duration=None): if duration is None: duration = settings.fast_move ecliptic_normal = self.ship._frame_rotation.conjugate().xform(J2000EquatorialReferenceFrame.orientation.xform(LVector3d.up())) angle = acos(ecliptic_normal.dot(LVector3d.right())) direction = ecliptic_normal.cross(LVector3d.right()).dot(LVector3d.forward()) if direction < 0: angle = 2 * pi - angle rot=LQuaterniond() rot.setFromAxisAngleRad(pi / 2 - angle, LVector3d.forward()) self.ship.step_turn(rot, absolute=False)
def _boundaries_with_priming(self) -> BoundingBox3D: """Return this Model's boundaries with the priming layer.""" if not self._priming_layer: return self._boundaries_without_priming # Calc new boundaries with priming layer in mind point_min = self._boundaries_without_priming.point_min.fmin( LVector3d(self._priming_layer.boundaries.point_min, 0)) point_max = self._boundaries_without_priming.point_max.fmax( LVector3d(self._priming_layer.boundaries.point_max, 0)) return BoundingBox3D(point_min=point_min, point_max=point_max)
def instanciate_body(universe, item_type, item_name, item_data): ra = None decl = None distance = None type = None radius = None axis = None angle = None abs_magnitude = None app_magnitude = None orbit = None axis = LVector3d.up() angle = 0.0 names = names_list(item_name) for (key, value) in item_data.items(): if key == 'RA': ra = value elif key == 'Dec': decl = value elif key == 'Distance': distance = value elif key == 'Type': type = value elif key == 'Radius': radius = value elif key == 'Axis': axis = LVector3d(*value) elif key == 'Angle': angle = value elif key == 'AbsMag': abs_magnitude = value elif key == 'AppMag': app_magnitude = value elif key == 'InfoURL': pass # = value else: print("Key of", item_type, key, "not supported") orbit = FixedPosition(right_asc=ra, right_asc_unit=units.HourAngle, declination=decl, distance=distance, distance_unit=units.Ly) rot = utils.LQuaternionromAxisAngle(axis, angle, units.Deg) rotation = FixedRotation(rot, J2000EquatorialReferenceFrame()) if app_magnitude != None and distance != None: abs_magnitude = units.app_to_abs_mag(app_magnitude, distance) dso = Galaxy(names, abs_magnitude=abs_magnitude, radius=radius, orbit=orbit, rotation=rotation) return dso
def __init__(self, radius, radius_units=units.AU, radial_speed=None, period=None, period_units=units.JYear, inclination=0, ascending_node=0.0, arg_of_periapsis=None, long_of_pericenter=None, mean_anomaly=None, mean_longitude=0.0, epoch=units.J2000, frame=None): Orbit.__init__(self, frame) self.radius = radius * radius_units if radial_speed is None: if period is None: self.mean_motion = 0.0 self.period = 0.0 else: self.period = period * period_units self.mean_motion = 2 * pi / self.period else: self.mean_motion = radial_speed self.period = 2 * pi / self.mean_motion / period_units if arg_of_periapsis is None: if long_of_pericenter is None: arg_of_periapsis = 0.0 else: arg_of_periapsis = long_of_pericenter - ascending_node if inclination == 0.0: #Ascending node is undefined if there is no inclination ascending_node = 0.0 if mean_anomaly is None: mean_anomaly = mean_longitude - (arg_of_periapsis + ascending_node) self.inclination = inclination * pi / 180 self.ascending_node = ascending_node * pi / 180 self.arg_of_periapsis = arg_of_periapsis * pi / 180 self.mean_anomaly = mean_anomaly * pi / 180 self.epoch = epoch inclination_quat = LQuaterniond() inclination_quat.setFromAxisAngleRad(self.inclination, LVector3d.unitX()) arg_of_periapsis_quat = LQuaterniond() arg_of_periapsis_quat.setFromAxisAngleRad(self.arg_of_periapsis, LVector3d.unitZ()) ascending_node_quat = LQuaterniond() ascending_node_quat.setFromAxisAngleRad(self.ascending_node, LVector3d.unitZ()) #self.rotation = ascending_node_quat * inclination_quat * arg_of_periapsis_quat self.rotation = arg_of_periapsis_quat * inclination_quat * ascending_node_quat
def __init__(self, env): self.env = env self.cam_node = Camera(self.__class__.__name__.lower()) self.cam_node.setScene(env.NP) self.NP = NodePath(self.cam_node) self.NP.reparentTo(env.NP) self.LENS = self.cam_node.getLens() self.LENS.setFar(_cam.FAR) self.LENS.setFov(base.camLens.getFov()) self.FOCUS = None self.focus_pos = LVector3d(0, 0, 0) self.sys_pos = LVector3d(0, 0, 0)
def __init__(self, recipe): self.__dict__.update(recipe) self.SATS = [] self.sys_vec = LVector3d(0, 0, 0) self.sys_pos = LVector3d(0, 0, 0) self.sys_hpr = LVector3f(0, 0, 0) self.sys_rot = LVector3f(0, 0, 0) self.POS = LVector3f(0, 0, 0) self.far_radius = _env.ATMOS_RADIUS - self.radius self.near_radius = 0 self._mode = "far" ## self._lod = "low" self._loaded = False
def __init__(self, names, orbit=None, rotation=None, body_class=None, point_color=None, description=''): LabelledObject.__init__(self, names) self.description = description self.system = None self.body_class = body_class self.visible = True self.resolved = True self.in_view = True if orbit is None: orbit = FixedOrbit() self.orbit = orbit if rotation is None: rotation = FixedRotation() self.rotation = rotation if point_color is None: point_color = LColor(1.0, 1.0, 1.0, 1.0) self.point_color = point_color self.position = LPoint3d() self.orbit_position = LPoint3d() self.orbit_rotation = LQuaterniond() self.orientation = LQuaterniond() self.equatorial = LQuaterniond() self.abs_magnitude = 99.0 self.cached_app_magnitude = None self.rel_position = None self.distance_to_obs = None self.vector_to_obs = None self.distance_to_star = None self.vector_to_star = None self.height_under = 0.0 self.light_color = (1.0, 1.0, 1.0, 1.0) self.visible_size = 0.0 self.scene_position = None self.scene_orientation = None self.scene_scale_factor = None self.orbit_object = None self.rotation_axis = None self.reference_axis = None self.star = None self.init_annotations = False self.init_components = False #TODO: Should be done properly self.orbit.body = self self.rotation.body = self self.selected = False objectsDB.add(self) self.global_position = self.orbit.get_global_position_at(0) self.cast_shadows = False self.world_body_center_offset = LVector3d() self.model_body_center_offset = LVector3d()
def LQuaternionromAxisAngle(axis, angle, angle_units=units.Rad): if isinstance(axis, list): axis = LVector3d(*axis) axis.normalize() rot = LQuaterniond() rot.setFromAxisAngleRad(angle * angle_units, axis) return rot
class J2000EquatorialReferenceFrame(BodyReferenceFrame): orientation = LQuaterniond() orientation.setFromAxisAngleRad(-units.J2000_Obliquity / 180.0 * pi, LVector3d.unitX()) def get_orientation(self): return self.orientation
def NormalizedSquarePatchPoint(radius, u, v, x0, y0, x1, y1, offset=None, x_inverted=False, y_inverted=False, xy_swap=False): if offset is not None: normal = NormalizedSquarePatchNormal(x0, y0, x1, y1, x_inverted, y_inverted, xy_swap) (x0, y0, x1, y1, dx, dy) = convert_xy(x0, y0, x1, y1, x_inverted, y_inverted, xy_swap) x = x0 + u * dx y = y0 + v * dy vec = LVector3d(2.0 * x - 1.0, 2.0 * y - 1.0, 1.0) vec.normalize() if offset is not None: vec = (vec - normal * offset) * radius return vec
def set_focus(self, obj): if self.FOCUS and obj is self.FOCUS: return self.FOCUS = obj self.focus_pos.set(0, obj.radius * 12, 0) obj_state = self.env.client.SIM.get_object_state(obj.name, ["sys_pos"]) obj.sys_pos = LVector3d(*obj_state['sys_pos']) self.sys_pos = obj.sys_pos - self.focus_pos
def do_load_bin(filepath, names, universe): start = time() print("Loading", filepath) base.splash.set_text("Loading %s" % filepath) data = open(filepath, 'rb') field = data.read(8 + 2 + 4) header, version, count = struct.unpack("<8shi", field) if not header == b"CELSTARS": print("Invalid header", header) return if not version == 0x0100: print("Invalid version", version) return print("Found", count, "stars") fmt = "<ifffhh" size = struct.calcsize(fmt) for i in range(count): fields = data.read(size) catNo, x, y, z, abs_magnitude, spectral_type = struct.unpack( fmt, fields) if catNo in names: name = names[catNo] else: name = "HIP %d" % catNo position = LVector3d(x * units.Ly, -z * units.Ly, y * units.Ly) orbit = FixedPosition(position=position) star = Star(name, surface_factory=celestiaStarSurfaceFactory, spectral_type=spectralTypeIntDecoder.decode(spectral_type), abs_magnitude=abs_magnitude / 256.0, orbit=orbit, rotation=FixedRotation()) universe.add_child_fast(star) end = time() print("Load time:", end - start)
def step(self, distance): arc_to_angle = 1.0 / (self.body.get_apparent_radius()) camera_pos = self.observer.get_camera_pos() (normal, tangent, binormal) = self.body.get_normals_under(camera_pos) direction = self.observer.get_camera_rot().xform( LVector3d(0, distance, 0)) projected = direction - normal * direction.dot(normal) position = self.body.cartesian_to_spherical( self.observer.get_camera_pos()) delta_x = tangent.dot(projected) * arc_to_angle delta_y = binormal.dot(projected) * arc_to_angle new_position = [ position[0] + delta_x, position[1] + delta_y, position[2] ] altitude = position[2] - self.body.height_under (x, y, distance) = self.body.spherical_to_longlat(new_position) new_height = self.body.surface.get_height_at(x, y, strict=True) if new_height is not None: new_position[2] = new_height + altitude else: print("Patch not found for", x, y, '->', new_position[2]) new_position = self.body.spherical_to_cartesian(new_position) self.observer.set_camera_pos(new_position) target_pos = new_position + direction * 10 * units.m target_pos = self.body.cartesian_to_spherical(target_pos) (x, y, distance) = self.body.spherical_to_longlat(target_pos) target_height = self.body.surface.get_height_at(x, y, strict=True) if target_height is not None: target_pos = (target_pos[0], target_pos[1], target_height + altitude) else: print("Patch not found for", x, y, '->', target_pos[2]) target_pos = self.body.spherical_to_cartesian(target_pos) rot, angle = self.observer.calc_look_at(target_pos, rel=False)
def __init__(self, model, offset=None, rotation=None, scale=None, auto_scale_mesh=True, flatten=True, panda=False, attribution=None, context=defaultDirContext): Shape.__init__(self) self.model = model self.attribution = attribution self.context = context if offset is None: offset = LPoint3d() self.offset = offset if rotation is None: rotation = LQuaterniond() if scale is None and not auto_scale_mesh: scale = LVector3d(1, 1, 1) self.scale_factor = scale self.rotation = rotation self.auto_scale_mesh = auto_scale_mesh self.flatten = flatten self.panda = panda self.mesh = None self.callback = None self.cb_args = None