Beispiel #1
0
 def rotate(self, ang, rx, ry, rz):
     glPushMatrix()
     glLoadIdentity()
     glRotatef(ang, rx, ry, rz)
     glMultMatrixf(self.matrix)
     self.matrix = get_model_matrix()
     glPopMatrix()
Beispiel #2
0
 def translate(self, dx, dy, dz):
     glPushMatrix()
     glLoadIdentity()
     glTranslatef(dx, dy, dz)
     glMultMatrixf(self.matrix)
     self.matrix = get_model_matrix()
     glPopMatrix()
Beispiel #3
0
 def chain(self):
     gl.glPushMatrix()
     p = self.position
     r = self.rotation
     gl.glMultMatrixf(
         raw(
             r[0][0],
             r[1][0],
             r[2][0],
             0.0,
             r[0][1],
             r[1][1],
             r[2][1],
             0.0,
             r[0][2],
             r[1][2],
             r[2][2],
             0.0,
             p[0],
             p[1],
             p[2],
             1.0,
         )
     )
     self.material.apply()
     self.render()
     self.material.unapply()
     for c in self.children:
         c.chain()
     gl.glPopMatrix()
Beispiel #4
0
    def set_state(self):
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(self.transform))

        if self.texture:
            gl.glEnable(self.texture.target)
            gl.glBindTexture(self.texture.target, self.texture.id)
Beispiel #5
0
    def set_state(self):
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(self.transform))

        if self.texture:
            gl.glEnable(self.texture.target)
            gl.glBindTexture(self.texture.target, self.texture.id)
Beispiel #6
0
    def show_drone(self, position, rotation):
        """
        Show the drone 3D model with corresponding translation and rotation.
        """
        # Get the transform matrix for drone 3D model
        x, z, y = position
        transform = np.eye(4)
        transform[:3, 3] = [x, y, z]

        # NOTE: change the view size of drone 3D model
        transform[0, 0] = 2.5
        transform[1, 1] = 2.5
        transform[2, 2] = 2.5

        yaw, pitch, roll = rotation
        transform = np.dot(transform, rotation_transform_mat(yaw, 'yaw'))
        transform = np.dot(transform, rotation_transform_mat(pitch, 'pitch'))
        transform = np.dot(transform, rotation_transform_mat(roll, 'roll'))

        # Add a new matrix to the model stack to transform the model
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(transform))

        # Enable the target texture
        if self.drone_texture is not None:
            gl.glEnable(self.drone_texture.target)
            gl.glBindTexture(self.drone_texture.target, self.drone_texture.id)

        # Draw the mesh with its transform applied
        self.drone_drawer.draw(mode=self.drone_vertex_list_mode)
        gl.glPopMatrix()

        # Disable texture after using
        if self.drone_texture is not None:
            gl.glDisable(self.drone_texture.target)
Beispiel #7
0
    def draw_world_items(self, glyphs):
        '''
        Draw all passed glyphs
        '''
        shader = None
        for position, orientation, glyph in glyphs:

            gl.glPushMatrix()

            gl.glTranslatef(*position)
            if orientation and orientation != Orientation.Identity:
                gl.glMultMatrixf(orientation.matrix)

            if glyph.shader is not shader:
                shader = glyph.shader
                shader.use()

            gl_wrap.glBindVertexArray(glyph.vao)

            gl.glDrawElements(
                gl.GL_TRIANGLES,
                len(glyph.glindices),
                glyph.index_type,
                glyph.glindices
            )

            gl.glPopMatrix()

        gl_wrap.glBindVertexArray(0)
        Shader.unuse()
Beispiel #8
0
 def translate(self,dx,dy,dz):
     glPushMatrix()
     glLoadIdentity()
     glTranslatef(dx,dy,dz)
     glMultMatrixf(self.matrix)
     self.matrix=get_model_matrix()
     glPopMatrix()
Beispiel #9
0
 def rotate(self,ang,rx,ry,rz):
     glPushMatrix()
     glLoadIdentity()
     glRotatef(ang,rx,ry,rz)
     glMultMatrixf(self.matrix)
     self.matrix=get_model_matrix()
     glPopMatrix()
    def ApplyCameraTransform(self, bRotOnly = False):

        m = self.GetCameraOrientation()
        
        # Camera Transform
        glMultMatrixf(m)
    
        # If Rotation only, then do not do the translation
        if not bRotOnly:
            glTranslatef(-self.vOrigin[0], -self.vOrigin[1], -self.vOrigin[2])
