Пример #1
0
 def maybe_update_matrices(self, gl):
     update_transform = self.must_update_view or self.must_update_projection
     if self.must_update_view:
         self.update_view(gl)
         self.must_update_view = False
     if self.must_update_projection:
         self.update_perspective(gl)
         self.must_update_projection = False
         
     if update_transform:
         # Device coordinates are a square from (-1, -1) to (1, 1).  Screen
         # coordinates are (0, 0) to (width, height).  Both coordinates
         # are useful in different circumstances, so we'll pre-compute
         # matrices to do the transformations from world coordinates
         # into each of these.
         transform_to_device = Matrix4x4.multiply_MM(self.projection_matrix, self.view_matrix)
         
         translate = Matrix4x4.create_translation(1.0, 1.0, 0.0)
         scale = Matrix4x4.create_scaling(self.render_state.screen_width * 0.5, 
                                          self.render_state.screen_height * 0.5, 1)
         
         transform_to_screen = \
         Matrix4x4.multiply_MM(Matrix4x4.multiply_MM(scale, translate), transform_to_device)
         
         self.render_state.set_tranformation_matrices(transform_to_device, transform_to_screen)