def _create_euler_ocs(self, yaw, pitch, roll): ocs = coordinate_system.CoordinateSystem() a_frame = ocs.a_frame a_frame.rotate(a_frame.y_axis, yaw) a_frame.rotate(a_frame.x_axis, pitch) a_frame.rotate(a_frame.z_axis, roll) return ocs
def __init__(self): self.mode = self.PERSPECTIVE self.ocs = coordinate_system.CoordinateSystem() self.pixel_aspect_w_h = 1. #-------------------- # read-only from here #-------------------- self.fovx = 80. self.fovy = 80. self.orthox = 5000. # window width in opengl units self.orthoy = 5000. self.z_near = 50. self.z_far = 500. * 1000. self.w_pixels = 1 self.h_pixels = 1 self._tanfovx_2 = 0. self._tanfovy_2 = 0. self.set_fovx(self.fovx) self.set_fovy(self.fovy)
def __init__(self, wx=1., wy=1., wz=1., color=0xaabbccdd): """ wx, wy, wz : size """ self.ocs = coordinate_system.CoordinateSystem() self.wx = wx self.wy = wy self.wz = wz #self.flags = 0 self.color = color
def __init__(self): self.size = 0.7 # halfsize self.color = (1., 0., 0.2, 1.) self.ocs = coordinate_system.CoordinateSystem() self.parent = None self.children = [] # normal list is a kludge. normal of the last quad vertex is used. # front right back left top bottom # self.vertex_list = pyglet.graphics.vertex_list_indexed(8, [0,1,2,3, 1,5,6,2, 5,4,7,6, 3,7,4,0, 0,4,5,1, 3,2,6,7], # ('v3f/static', (-1.,1.,-1., 1.,1.,-1., 1.,-1.,-1., -1.,-1.,-1., -1.,1.,1., 1.,1.,1., 1.,-1.,1., -1.,-1.,1.)), # ('n3f/static', (-1.,0.,0., 0.,1.,0., 1.,0.,0., 0.,0.,-1., 2.,2.,2., 2.,2.,2., 0.,0.,1., 0.,-1.,0.)) # ) # updated every frame from the outside self.target_ocs = coordinate_system.CoordinateSystem()
def get_ocs_to(self, dest_object=None): """ TODO: move this to object3d subclass. and make it work with hierarchies deeper than 1 :) return an ocs where projv_out projects vectors into dest_object space. dest_object None is the root object. the purest world-space there is.. """ assert dest_object == None, "not implemented :(" ocs = coordinate_system.CoordinateSystem() ocs.set(self.ocs) return ocs
def _build_body(self): cubes = [] # body c = cube.Cube(0.6, 0.03, 0.6) body_ocs = coordinate_system.CoordinateSystem() body_ocs.set(c.ocs) c.ocs.a_frame.rotate(c.ocs.a_frame.y_axis, 45.) c.set_color_f(.7, .7, .7, 1.) cubes.append(c) # support beams beam_len = 1.9 beam_width = 0.05 beam_color = (.1, .1, .1, 1.) c = cube.Cube(beam_len, beam_width, beam_width) beam1_ocs = c.ocs c.set_color_f(*beam_color) cubes.append(c) c = cube.Cube(beam_len, beam_width, beam_width) c.ocs.a_frame.rotate(c.ocs.a_frame.y_axis, 90.) c.set_color_f(*beam_color) cubes.append(c) beam_len = 1.9 blade_yofs = 0.1 # blades cubes += self._build_blade(body_ocs.a_frame.x_axis * beam_len * 0.5 + c.ocs.a_frame.y_axis * blade_yofs) cubes += self._build_blade(-body_ocs.a_frame.x_axis * beam_len * 0.5 + c.ocs.a_frame.y_axis * blade_yofs) cubes += self._build_blade(body_ocs.a_frame.z_axis * beam_len * 0.5 + c.ocs.a_frame.y_axis * blade_yofs) cubes += self._build_blade(-body_ocs.a_frame.z_axis * beam_len * 0.5 + c.ocs.a_frame.y_axis * blade_yofs) return cubes
def __init__(self): self.mode = self.MODE_RAW self.ocs = coordinate_system.CoordinateSystem() self.camera_desired_orientation = axial_frame.AxialFrame() self.camera_trackpoint = vector.Vector() self.camera_trackpoint_normal = vector.Vector() # calculated motor angles self.yaw = 0. self.roll = 0. self.pitch = 0. cubes_lists, ocs_list = self._build_gimbal() cubes_yaw = cubes_lists[0] cubes_roll = cubes_lists[1] cubes_pitch = cubes_lists[2] self.ocs_yaw = ocs_list[0] self.ocs_roll = ocs_list[1] self.ocs_pitch = ocs_list[2] # vertex_lists = self._build_body() # self.vertex_lists_blade = vertex_lists[0] # self.vertex_lists_body = vertex_lists[1] cubes_body = self._build_body() self.cubes_vbo_body = cubes_vbo.CubesVbo(len(cubes_body)) self.cubes_vbo_body.update_cubes(0, cubes_body) self.cubes_vbo_yaw = cubes_vbo.CubesVbo(len(cubes_yaw)) self.cubes_vbo_yaw.update_cubes(0, cubes_yaw) self.cubes_vbo_roll = cubes_vbo.CubesVbo(len(cubes_roll)) self.cubes_vbo_roll.update_cubes(0, cubes_roll) self.cubes_vbo_pitch = cubes_vbo.CubesVbo(len(cubes_pitch)) self.cubes_vbo_pitch.update_cubes(0, cubes_pitch) self.color = (1., 0., 0.2, 1.)
def _build_gimbal(self): scale = 0.5 # yaw platform ocs_yaw = coordinate_system.CoordinateSystem() s = .05 * scale # pipe base radius h = .5 * scale gimbal_color = (1., 0., 0.2, 1.) cubes_yaw = [self._gen_box(-s, s, -s, s, -h - s, s)] for c in cubes_yaw: c.set_color_f(*gimbal_color) # roll platform (top view) # 0 x1 # | | # O | O--z2 # O | O # O | O # OOOOOOOOOOO--z1 # O # O-------0 # ocs_roll = coordinate_system.CoordinateSystem() ocs_roll.pos.set((0., -h, 0.)) s1 = s * .8 s2 = s s3 = s * .9 x1 = .5 * scale z1 = .2 * scale z2 = z1 + .5 * scale cubes_roll = [ self._gen_box(-s1, s1, -s1, s1, -s1, z1 + s1), # 0 .. z1 self._gen_box(-x1 - s2, s2, z1 - s2, x1 + s2, -s2, z1 + s2), # -x1 .. x1 self._gen_box(-x1 - s3, s3, z1 + s3, -x1 + s3, -s3, z2 + s3), # z1 .. z2 (left) self._gen_box(x1 - s3, s3, z1 + s3, x1 + s3, -s3, z2 + s3) ] # z1 .. z2 (right) for c in cubes_roll: c.set_color_f(*gimbal_color) # pitch platform (top view) # 0 x1 x2 # | | | # OOOOOOOOO--|--z1 # O O | # OOOO OOOO--0 # O O # OOOOOOOOO # ocs_pitch = coordinate_system.CoordinateSystem() ocs_pitch.pos.set((0., 0., z2)) s1 = s * .3 # pole radius s2 = s * .4 # platform thickness x2 = x1 x1 = x1 * .8 z1 = (z2 - z1) * .8 cubes_pitch = [ self._gen_box(-x2 - s1, s1, -s1, x2 + s1, -s1, s1), # pole self._gen_box(-x1, s2, -z1, x1, -s2, z1) ] # platform for c in cubes_pitch: c.set_color_f(*gimbal_color) return (cubes_yaw, cubes_roll, cubes_pitch), (ocs_yaw, ocs_roll, ocs_pitch)