Пример #1
0
 def update_view(self, gl):
     # Get a vector perpendicular to both, pointing to the right, by taking
     # lookDir cross up.
     look_dir = self.render_state.look_dir.copy()
     up_dir = self.render_state.up_dir.copy()
     right = cross_product(look_dir, up_dir)
     
     if self.DEBUG_MODE != None:
         from src.units.Vector3 import Vector3
         look_dir = Vector3(Debug.LOOKDIRVECTORS[self.DEBUG_MODE][0], 
                            Debug.LOOKDIRVECTORS[self.DEBUG_MODE][1], 
                            Debug.LOOKDIRVECTORS[self.DEBUG_MODE][2])
         up_dir = Vector3(Debug.UPDIRVECTORS[self.DEBUG_MODE][0], 
                          Debug.UPDIRVECTORS[self.DEBUG_MODE][1], 
                          Debug.UPDIRVECTORS[self.DEBUG_MODE][2])
         right = Vector3(Debug.RIGHTVECTORS[self.DEBUG_MODE][0], 
                         Debug.RIGHTVECTORS[self.DEBUG_MODE][1], 
                         Debug.RIGHTVECTORS[self.DEBUG_MODE][2])
     
     self.view_matrix = Matrix4x4.create_view(look_dir, up_dir, right)
     
     gl.glMatrixMode(gl.GL_MODELVIEW)
     adjust_matrix = Matrix4x4.Matrix4x4([0.0, 0.0, -1.0, 0.0,
                                          0.0, 1.0, -0.0, 0.0,
                                          1.0, 0.0, -0.0, 0.0,
                                          0.0, 0.0, 0.0, 1.0])
     matrix = Matrix4x4.multiply_MM(self.view_matrix, adjust_matrix)
     
     # Invert the left/right rotation of the matrix
     matrix.values[2] *= -1
     matrix.values[8] *= -1
     
     # Invert these so that we don't rotate in and out of the unit sphere
     matrix.values[1] *= -1
     matrix.values[4] *= -1
     
     matrix = np.array(matrix.values, dtype=np.float32)
     #matrix = np.array(self.view_matrix.values, dtype=np.float32)
     gl.glLoadMatrixf(matrix)