Fiddling around with lighting and a Rendermanager
This commit is contained in:
parent
8dcc04b7b2
commit
8d7625a411
5 changed files with 88 additions and 22 deletions
Objects
|
@ -8,7 +8,13 @@ class Object:
|
|||
return True
|
||||
def __init__(self):
|
||||
self.pos = np.zeros((3))
|
||||
self.color = np.zeros((3))
|
||||
self.color = np.zeros((3,))
|
||||
self.programmId = -1
|
||||
def translate(self,M):
|
||||
self.pos = self.pos * M
|
||||
self.pos = np.array((np.concatenate((self.pos, [1])) * M)[0,0:3])[0]
|
||||
return self
|
||||
def setColor(self,R,G,B):
|
||||
self.color[0] = R
|
||||
self.color[1] = G
|
||||
self.color[2] = B
|
||||
return self
|
|
@ -8,6 +8,8 @@ from OpenGL.GLU import *
|
|||
from OpenGL.GL import *
|
||||
|
||||
import numpy as np
|
||||
from OpenGL.extensions import alternate
|
||||
|
||||
|
||||
def check_error(message):
|
||||
gl_error = glGetError()
|
||||
|
@ -140,4 +142,28 @@ class Structure:
|
|||
check_error("Rendering problem")
|
||||
|
||||
glBindVertexArray(0)
|
||||
glUseProgram(0)
|
||||
glUseProgram(0)
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(other) is type(self):
|
||||
return self.vais == other.vais and self.Objects == other.Objects
|
||||
else:
|
||||
return False
|
||||
|
||||
class CompoundStructure:
|
||||
def __init__(self):
|
||||
self.Structures = []
|
||||
|
||||
def addStructure(self, structure : Structure, M : np.matrix = np.identity(4, np.float), R : np.matrix = np.identity(3, np.float)):
|
||||
self.Structures.append((structure,M,R))
|
||||
|
||||
def render(self,projMatrix,geometryRotMatrix,alternateprograms = None):
|
||||
for (structure, M, R) in self.Structures:
|
||||
structure.buildvertexArrays()
|
||||
structure.render(M*projMatrix, R*geometryRotMatrix, alternateprograms)
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(other) is type(self):
|
||||
return self.Structures == other.Structures
|
||||
else:
|
||||
return False
|
Loading…
Add table
Add a link
Reference in a new issue