2017-08-27 12:51:26 +02:00
|
|
|
from OpenGL.GL import *
|
|
|
|
import numpy as np
|
|
|
|
from OpenGL.GL.ARB.vertex_array_object import glDeleteVertexArrays
|
|
|
|
from OpenGL.GL.framebufferobjects import glBindRenderbuffer
|
|
|
|
from OpenGL.GLUT import *
|
|
|
|
import OpenGL.GLUT.freeglut
|
|
|
|
from OpenGL.GLU import *
|
|
|
|
from OpenGL.GL import *
|
|
|
|
from ctypes import sizeof, c_float, c_void_p, c_uint
|
|
|
|
from MatrixStuff.Transformations import *
|
|
|
|
|
|
|
|
class LightingManager:
|
|
|
|
def __init__(self):
|
|
|
|
self.Lights = []
|
|
|
|
self.renderSteps = []
|
|
|
|
|
|
|
|
def addLight(self,l):
|
|
|
|
self.Lights.append(l)
|
|
|
|
|
|
|
|
def removeLight(self,l):
|
|
|
|
self.Lights.remove(l)
|
|
|
|
|
|
|
|
class __Renderstep:
|
2017-10-21 11:10:00 +02:00
|
|
|
def render(self, projMatrix, geometryRotMatrix):
|
|
|
|
pass
|
|
|
|
class __Structurestep(__Renderstep):
|
|
|
|
def __init__(self, alternateprogramdict, structure):
|
|
|
|
self.alternateprogramdict = alternateprogramdict
|
|
|
|
self.structure = structure
|
2017-08-27 12:51:26 +02:00
|
|
|
def __eq__(self, other):
|
|
|
|
if type(other) is type(self):
|
2017-10-21 11:10:00 +02:00
|
|
|
return self.alternateprogramdict == other.alternateprogramdict and self.structure == self.structure
|
2017-08-27 12:51:26 +02:00
|
|
|
else:
|
|
|
|
return False
|
2017-10-21 11:10:00 +02:00
|
|
|
def render(self,projMatrix,geometryRotMatrix):
|
|
|
|
self.structure.render(projMatrix,geometryRotMatrix,self.alternateprogramdict)
|
|
|
|
class __Clearstep(__Renderstep):
|
|
|
|
def render(self, projMatrix, geometryRotMatrix):
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
2017-08-27 12:51:26 +02:00
|
|
|
|
2017-10-21 11:10:00 +02:00
|
|
|
class __ActivateDepthmappingStep(__Renderstep):
|
|
|
|
def __init__(self,light):
|
|
|
|
self.light = light
|
|
|
|
|
|
|
|
def render(self, projMatrix, geometryRotMatrix):
|
|
|
|
self.light.prepareForDepthMapping()
|
|
|
|
|
|
|
|
class __DeactivateDepthmappingStep(__Renderstep):
|
|
|
|
def __init__(self, light):
|
|
|
|
self.light = light
|
|
|
|
|
|
|
|
def render(self, projMatrix, geometryRotMatrix):
|
|
|
|
self.light.finishDepthMapping()
|
|
|
|
|
2017-10-29 08:37:11 +01:00
|
|
|
|
|
|
|
|
2017-10-21 11:10:00 +02:00
|
|
|
def addRenderStep(self,alternateprogramdict,structure):
|
|
|
|
r = self.__Renderstep(alternateprogramdict,structure)
|
2017-08-27 12:51:26 +02:00
|
|
|
self.renderSteps.append(r)
|
2017-10-21 11:10:00 +02:00
|
|
|
def removeRenderStep(self,alternateprogramdict,structure):
|
|
|
|
r = self.__Renderstep(alternateprogramdict,structure)
|
2017-08-27 12:51:26 +02:00
|
|
|
self.renderSteps.remove(r)
|