Beispiel #11
0
    def ApplyCameraTransform(self, bRotOnly=False):

        m = self.GetCameraOrientation()

        # Camera Transform
        glMultMatrixf(m)

        # If Rotation only, then do not do the translation
        if not bRotOnly:
            glTranslatef(-self.vOrigin[0], -self.vOrigin[1], -self.vOrigin[2])
Beispiel #12
0
    def draw(self):
        T = self.body.T

        mT = T.flatten('F').tolist()[0]

        mT = (gl.GLfloat * len(mT))(*mT)  # FIXME there is prob a better way...
        gl.glMultMatrixf(mT)
        if self.collides:
            gl.glColor3f(*red)
        else:
            gl.glColor3f(*self.color)
        self.cube.draw()
Beispiel #13
0
    def draw(self):
        T = self.body.T

        mT = T.flatten('F').tolist()[0]

        mT = (gl.GLfloat * len(mT))(*mT)  # FIXME there is prob a better way...
        gl.glMultMatrixf(mT)
        if self.collides:
            gl.glColor3f(*red)
        else:
            gl.glColor3f(*self.color)
        self.cube.draw()
Beispiel #14
0
    def set_state(self):
        self._set_view()

        SceneViewer._gl_set_background(self._background)
        SceneViewer._gl_enable_depth()
        SceneViewer._gl_enable_color_material()
        SceneViewer._gl_enable_blending()
        SceneViewer._gl_enable_smooth_lines()
        SceneViewer._gl_enable_lighting(self.scene)

        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.glMultMatrixf(
            rendering.matrix_to_gl(np.linalg.inv(self.scene.camera.transform)))
Beispiel #15
0
    def set_state(self):
        self._set_view()

        SceneViewer._gl_set_background(self._background)
        SceneViewer._gl_enable_depth()
        SceneViewer._gl_enable_color_material()
        SceneViewer._gl_enable_blending()
        SceneViewer._gl_enable_smooth_lines()
        SceneViewer._gl_enable_lighting(self.scene)

        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.glMultMatrixf(
            rendering.matrix_to_gl(np.linalg.inv(self.scene.camera.transform)))
Beispiel #16
0
    def show_drone(self, position, rotation):
        """
        Show the drone 3D model with corresponding translation and rotation.
        """
        # Get the transform matrix for drone 3D model
        x, z, y = position
        transform = np.eye(4)
        transform[:3, 3] = [x, y, z]

        # NOTE: change the view size of drone 3D model
        transform[0, 0] = 2.5
        transform[1, 1] = 2.5
        transform[2, 2] = 2.5

        # Match drone model space x-y-z to openGL x-z-y
        # TODO: read the config.json and match the propeller positions
        model_space_transform = rotation_transform_mat(-np.pi / 2, 'roll')
        transform = np.dot(transform, model_space_transform)

        yaw, pitch, roll = rotation
        if self.debug_mode:
            # NOTE: manually set values to debug rotation,
            # it's useful when input act is in form [c, c, c, c].
            yaw = np.pi / 2
            # pitch = np.pi / 2
            # roll = np.pi / 2
        transform = np.dot(transform, rotation_transform_mat(yaw, 'yaw'))
        transform = np.dot(transform, rotation_transform_mat(pitch, 'pitch'))
        transform = np.dot(transform, rotation_transform_mat(roll, 'roll'))

        # Add a new matrix to the model stack to transform the model
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(transform))

        # Enable the target texture
        if self.drone_texture is not None:
            gl.glEnable(self.drone_texture.target)
            gl.glBindTexture(self.drone_texture.target, self.drone_texture.id)

        # Draw the mesh with its transform applied
        self.drone_drawer.draw(mode=self.drone_vertex_list_mode)
        gl.glPopMatrix()

        # Disable texture after using
        if self.drone_texture is not None:
            gl.glDisable(self.drone_texture.target)
