def createDisplayList(self): # print 'MESH: Creating display list...' self.list = intf.glGenLists(1) intf.glNewList(self.list, intf.GL_COMPILE) intf.glBegin(intf.GL_TRIANGLES) for face in self.mesh.faces: for i in xrange(3): v = face[0][i] t = face[1][i] n = face[2][i] v = self.mesh.vertArray[v - 1] t = self.mesh.textArray[t - 1] n = self.mesh.normArray[n - 1] intf.glNormal3fv(n) intf.glTexCoord2fv(t) intf.glMultiTexCoord2fv(intf.GL_TEXTURE1, t) if len(v) == 3: v.append(1) if len(v) == 4: v[3] = 1 intf.glVertex4fv(v) # Why the hell did I make it 4f? intf.glEnd() intf.glEndList()
def _createDisplayList(self): self.list = intf.glGenLists(1) intf.glNewList(self.list,intf.GL_COMPILE) intf.glBegin(intf.GL_QUADS) intf.glMultiTexCoord2f(intf.GL_TEXTURE1,1 ,1) intf.glVertex3i(0,10,10) intf.glMultiTexCoord2f(intf.GL_TEXTURE1,1,0) intf.glVertex3i(0,10,-10) intf.glMultiTexCoord2f(intf.GL_TEXTURE1,0,0) intf.glVertex3i(0,-10,-10) intf.glMultiTexCoord2f(intf.GL_TEXTURE1, 0, 1) intf.glVertex3i(0,-10,10) intf.glEnd() intf.glEndList()
def createList(self): ''' Just one display list for a tunnel with ~4000 triangles. Make it more efficient? ''' # print 'TUNNEL: Creating display list...' self.list = intf.glGenLists(1) intf.glNewList(self.list,intf.GL_COMPILE) intf.glBegin(intf.GL_QUADS) #intf.glBegin(intf.GL_LINE_STRIP) def diffVectors(x,y): return (x[0] - y[0], x[1] - y[1] , x[2] - y[2]) #x-y def cross(u,v): return (u[1]*v[2] - u[2]*v[1] , u[0]*v[2] - u[2]*v[0], u[0]*v[1] - u[1]*v[0]) for i in xrange(len(self.rings) - 1): for j in xrange(vertNum): r1 = self.rings[i] r2 = self.rings[i+1] # to--------o u # | | # | | # p o--------x o--------o w # | | | # | | | # q o--------y o--------o z # # r0 r1 r2 r3 # x = r1.verts[j] y = r1.verts[j+1] z = r2.verts[j+1] w = r2.verts[j] try: r0 = self.rings[i-1] p = r0.verts[j] q = r0.verts[j+1] except: p = w q = y try: t = r1.verts[j-1] except: t = y try: u = r2.verts[j-1] except: u = z #Cross product normals if j==0: nx = cross(diffVectors(t,x), diffVectors(p,x)) nw = cross(diffVectors(u,w), diffVectors(x,w)) else: nx = cross(diffVectors(p,x), diffVectors(t,x)) nw = cross(diffVectors(x,w), diffVectors(u,w)) ny = cross(diffVectors(q,y), diffVectors(x,y)) nz = cross(diffVectors(y,z), diffVectors(w,z)) #TODO: This func. calls are the startup bottleneck: if intf.pyCaveOptions['tunnel_geom']: if intf.pyCaveOptions['cext_available']: cext.sendVertex(nx,x) cext.sendVertex(ny,y) cext.sendVertex(nz,z) cext.sendVertex(nw,w) else: intf.glNormal3fv(nx) intf.glVertex3fv(x) intf.glNormal3fv(ny) intf.glVertex3fv(y) intf.glNormal3fv(nz) intf.glVertex3fv(z) intf.glNormal3fv(nw) intf.glVertex3fv(w) intf.glEnd() intf.glEndList()