Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (normal, tangent, binormal)
class SquarePatchBase(Patch):
patch_cache = {}
RIGHT = 0
LEFT = 1
BACK = 2
FRONT = 3
TOP = 4
BOTTOM = 5
rotations = [LQuaterniond(), LQuaterniond(), LQuaterniond(), LQuaterniond(), LQuaterniond(), LQuaterniond()]
rotations_mat = [LMatrix4(), LMatrix4(),LMatrix4(), LMatrix4(), LMatrix4(), LMatrix4()]
rotations[0].setHpr(LVector3d(0, 0, 90)) #right
rotations[1].setHpr(LVector3d(0, 0, -90)) #left
rotations[2].setHpr(LVector3d(0, 90, 0)) #back
rotations[3].setHpr(LVector3d(0, -90, 0)) #face
rotations[4].setHpr(LVector3d(180, 0, 0)) #top
rotations[5].setHpr(LVector3d(180, 180, 0)) #bottom
for i in range(6):
LQuaternion(*rotations[i]).extractToMatrix(rotations_mat[i])
def __init__(self, face, x, y, parent, lod, density, surface, min_radius, max_radius, mean_radius, user_shader, use_tesselation):
Patch.__init__(self, parent, lod, density, surface)
self.face = face
self.x = x
self.y = y
self.cube_map = True
self.use_shader = user_shader
self.use_tesselation = use_tesselation
self.div = 1 << self.lod
float time = 1.0
float distance = 5.0
string upframe = "observer"
vector up = [ 0 1 0 ]
Description:
Go to the currently selected object.
Trip duration is controlled with the time parameter.
The distance parameter specifies how far away from the object to stop in units of the object's radius.
The goto command executes instantaneously so that you can use other commands such as print while the camera is moving toward the destination.
In order for goto to complete, there should be wait commands with a combined duration equal to the value of the time parameter.
"""
duration=float(parameters.get('time', '1.0'))
distance=float(parameters.get('distance', '5.0'))
upframe=parameters.get('upframe', 'observer')
up=parameters.get('up', [0, 1, 0])
up=LVector3d(up[0], -up[2], up[1])
up.normalize()
sequence.append(Func(base.autopilot.go_to_object, duration, distance, up))
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 project(self, time, center, radius):
return self.orientation.xform(LVector3d(0, 0, radius))
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,
float time = 1.0
float distance = 5.0
vector up = [ 0 1 0 ]
float longitude = 0
float latitude = 0
Description:
gotolonglat works exactly the same as goto except that you can specify coordinates on the surface of the object as well as a distance.
Since the distance is in object radii, a distance of 1.0 will put you right on the surface.
Typically, you want to be just above the surface, so giving a radius of 1.001 is a better idea.
Latitude is negative for the southern hemisphere and positive for the northern hemisphere.
Longitude is negative for the western hemisphere and position for the eastern hemisphere.
"""
duration=float(parameters.get('time', '1.0'))
distance=float(parameters.get('distance', '5.0'))
up=parameters.get('up', [0, 1, 0])
up=LVector3d(up[0], -up[2], up[1])
up.normalize()
longitude=float(parameters.get('longitude', '0.0'))
latitude=float(parameters.get('latitude', '0.0'))
sequence.append(Func(base.autopilot.go_to_object_long_lat, longitude * pi / 180, latitude * pi / 180, duration, distance, up))
x = x0 + u * dx
y = y0 + v * dy
x = 2.0 * x - 1.0
y = 2.0 * y - 1.0
z = 1.0
x2 = x * x
y2 = y * y
z2 = z * z
x *= sqrt(1.0 - y2 * 0.5 - z2 * 0.5 + y2 * z2 / 3.0)
y *= sqrt(1.0 - z2 * 0.5 - x2 * 0.5 + z2 * x2 / 3.0)
z *= sqrt(1.0 - x2 * 0.5 - y2 * 0.5 + x2 * y2 / 3.0)
vec = LVector3d(x, y, z)
vec *= radius
if offset is not None:
normal = SquaredDistanceSquarePatchNormal(x0, y0, x1, y1, x_inverted, y_inverted, xy_swap)
vec = vec - normal * offset
return vec
def UVPatchNormal(x0, y0, x1, y1):
dx = x1 - x0
dy = y1 - y0
x = cos(2*pi * (x0 + dx / 2) + pi) * sin(pi * (y0 + dy / 2))
y = sin(2*pi * (x0 + dx / 2) + pi) * sin(pi * (y0 + dy / 2))
z = sin(pi / 2 - pi * (y0 + dy / 2))
return LVector3d(x, y, z)
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 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())