Beispiel #17
0
    def on_draw(self):
        if self._profile:
            profiler = self.Profiler()
            profiler.start()

        self._update_vertex_list()

        transform_camera = np.linalg.inv(self._scene.camera_transform)
        transform_camera = np.asanyarray(transform_camera, dtype=np.float32)
        gl.glMultMatrixf((gl.GLfloat * 16)(*transform_camera.T.ravel()))

        node_names = collections.deque(self._scene.graph.nodes_geometry)
        while len(node_names) > 0:
            current_node = node_names.popleft()
            transform, geometry_name = self._scene.graph.get(current_node)

            if geometry_name is None:
                continue

            mesh = self._scene.geometry[geometry_name]
            if mesh.is_empty:
                continue

            mode = self._vertex_list_mode[geometry_name]
            if mode == gl.GL_LINES:
                # apply the offset in camera space
                arrays = [
                    transform,
                    np.linalg.inv(transform_camera), self._line_offset,
                    transform_camera
                ]
                transform = np.linalg.multi_dot(arrays)

            gl.glPushMatrix()
            transform = np.asanyarray(transform, dtype=np.float32)
            transform = (gl.GLfloat * 16)(*transform.T.ravel())
            gl.glMultMatrixf(transform)

            # draw the mesh with its transform applied
            self._vertex_list[geometry_name].draw(mode=mode)
            gl.glPopMatrix()

        if self._profile:
            profiler.stop()
            print(profiler.output_text(unicode=True, color=True))
Beispiel #18
0
    def show_velocity(self, position, velocity, expected_velocity=None):
        """
        Show velocity vector as a thin cylinder arrow.
        """
        if not hasattr(self, 'drone_velocity_drawer'):
            return

        transform = self._get_velocity_transform(velocity, position)
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(transform))

        self.drone_velocity_drawer.draw(mode=self.drone_vertex_list_mode)
        gl.glPopMatrix()

        if expected_velocity is not None and \
           hasattr(self, 'drone_expected_velocity_drawer'):
            transform = self._get_velocity_transform(expected_velocity,
                                                     position)
            gl.glPushMatrix()
            gl.glMultMatrixf(rendering.matrix_to_gl(transform))

            self.drone_expected_velocity_drawer.draw(
                mode=self.drone_vertex_list_mode)
            gl.glPopMatrix()
Beispiel #19
0
    def on_draw(self):
        self._update_meshes()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()

        # pull the new camera transform from the scene
        transform_camera, _junk = self.scene.graph['camera']

        # apply the camera transform to the matrix stack
        gl.glMultMatrixf(_gl_matrix(transform_camera))

        # dragging the mouse moves the view transform (but doesn't alter the
        # scene)
        transform_view = _view_transform(self.view)
        gl.glMultMatrixf(_gl_matrix(transform_view))

        # we want to render fully opaque objects first,
        # followed by objects which have transparency
        node_names = collections.deque(self.scene.graph.nodes_geometry)
        count_original = len(node_names)
        count = -1

        while len(node_names) > 0:
            count += 1
            current_node = node_names.popleft()

            # if the flag isn't defined, this will be None
            # by checking False explicitly, it makes the default
            # behaviour to render meshes with no flag defined.
            # if self.node_flag(name_node, 'visible') is False:
            #    continue

            transform, geometry_name = self.scene.graph[current_node]

            if geometry_name is None:
                continue

            mesh = self.scene.geometry[geometry_name]

            if (hasattr(mesh, 'visual') and
                    mesh.visual.transparency):
                # put the current item onto the back of the queue
                if count < count_original:
                    node_names.append(current_node)
                    continue

            # add a new matrix to the model stack
            gl.glPushMatrix()
            # transform by the nodes transform
            gl.glMultMatrixf(_gl_matrix(transform))
            # get the mode of the current geometry
            mode = self.vertex_list_mode[geometry_name]
            # draw the mesh with its transform applied
            self.vertex_list[geometry_name].draw(mode=mode)
            # pop the matrix stack as we drew what we needed to draw
            gl.glPopMatrix()
Beispiel #20
0
    def on_draw(self):
        self._update_meshes()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()

        # pull the new camera transform from the scene
        transform_camera = self.scene.transforms['camera']
        # apply the camera transform to the matrix stack
        gl.glMultMatrixf(_gl_matrix(transform_camera))
        
        # dragging the mouse moves the view transform (but doesn't alter the scene)
        transform_view = _view_transform(self.view)
        gl.glMultMatrixf(_gl_matrix(transform_view))

        # we want to render fully opaque objects first,
        # followed by objects which have transparency
        items = deque(self.scene.nodes.items())
        count_original = len(items)
        count = -1
        
        while len(items) > 0:
            count += 1
            item = items.popleft()
            name_node, name_mesh = item

            # if the flag isn't defined, this will be None
            # by checking False explicitly, it makes the default
            # behaviour to render meshes with no flag defined. 
            if self.node_flag(name_node, 'visible') == False:
                continue
                
            if self.scene.meshes[name_mesh].visual.transparency:
                # put the current item onto the back of the queue
                if count < count_original:
                    items.append(item)
                    continue

            transform = self.scene.transforms[name_node]
            # add a new matrix to the model stack
            gl.glPushMatrix()
            # transform by the nodes transform
            gl.glMultMatrixf(_gl_matrix(transform))
            # draw the mesh with its transform applied
            self.vertex_list[name_mesh].draw(mode=gl.GL_TRIANGLES)
            # pop the matrix stack as we drew what we needed to draw
            gl.glPopMatrix()
