def draw(self): """Draw the whole play layer. The play layer is composed of four different sub-layers. First, the camera image is drawn. Second, every tracked object draws its background. Third, every tracked object draws its 3D part. Finally, every tracked object draws its foreground.""" director.app.frame += 1 w, h = director.get_window_size() glMatrixMode(GL_MODELVIEW) glPushMatrix() self.transform() # Draw the camera image glColor4f(1.0, 1.0, 1.0, 1.0) director.app.tracker.draw_current_frame_gl(w, h) # Draw the background of the tracked objects director.app.object_manager.draw_background() glPopMatrix() # Then draw the 3D objects glMatrixMode(GL_PROJECTION) director.app.tracker.projection_matrix.load_gl() glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() director.app.object_manager.draw_3d() glMatrixMode(GL_MODELVIEW) glPopMatrix() # Finally draw the foregrounds glPushMatrix() director.set_projection() glPopMatrix() glPushMatrix() self.transform() director.app.object_manager.draw_foreground() glPopMatrix() # Draw the original contents also super(PlayLayer, self).draw()
def _set_active(self, bool): if self._active == bool: return self._active = bool if self._active is True: pass elif self._active is False: self.vertex_list.delete() # to restore the camera to default position director.set_projection() else: raise Exception("Invalid value for GridBase.active")