diff --git a/Lights/LightingManager.py b/Lights/LightingManager.py index 70fd585..f92d225 100644 --- a/Lights/LightingManager.py +++ b/Lights/LightingManager.py @@ -12,6 +12,7 @@ from MatrixStuff.Transformations import * class LightingManager: def __init__(self): self.Lights = [] + self.StructureSteps = [] self.renderSteps = [] def addLight(self,l): diff --git a/Lights/Lights.py b/Lights/Lights.py index 568acf1..63623d7 100644 --- a/Lights/Lights.py +++ b/Lights/Lights.py @@ -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: @@ -71,4 +97,5 @@ class Light: DrawBuffers = [GL_COLOR_ATTACHMENT0] glDrawBuffers(DrawBuffers) glClearColor(0.0, 0.0, 0.0, 1.0) - glBindFramebuffer(GL_FRAMEBUFFER,0) \ No newline at end of file + glBindFramebuffer(GL_FRAMEBUFFER,0) + diff --git a/main.py b/main.py index 610ed3f..1b965dc 100644 --- a/main.py +++ b/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)