Beispiel #21
0
    def on_draw(self):
        self._update_meshes()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()

        # pull the new camera transform from the scene
        transform_camera = self.scene.transforms['camera']
        # apply the camera transform to the matrix stack
        gl.glMultMatrixf(_gl_matrix(transform_camera))
        
        # dragging the mouse moves the view transform (but doesn't alter the scene)
        transform_view = _view_transform(self.view)
        gl.glMultMatrixf(_gl_matrix(transform_view))

        # we want to render fully opaque objects first,
        # followed by objects which have transparency
        items = deque(self.scene.nodes.items())
        count_original = len(items)
        count = -1
        
        while len(items) > 0:
            count += 1
            item = items.popleft()
            name_node, name_mesh = item

            # if the flag isn't defined, this will be None
            # by checking False explicitly, it makes the default
            # behaviour to render meshes with no flag defined. 
            if self.node_flag(name_node, 'visible') == False:
                continue
                
            if self.scene.meshes[name_mesh].visual.transparency:
                # put the current item onto the back of the queue
                if count < count_original:
                    items.append(item)
                    continue

            transform = self.scene.transforms[name_node]
            # add a new matrix to the model stack
            gl.glPushMatrix()
            # transform by the nodes transform
            gl.glMultMatrixf(_gl_matrix(transform))
            # draw the mesh with its transform applied
            self.vertex_list[name_mesh].draw(mode=gl.GL_TRIANGLES)
            # pop the matrix stack as we drew what we needed to draw
            gl.glPopMatrix()
        x = hmd.headPose.translation.x
        y = hmd.headPose.translation.y
        z = hmd.headPose.translation.z
        # print(x, y, z)

        # use OpenGL rendering commands here...

        # Just draw a triangle 2 meters away. Let's use the ovrMatrix4f type to
        # handle the translation. You can do whatever you like to the position
        # every frame.
        #
        triangle_origin = ovrVector3f(0.0, 0.0, -2.0)
        M = ovrMatrix4f.translation(triangle_origin)

        GL.glPushMatrix()
        GL.glMultMatrixf(M.ctypes)  # multiply the scene by the matrix
        GL.glBegin(GL.GL_TRIANGLES)
        GL.glColor3f(1, 0, 0)
        GL.glVertex3f(-1.0, -1.0, 0.0)
        GL.glColor3f(0, 1, 0)
        GL.glVertex3f(1.0, -1.0, 0.0)
        GL.glColor3f(0, 0, 1)
        GL.glVertex3f(0.0, 1.0, 0.0)
        GL.glEnd()
        GL.glPopMatrix()

    # send the rendered buffer to the HMD
    hmd.flip()

    # check if the application should exit
    if event.getKeys('q') or hmd.shouldQuit:
Beispiel #23
0
 def draw(self):
     eyex,eyey,eyez,centx,centy,centz,upx,upy,upz=self.lookat
     gluLookAt(eyex,eyey,eyez,centx,centy,centz,upx,upy,upz)
     glMultMatrixf(self.cam_trans.matrix)
     glMultMatrixf(self.cam_rot.matrix)
Beispiel #24
0
 def glmult(l):
        return glMultMatrixf( (GLfloat * len(l))(*l) )
Beispiel #25
0
 def apply(self, mat):
     gl.glMultMatrixf(mat)
Beispiel #26
0
 def draw(self):
     eyex, eyey, eyez, centx, centy, centz, upx, upy, upz = self.lookat
     gluLookAt(eyex, eyey, eyez, centx, centy, centz, upx, upy, upz)
     glMultMatrixf(self.cam_trans.matrix)
     glMultMatrixf(self.cam_rot.matrix)
 def premultiply(self, values):
     gl.glMultMatrixf(*values)
