Пример #1
0
 def update_transformed_orientation_if_necessary(self):
     if self.must_update_transformed_orientation and self.searching:
         
         self.transformed_look_dir = \
             multiply_MV(self.geo_to_viewer_transform, self.look_dir)
             
         self.transformed_up_dir = \
             multiply_MV(self.geo_to_viewer_transform, self.up_dir)
             
         self.must_update_transformed_orientation = False
Пример #2
0
 def begin_drawing(self, gl):
     '''
     Sets OpenGL state for rapid drawing
     '''
     self.texture_ref.bind(gl)
     gl.glShadeModel(gl.GL_FLAT)
     
     ########################################################################## added Blending
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
     
     gl.glEnable(gl.GL_ALPHA_TEST)
     gl.glAlphaFunc(gl.GL_GREATER, 0.5)
     gl.glEnable(gl.GL_TEXTURE_2D)
     
     # We're going to do the transformation on the CPU, so set the matrices 
     # to the identity
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     gl.glOrtho(0, self.render_state.screen_width,
                 0, self.render_state.screen_height,
                 -1, 1)
     
     # equivalent of a call to GLBuffer.unbind(gl)
     gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0)
     gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, 0)
     
     gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
     gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
     gl.glDisableClientState(gl.GL_COLOR_ARRAY)
 
     rs = self.render_state
     
     view_width = rs.screen_width
     view_height = rs.screen_height
     
     rotation = create_rotation(rs.up_angle, rs.look_dir)
     self.label_offset = multiply_MV(rotation, rs.up_dir)
 
     # If a label isn't within the field of view angle from the target vector, it can't
     # be on the screen.  Compute the cosine of this angle so we can quickly identify these.
     DEGREES_TO_RADIANS = math.pi / 180.0
     self.dot_product_threshold = math.cos(rs.radius_of_view * DEGREES_TO_RADIANS * \
                                         (1 + view_width / float(view_height)) * 0.5)
Пример #3
0
    def begin_drawing(self, gl):
        '''
        Sets OpenGL state for rapid drawing
        '''
        self.texture_ref.bind(gl)
        gl.glShadeModel(gl.GL_FLAT)

        ########################################################################## added Blending
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        gl.glEnable(gl.GL_ALPHA_TEST)
        gl.glAlphaFunc(gl.GL_GREATER, 0.5)
        gl.glEnable(gl.GL_TEXTURE_2D)

        # We're going to do the transformation on the CPU, so set the matrices
        # to the identity
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.glOrtho(0, self.render_state.screen_width, 0,
                   self.render_state.screen_height, -1, 1)

        # equivalent of a call to GLBuffer.unbind(gl)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0)
        gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, 0)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)

        rs = self.render_state

        view_width = rs.screen_width
        view_height = rs.screen_height

        rotation = create_rotation(rs.up_angle, rs.look_dir)
        self.label_offset = multiply_MV(rotation, rs.up_dir)

        # If a label isn't within the field of view angle from the target vector, it can't
        # be on the screen.  Compute the cosine of this angle so we can quickly identify these.
        DEGREES_TO_RADIANS = math.pi / 180.0
        self.dot_product_threshold = math.cos(rs.radius_of_view * DEGREES_TO_RADIANS * \
                                            (1 + view_width / float(view_height)) * 0.5)