Loading a DirectX (left-handed) model with Assimp into Open Dynamics Engine

Started by
1 comment, last by MidLevelGameDev 3 years, 8 months ago

I've been trying to load a DirectX model into an ODE triangle mesh using Assimp. Here is the relevant code:

const C_STRUCT aiScene *scene = aiImportFile(filepath, aiProcess_Triangulate | aiProcess_OptimizeMeshes | aiProcess_OptimizeGraph | aiProcess_SortByPType | aiProcess_ConvertToLeftHanded);

C_STRUCT aiMesh *mesh = scene->mMeshes[0];

C_STRUCT aiVector3D *vertices = malloc(sizeof(C_STRUCT aiVector3D) * mesh->mNumVertices);
memcpy(vertices, mesh->mVertices, sizeof(C_STRUCT aiVector3D) * mesh->mNumVertices);

int *indices = malloc(sizeof(int) * (mesh->mNumFaces * 3));
for(int i = 0; i < mesh->mNumFaces; i++) {
	indices[i * 3 + 0] = mesh->mFaces[i].mIndices[0];
	indices[i * 3 + 1] = mesh->mFaces[i].mIndices[1];
	indices[i * 3 + 2] = mesh->mFaces[i].mIndices[2];
}

dTriMeshDataID id = dGeomTriMeshDataCreate();
dGeomTriMeshDataBuildSingle(id, vertices, sizeof(C_STRUCT aiVector3D), mesh->mNumVertices, indices, mesh->mNumFaces * 3, sizeof(int) * 3);

No matter what I try to change up, a different sphere body just seems fall through, touching random spots. It seems that there's a triangle soup in the physics engine, but I can't figure out where the problem is.

Please tell if I had forgotten to mention something else important. Thanks.

Advertisement

Bump, I'm still having the issue :|.

This topic is closed to new replies.

Advertisement