Beispiel #28
0
    def ApplyActorTransform(self, bRotationOnly=False):
        rotMat = self.GetMatrix(bRotationOnly)

        # Apply rotation to the current matrix
        glMultMatrixf(rotMat)
 def ApplyActorTransform(self, bRotationOnly = False):
     rotMat = self.GetMatrix(bRotationOnly)
     
     # Apply rotation to the current matrix
     glMultMatrixf(rotMat)
Beispiel #30
0
 def set_up_matrix(self):
     glPushMatrix()
     glMultMatrixf(self._model_view_matrix)
Beispiel #31
0
 def mult_rot_matrix(self, rot):
     pgl.glPushMatrix()
     pgl.glLoadMatrixf(rot)
     pgl.glMultMatrixf(self._rot)
     self._rot = get_model_matrix()
     pgl.glPopMatrix()
Beispiel #32
0
 def apply_transformation(self):
     pgl.glLoadIdentity()
     pgl.glTranslatef(self._x, self._y, -self._dist)
     if self._rot is not None:
         pgl.glMultMatrixf(self._rot)
     pgl.glScalef(*self._get_scale())
Beispiel #33
0
 def mult_rot_matrix(self, rot):
     pgl.glPushMatrix()
     pgl.glLoadMatrixf(rot)
     pgl.glMultMatrixf(self._rot)
     self._rot = get_model_matrix()
     pgl.glPopMatrix()
Beispiel #34
0
 def apply_transformation(self):
     pgl.glLoadIdentity()
     pgl.glTranslatef(self._x, self._y, -self._dist)
     if self._rot is not None:
         pgl.glMultMatrixf(self._rot)
     pgl.glScalef(*self._get_scale())
Beispiel #35
0
    def on_draw(self):
        self._update_meshes()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()

        # pull the new camera transform from the scene
        transform_camera, _junk = self.scene.graph['camera']

        # apply the camera transform to the matrix stack
        gl.glMultMatrixf(rendering.matrix_to_gl(transform_camera))

        # dragging the mouse moves the view transform
        # but doesn't alter the scene
        transform_view = view_to_transform(self.view)
        gl.glMultMatrixf(rendering.matrix_to_gl(transform_view))

        # we want to render fully opaque objects first,
        # followed by objects which have transparency
        node_names = collections.deque(self.scene.graph.nodes_geometry)
        count_original = len(node_names)
        count = -1

        # if we are rendering an axis marker at the world
        if self._axis:
            # we stored it as a vertex list
            self._axis.draw(mode=gl.GL_TRIANGLES)

        while len(node_names) > 0:
            count += 1
            current_node = node_names.popleft()

            # get the transform from world to geometry and mesh name
            transform, geometry_name = self.scene.graph[current_node]

            # if no geometry at this frame continue without rendering
            if geometry_name is None:
                continue

            # get a reference to the mesh so we can check transparency
            mesh = self.scene.geometry[geometry_name]

            # add a new matrix to the model stack
            gl.glPushMatrix()
            # transform by the nodes transform
            gl.glMultMatrixf(rendering.matrix_to_gl(transform))

            # draw an axis marker for each mesh frame
            if self.view['axis'] == 'all':
                self._axis.draw(mode=gl.GL_TRIANGLES)

            # transparent things must be drawn last
            if (hasattr(mesh, 'visual')
                    and hasattr(mesh.visual, 'transparency')
                    and mesh.visual.transparency):
                # put the current item onto the back of the queue
                if count < count_original:
                    # add the node to be drawn last
                    node_names.append(current_node)
                    # pop the matrix stack for now
                    gl.glPopMatrix()
                    # come back to this mesh later
                    continue

            #
            texture = None
            if geometry_name in self.textures:
                texture = self.textures[geometry_name]
                gl.glEnable(texture.target)
                gl.glBindTexture(texture.target, texture.id)

            # get the mode of the current geometry
            mode = self.vertex_list_mode[geometry_name]
            # draw the mesh with its transform applied
            self.vertex_list[geometry_name].draw(mode=mode)
            # pop the matrix stack as we drew what we needed to draw
            gl.glPopMatrix()

            if texture is not None:
                gl.glDisable(texture.target)
Beispiel #36
0
 def render(self):
     glPushMatrix()
     glMultMatrixf(self.m)
     self.model.render()
     glPopMatrix()
Beispiel #37
0
 def glmult(l):
         return glMultMatrixf( l )
