Create btIndexMesh from WavefronObj

Post Reply
Posts: 1
Joined: Sun Nov 08, 2020 2:42 pm

Create btIndexMesh from WavefronObj

Post by arsakes »


I try to set fields in `btIndexMesh` in order to use geometry that I've read from OBJ file using `tinyObjLoader` lib.
I'm creating the btIndexMesh in a following way.

Code: Select all

	btIndexedMesh indexed_mesh = btIndexedMesh();
        indexed_mesh.m_numTriangles = vertex_count / 3;              
        indexed_mesh.m_triangleIndexBase = (const unsigned char*) &shapes[s].mesh.indices[0].vertex_index;                                                                    
        indexed_mesh.m_triangleIndexStride = 3 * sizeof(tinyobj::index_t);    
        indexed_mesh.m_numVertices = vertex_count;    
        indexed_mesh.m_vertexBase = (const unsigned char*) &(attrib.vertices[0]);    
        indexed_mesh.m_vertexStride = 3 * sizeof(float);                         

As for atrrib and mesh.indices goes:
  • shapes[0].mesh.indices is of type std::vector<tinyobj::index_t> and contains indices of vertices that form triangles (a map from to attrib).
  • attrib.vertices is of type std::vector<float>) and contains all the coordintes of vertices
They are a result of executing `tinyobj::LoadObj` on the *.obj

Here you have the code of the OBJ loader (it's also used in bullet examples). ... j_loader.h

So, the code doesn't seem to be right, because I get differnt mesh than using using btTriangleMesh class.
Can some tell me what I'm doing wrong?
Post Reply