object.py 908 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from OpenGL.GL import *
  2. from OpenGL.GLU import *
  3. from characteristic import Characteristic
  4. from transform import Transform
  5. class Object:
  6. pos = 0
  7. col = 0
  8. loc = 0
  9. def __init__(self):
  10. self.characteristics = []
  11. def draw(self):
  12. transform = 0
  13. for char in self.characteristics:
  14. if char.name == "transform":
  15. transform = char
  16. # if transform
  17. if transform != 0:
  18. glPushMatrix()
  19. glMultMatrixf( transform.matrix )
  20. # draw
  21. glBegin(GL_TRIANGLES)
  22. for vertex in self.pos:
  23. glColor3fv(self.col)
  24. glVertex3fv(vertex)
  25. glEnd()
  26. # end transform
  27. if transform != 0:
  28. glPopMatrix()
  29. def AddCharacteristic(self, characteristic):
  30. self.characteristics.append( characteristic )