Skip to content

Instantly share code, notes, and snippets.

@philippTheCat
Created May 26, 2011 21:08
Show Gist options
  • Save philippTheCat/994084 to your computer and use it in GitHub Desktop.
Save philippTheCat/994084 to your computer and use it in GitHub Desktop.
code:
class face:
vertexes = []
def __init__(self):
pass
def addVertex(self,vertex):
if len(self.vertexes) >= 4:
print "vertexes:", len(self.vertexes),
print self.vertexes
raise Exception("face.vertexes >= 4",vertex)
else:
self.vertexes.append(vertex)
def draw(self):
if len(self.vertexes) == 3:
glBegin(GL_TRIANGLES)
elif len(self.vertexes) == 4:
glBegin(GL_QUADS)
else:
return
glColor(0, 0, 1.0)
for i in self.vertexes:
i.draw()
glEnd()
curface = face()
print "new face:",curface.vertexes
output:
vertexes: 4 [<sang.mesh.vertex instance at 0x3207200>, <sang.mesh.vertex instance at 0x3212050>, <sang.mesh.vertex instance at 0x3213f80>, <sang.mesh.vertex instance at 0x3213998>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment