コード例 #1
0
ファイル: phong3.py プロジェクト: freneticmonkey/Epsilon
    def on_frame_start(self):
        # Set the proj matrix
        projection = SceneManager.get_current_scene().active_camera.projection_matrix
        camera_pos = SceneManager.get_current_scene().active_camera.node_parent.transform.world_matrix
        if projection:
            #projection.inverse()
            self.set_uniform_data('proj', projection)
        if camera_pos:
            #camera_pos.transpose()
            self.set_uniform_data('view', camera_pos)

        lights = SceneManager.get_current_scene().lights
        if len(lights) > 0:
            light_pos = lights[0].transform.position
            self.set_uniform_data('lightPosition', light_pos)
コード例 #2
0
 def setup_3d(self):
     
     setup_ok = False
     
     # Configure OpenGL Settings for drawing 3D
     glEnable(GL_DEPTH_TEST)
     glEnable(GL_POLYGON_SMOOTH)
     glEnable(GL_BLEND)
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
     glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
     
     glShadeModel(GL_SMOOTH)
     
     glCullFace(GL_BACK)
     glEnable(GL_CULL_FACE)
             
     glClearColor(*self._back_colour.get_gl_colour())
     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
     
     if Settings.get('RenderSettings','wireframe'):
         glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
     else:
         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
     
     # If the SceneManager instance hasn't been set
     if self._camera is None and self._scene_root is None:
         if not SceneManager.get_current_scene() is None:
             # If there isn't a camera set, get the active camera from the SceneManager
             if self._camera is None:
                 self._camera = SceneManager.get_current_scene().active_camera
             
             # Get the Scene Root
             if self._scene_root is None:    
                 self._scene_root = SceneManager.get_current_scene().root
     
     setup_ok = False
     if self._camera is None:
         Logger.Log("RENDER ERROR: Camera not found.")
     elif self._scene_root is None:
         Logger.Log("RENDER ERROR: Scene Root not found.")
     else:
         setup_ok = True
         
         # Activate the camera for rendering
         # set_projection, etc
         self._camera.activate()
     
     return setup_ok