Пример #1
0
 def _createVertexBuffer(self):
     self.vertexbuffer = VertexBuffer.MakeStandardVertexBuffer(
         vertices=[vec3(*x) for x in self.vertexArray],
         tex_coords=ListFunctions.flattenListOfLists(self.texCoords),
         tex_coords_2=ListFunctions.flattenListOfLists(self.worldTexCoords))
     self.indexbuffer = VertexBuffer.IndexBufferObject(self.indexArray,
                                                       element_type='I')
Пример #2
0
 def _createVertexBuffer(self):
     self.vertexbuffer = VertexBuffer.MakeStandardVertexBuffer(
         vertices=[vec3(*x) for x in self.vertexArray],
         tex_coords=ListFunctions.flattenListOfLists( self.texCoords ),
         tex_coords_2=ListFunctions.flattenListOfLists( self.worldTexCoords )
         )
     self.indexbuffer = VertexBuffer.IndexBufferObject( self.indexArray, element_type='I' )
Пример #3
0
 def makeVertexBuffer(self):
     self.vertexbuffer = VertexBuffer.MakeStandardVertexBuffer(
         vertices=[vec3(*x) for x in self.vertices_gl],
         normals=[vec3(*x) for x in self.normals_gl],
         tex_coords=ListFunctions.flattenListOfLists(self.texcoord_gl)
         )
     self.indexbuffer = VertexBuffer.IndexBufferObject( self.indices_gl )
Пример #4
0
    def _createPhysicsBody(self):
        """Creates a physics body"""
        solver = self.world.solver

        #Create the collision geometry
        print "Creating collision geometry..."
        self.collisionGeom = self.world.solver.makeMesh()

        #check if the heightmap mesh has already been serialized..
        meshpath = self.world.fsPath() + 'terrain.superserial'
        if os.path.isfile(meshpath):
            #...if it has, just load it
            print "Heightmap mesh collision exists, loading.."
            self.collisionGeom.Deserialize(meshpath)
        else:
            self.collisionGeom.BeginBuild()
            faces = self.getFaceList()
            for face in faces:
                self.collisionGeom.AddFace(
                    ListFunctions.flattenListOfLists(face), 0)
            self.collisionGeom.EndBuild(0)
            print "Heightmap mesh collision built, saving for future uses..."
            self.collisionGeom.Serialize(meshpath)

        #Create the body
        self.body = solver.makeBody(self.collisionGeom, self)
        self.body.TreeCollisionCallback = self.onHeightmapCollision
Пример #5
0
    def _createPhysicsBody( self):
        """Creates a physics body"""
        solver = self.world.solver

        #Create the collision geometry
        print "Creating collision geometry..."
        self.collisionGeom = self.world.solver.makeMesh( )

        #check if the heightmap mesh has already been serialized..
        meshpath = self.world.fsPath() + 'terrain.superserial'
        if os.path.isfile( meshpath ):
            #...if it has, just load it
            print "Heightmap mesh collision exists, loading.."
            self.collisionGeom.Deserialize( meshpath )
        else:
            self.collisionGeom.BeginBuild()
            faces = self.getFaceList()
            for face in faces:
                self.collisionGeom.AddFace( ListFunctions.flattenListOfLists( face), 0 )
            self.collisionGeom.EndBuild(0)
            print "Heightmap mesh collision built, saving for future uses..."
            self.collisionGeom.Serialize( meshpath )

        #Create the body
        self.body = solver.makeBody( self.collisionGeom, self )
        self.body.TreeCollisionCallback = self.onHeightmapCollision
Пример #6
0
 def _getProjectionMatrixFromGL(self):
     glMatrixMode(GL_PROJECTION)
     glPushMatrix()
     glLoadIdentity()
     gluPerspective(self.FOV, self.aspect, self.near, self.far)
     self.projectionMatrix = mat4(
         ListFunctions.flattenListOfLists(
             glGetDoublev(GL_PROJECTION_MATRIX))).transpose()
     glPopMatrix()
     glMatrixMode(GL_MODELVIEW)
     return self.projectionMatrix
Пример #7
0
 def _getProjectionMatrixFromGL(self ):
     glMatrixMode(GL_PROJECTION)
     glPushMatrix()
     glLoadIdentity()
     gluPerspective(self.FOV, self.aspect, self.near, self.far)
     self.projectionMatrix = mat4(
         ListFunctions.flattenListOfLists(
             glGetDoublev( GL_PROJECTION_MATRIX ))
         ).transpose()
     glPopMatrix()
     glMatrixMode(GL_MODELVIEW)
     return self.projectionMatrix
Пример #8
0
 def makeVertexBuffer(self):
     self.vertexbuffer = VertexBuffer.MakeStandardVertexBuffer(
         vertices=[vec3(*x) for x in self.vertices_gl],
         normals=[vec3(*x) for x in self.normals_gl],
         tex_coords=ListFunctions.flattenListOfLists(self.texcoord_gl))
     self.indexbuffer = VertexBuffer.IndexBufferObject(self.indices_gl)