I am using the rendering engine Lightfeather. Using the tileload event in their large terrain, I am attempting to create a physics model of that tile (and all tiles). I then want to add it to a btTriangleIndexVertexArray using a btIndexedMesh. Here is the rather sloppy code so far:
Code: Select all
btIndexedMesh iMesh = btIndexedMesh();
res::CMesh* tileMesh = event.getMesh();; // Is the mesh of only the single tile?
res::CVertexBuffer* vertices = tileMesh->getVertexBuffer(); //05702c70
lf::u32 start = vertices->getStartVertex();
res::CIndexBuffer* indices = tileMesh->getIndexBuffer();
lf::u32 numIndex = indices->getIndexCount();
lf::u32 numVertex = vertices->getVertexCount();
iMesh.m_triangleIndexBase = (unsigned char*)indices->getPointer();
iMesh.m_vertexBase = (unsigned char*)vertices->getPointer(res::EVCT_POSITION, start);
iMesh.m_triangleIndexStride = 0*sizeof(int); // what should this value be?
iMesh.m_vertexStride = vertices->getVertexStride(); // is a value of 0 correct?
iMesh.m_numVertices = numVertex;
iMesh.m_numTriangles = tileMesh->getPolygonCount(); // Is this the same as number of triangles?
lf::u32 entrySize = vertices->getEntrySize();
triArray->addIndexedMesh(iMesh);After feeding in the triArray to make a btBvhTriangleMeshShape, the btBvhTriangleMeshShape serialization into "myTerrain.bullet" appears to go ok, however, not so much when trying to reload it.
While reloading the btBvhTriangleMeshShape, bullet gives the vertex stride 16 and the index stride 12 but I get an access violation.
Does this seem right? I would appreciate any help. Thank you.
Note: Lightfeather's buffers are non-interleaved which, I believe makes the index and vertex stride equal to zero.
However with the index stride and vertex stride at 0 (in Bullet's processAllTriangles) I noticed that the triangle being made reads only from the vertex base which never advances forward; resulting in all the triangles vertex's having the same values as the vertex base.....I have thousands of triangles all with vertexs whose only values are those at vertexbase. Will post more code later. Thanks.