[PyOpenGL-Users] culling with tétrahedron
Brought to you by:
mcfletch
From: Roland E. <r.e...@gm...> - 2010-05-14 19:25:07
|
Hi, I am currently trying culling with a tetrahedron, but when I make it spin, some vertices disappear while they shouldn't, following the point of view of the camera. Below is the code of the class I use to handle the object: class Tetrahedron(Polyhedron): def __init__(self, size): self.vertices = [0.0, 0.0, float(size), (float(size))*math.sin(120), 0.0, -(float(size))*math.cos(120), -(float(size))*math.sin(240), 0.0, -(float(size))*math.cos(240), 0.0, float(size), 0.0] self.indices = [0, 1, 2, 0, 3, 2, 0, 3, 1, 1, 3, 2] Polyhedron.__init__(self) def render(self): glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) glEnableClientState(GL_VERTEX_ARRAY) glVertexPointer(3, GL_FLOAT, 0, self.vertices) # Specify the vertex list to be used to draw the object glEnable(GL_CULL_FACE) glCullFace(GL_BACK) glColor3f(*self.color) glTranslatef (*self.position) glRotatef (self.x_angle, 1.0, 0.0, 0.0) glRotatef (self.y_angle, 0.0, 1.0, 0.0) glRotatef (self.z_angle, 0.0, 0.0, 1.0) glScalef (*self.scaling) glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_BYTE, self.indices) glDisable(GL_CULL_FACE) glDisableClientState(GL_VERTEX_ARRAY) What am I missing? I did not face that problem with a Cube using the same code for method render (except for 1st and 2nd parameters of glDrawElements) The superclass polyhedron only contains the variables used for the transformation and a few convenience method to set them. I am running the code on Linux AMD 64 with pygame to get the window and interacting with the user. Thanks for your help, Roland. |