Trimesh is a nice feature for defining the geometry of a body in ODE. You just need a vertices and a faces array. Md3 files encode the faces in CCW and ODE (and OpenGL too) does it in CW. So you need to make the transformation, thus creating a new array of dVector3 (you must do this to unpack the fixed md3 format vertex info).
Here is a llitle piece of code that resumes the proccess: ( GetModel() returns a libmd3_file* )
libmd3_mesh* meshp; meshp = GetModel()->meshes; int* tri; dVector3* triVert; tri = (int*) malloc (meshp->mesh_header->triangle_count*sizeof(int)); triVert = (dVector3*) malloc (meshp->mesh_header->vertex_count*sizeof(dVector3)); std::cout << meshp->mesh_header->triangle_count << std::endl; std::cout << meshp->mesh_header->vertex_count << std::endl; std::cout << "Faces: "; for (int i=0;i < meshp->mesh_header->triangle_count*3; i+=3){ tri[i+0]=meshp->triangles[i+1]; tri[i+1]=meshp->triangles[i+2]; tri[i+2]=meshp->triangles[i+0]; std::cout << tri[i] << " "; std::cout << tri[i+1] << " "; std::cout << tri[i+2] << " - "; } std::cout << " Verts: "; for (int i=0;i < meshp->mesh_header->vertex_count; i++){ triVert[i][0]=meshp->vertices[i*3]*scaleFactor; triVert[i][1]=meshp->vertices[i*3+1]*scaleFactor; triVert[i][2]=meshp->vertices[i*3+2]*scaleFactor; std::cout << "(" << triVert[i][0] << " "; std::cout << triVert[i][1] << " "; std::cout << triVert[i][2] << ") - "; } mtriMesh = dGeomTriMeshDataCreate(); dGeomTriMeshDataBuildSimple(mtriMesh, (dReal*)triVert, meshp->mesh_header->vertex_count, tri, \ meshp->mesh_header->triangle_count); mOdeGeom = dCreateTriMesh(sSpace, mtriMesh, NULL, NULL, NULL); dGeomSetData(mOdeGeom, (void*)"md3");
Entries (RSS)