Fiddling around with lighting and a Rendermanager
This commit is contained in:
parent
b5ec100c9c
commit
325da79fac
3 changed files with 37 additions and 5 deletions
|
@ -12,6 +12,7 @@ from MatrixStuff.Transformations import *
|
|||
class LightingManager:
|
||||
def __init__(self):
|
||||
self.Lights = []
|
||||
self.StructureSteps = []
|
||||
self.renderSteps = []
|
||||
|
||||
def addLight(self,l):
|
||||
|
|
|
@ -40,9 +40,35 @@ class Light:
|
|||
|
||||
|
||||
def __init__(self):
|
||||
self.ModelviewProjectionMatrix = np.identity(4)
|
||||
self._ModelviewProjectionMatrix = np.identity(4)
|
||||
self._pos = [0,0,0]
|
||||
self._lightColor = [1,1,1]
|
||||
self.FramebufferId = -1
|
||||
self.DepthBuffer = -1
|
||||
|
||||
@property
|
||||
def lightColor(self):
|
||||
return self._lightColor
|
||||
@lightColor.setter
|
||||
def lightColor(self,value):
|
||||
self._lightColor = value
|
||||
|
||||
@property
|
||||
def ModelviewProjectionMatrix(self):
|
||||
return self._ModelviewProjectionMatrix
|
||||
|
||||
@ModelviewProjectionMatrix.setter
|
||||
def ModelviewProjectionMatrix(self, value):
|
||||
self._ModelviewProjectionMatrix = np.matrix(value)
|
||||
|
||||
@property
|
||||
def pos(self):
|
||||
return self._pos
|
||||
|
||||
@pos.setter
|
||||
def pos(self,value):
|
||||
self._pos = value
|
||||
|
||||
def prepareForDepthMapping(self):
|
||||
new = False
|
||||
if self.FramebufferId == -1:
|
||||
|
@ -72,3 +98,4 @@ class Light:
|
|||
glDrawBuffers(DrawBuffers)
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,0)
|
||||
|
||||
|
|
10
main.py
10
main.py
|
@ -374,10 +374,14 @@ def display():
|
|||
lightpos = glGetUniformLocation(program_id, 'lightpos')
|
||||
lightcolorid = glGetUniformLocation(program_id, 'lightColor')
|
||||
|
||||
glUniformMatrix4fv(lightProjModelViewMatrix,1,GL_FALSE,np.array(newMat))
|
||||
l.pos = [-cx, -cy, -5]
|
||||
l.ModelviewProjectionMatrix = newMat
|
||||
l.lightColor = [1,1,1]
|
||||
|
||||
glUniformMatrix4fv(lightProjModelViewMatrix,1,GL_FALSE,np.array(l.ModelviewProjectionMatrix))
|
||||
glUniform1iv(numLights, 1, 1)
|
||||
glUniform3fv(lightpos, 1, [-cx,-cy,-5])
|
||||
glUniform3fv(lightcolorid, 1, [1,1,1])
|
||||
glUniform3fv(lightpos, 1, l.pos)
|
||||
glUniform3fv(lightcolorid, 1, l.lightColor)
|
||||
|
||||
texID = glGetUniformLocation(program_id, 'ShadowMaps')
|
||||
glActiveTexture(GL_TEXTURE0)
|
||||
|
|
Loading…
Reference in a new issue