Beispiel #38
0
    def on_draw(self):
        """
        Run the actual draw calls.
        """

        if self._profile:
            profiler = self.Profiler()
            profiler.start()

        self._update_meshes()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        gl.glLoadIdentity()

        # pull the new camera transform from the scene
        transform_camera = np.linalg.inv(self.scene.camera_transform)

        # apply the camera transform to the matrix stack
        gl.glMultMatrixf(rendering.matrix_to_gl(transform_camera))

        # we want to render fully opaque objects first,
        # followed by objects which have transparency
        node_names = collections.deque(self.scene.graph.nodes_geometry)
        # how many nodes did we start with
        count_original = len(node_names)
        count = -1

        # if we are rendering an axis marker at the world
        if self._axis:
            # we stored it as a vertex list
            self._axis.draw(mode=gl.GL_TRIANGLES)
        if self._grid:
            self._grid.draw(mode=gl.GL_LINES)

        while len(node_names) > 0:
            count += 1
            current_node = node_names.popleft()

            if current_node in self._nodes_hidden:
                continue

            # get the transform from world to geometry and mesh name
            transform, geometry_name = self.scene.graph.get(current_node)

            # if no geometry at this frame continue without rendering
            if geometry_name is None:
                continue

            # if a geometry is marked as fixed apply the inverse view transform
            if self.fixed is not None and geometry_name in self.fixed:
                # remove altered camera transform from fixed geometry
                transform_fix = np.linalg.inv(
                    np.dot(self._initial_camera_transform, transform_camera))
                # apply the transform so the fixed geometry doesn't move
                transform = np.dot(transform, transform_fix)

            # get a reference to the mesh so we can check transparency
            mesh = self.scene.geometry[geometry_name]
            if mesh.is_empty:
                continue

            # get the GL mode of the current geometry
            mode = self.vertex_list_mode[geometry_name]

            # if you draw a coplanar line with a triangle it will z-fight
            # the best way to do this is probably a shader but this works fine
            if mode == gl.GL_LINES:
                # apply the offset in camera space
                transform = util.multi_dot([
                    transform,
                    np.linalg.inv(transform_camera),
                    self._line_offset,
                    transform_camera])

            # add a new matrix to the model stack
            gl.glPushMatrix()
            # transform by the nodes transform
            gl.glMultMatrixf(rendering.matrix_to_gl(transform))

            # draw an axis marker for each mesh frame
            if self.view['axis'] == 'all':
                self._axis.draw(mode=gl.GL_TRIANGLES)

            # transparent things must be drawn last
            if (hasattr(mesh, 'visual') and
                hasattr(mesh.visual, 'transparency')
                    and mesh.visual.transparency):
                # put the current item onto the back of the queue
                if count < count_original:
                    # add the node to be drawn last
                    node_names.append(current_node)
                    # pop the matrix stack for now
                    gl.glPopMatrix()
                    # come back to this mesh later
                    continue

            # if we have texture enable the target texture
            texture = None
            if geometry_name in self.textures:
                texture = self.textures[geometry_name]
                gl.glEnable(texture.target)
                gl.glBindTexture(texture.target, texture.id)

            # draw the mesh with its transform applied
            self.vertex_list[geometry_name].draw(mode=mode)
            # pop the matrix stack as we drew what we needed to draw
            gl.glPopMatrix()

            # disable texture after using
            if texture is not None:
                gl.glDisable(texture.target)

        if self._profile:
            profiler.stop()
            print(profiler.output_text(unicode=True, color=True))
        x = hmd.headPose.translation.x
        y = hmd.headPose.translation.y
        z = hmd.headPose.translation.z
        # print(x, y, z)

        # use OpenGL rendering commands here...

        # Just draw a triangle 2 meters away. Let's use the ovrMatrix4f type to
        # handle the translation. You can do whatever you like to the position
        # every frame.
        #
        triangle_origin = ovrVector3f(0.0, 0.0, -2.0)
        M = ovrMatrix4f.translation(triangle_origin)

        GL.glPushMatrix()
        GL.glMultMatrixf(M.ctypes)  # multiply the scene by the matrix
        GL.glBegin(GL.GL_TRIANGLES)
        GL.glColor3f(1, 0, 0)
        GL.glVertex3f(-1.0, -1.0, 0.0)
        GL.glColor3f(0, 1, 0)
        GL.glVertex3f(1.0, -1.0, 0.0)
        GL.glColor3f(0, 0, 1)
        GL.glVertex3f(0.0, 1.0, 0.0)
        GL.glEnd()
        GL.glPopMatrix()

    # send the rendered buffer to the HMD
    hmd.flip()

    # check if the application should exit
    if event.getKeys('q') or hmd.shouldQuit: