this is what I'm doing:
obj->num_i is the number of triangles
obj->i[] is the index array
obj->v[] is the vertex array
Code: Select all
int e=0;
obj->_btTriangleMesh = new btTriangleMesh();
int v1;
int v2;
int v3;
while(e!=obj->num_i)
{
v1= obj->i[e*3];
v2= obj->i[e*3+1];
v3= obj->i[e*3+2];
btVector3 vertex0(obj->v[3*v1], obj->v[3*v1+1], obj->v[3*v1+2]);
btVector3 vertex1(obj->v[3*v2], obj->v[3*v2+1], obj->v[3*v2+2]);
btVector3 vertex2(obj->v[3*v3], obj->v[3*v3+1], obj->v[3*v3+2]);
obj->_btTriangleMesh->addTriangle( vertex0, vertex1, vertex2, 1 );
++e;
}
_btCollisionShape = new btBvhTriangleMeshShape( obj->_btTriangleMesh, 1, 1 );
Thanks
