glEnableClientState(GL_NORMAL_ARRAY);\r
glVertexPointer(3, GL_FLOAT, 0, mesh.vertexes)\r
glNormalPointer(GL_FLOAT, 0, mesh.normal)\r
+\r
+ #Odd, drawing in batchs is a LOT faster then drawing it all at once.\r
+ batchSize = 999 #Warning, batchSize needs to be dividable by 3\r
+ extraStartPos = int(mesh.vertexCount / batchSize) * batchSize\r
+ extraCount = mesh.vertexCount - extraStartPos\r
\r
glCullFace(GL_BACK)\r
- glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount)\r
+ for i in xrange(0, int(mesh.vertexCount / batchSize)):\r
+ glDrawArrays(GL_TRIANGLES, i*batchSize, batchSize)\r
+ glDrawArrays(GL_TRIANGLES, extraStartPos, extraCount)\r
\r
glCullFace(GL_FRONT)\r
glNormalPointer(GL_FLOAT, 0, mesh.invNormal)\r
- glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount)\r
+ for i in xrange(0, int(mesh.vertexCount / batchSize)):\r
+ glDrawArrays(GL_TRIANGLES, i*batchSize, batchSize)\r
+ extraStartPos = int(mesh.vertexCount / batchSize) * batchSize\r
+ extraCount = mesh.vertexCount - extraStartPos\r
+ glDrawArrays(GL_TRIANGLES, extraStartPos, extraCount)\r
glCullFace(GL_BACK)\r
\r
glDisableClientState(GL_VERTEX_ARRAY)\r
def _prepareVertexCount(self, vertexNumber):
#Set the amount of faces before loading data in them. This way we can create the numpy arrays before we fill them.
- self.origonalVertexes = numpy.zeros((vertexNumber, 3), float)
- self.normal = numpy.zeros((vertexNumber, 3), float)
+ self.origonalVertexes = numpy.zeros((vertexNumber, 3), numpy.float32)
+ self.normal = numpy.zeros((vertexNumber, 3), numpy.float32)
self.vertexCount = 0
def _postProcessAfterLoad(self):
mat10 = math.sin(rotate) * scaleX
mat11 = math.cos(rotate) * scaleY
- mat = numpy.array([[mat00,mat10,0],[mat01,mat11,0],[0,0,scaleZ]], float)
+ mat = numpy.array([[mat00,mat10,0],[mat01,mat11,0],[0,0,scaleZ]], numpy.float32)
if swapXZ:
- mat = numpy.array([mat[2],mat[1],mat[0]], float)
+ mat = numpy.array([mat[2],mat[1],mat[0]], numpy.float32)
if swapYZ:
- mat = numpy.array([mat[0],mat[2],mat[1]], float)
+ mat = numpy.array([mat[0],mat[2],mat[1]], numpy.float32)
self.vertexes = (numpy.matrix(self.origonalVertexes, copy = False) * numpy.matrix(mat)).getA()
tris = self.vertexes.reshape(self.vertexCount / 3, 3, 3)
normals[:,1] /= lens
normals[:,2] /= lens
- n = numpy.zeros((self.vertexCount / 3, 9), float)
+ n = numpy.zeros((self.vertexCount / 3, 9), numpy.float32)
n[:,0:3] = normals
n[:,3:6] = normals
n[:,6:9] = normals