StaticMeshToShapeConverter and submeshes

Samapico

15-08-2013 15:40:44

I'm using something like this:
OgreBulletCollisions::StaticMeshToShapeConverter smtsc(someEntity, transform);

OgreBulletCollisions::CollisionShape* newShape = smtsc.createTrimesh();
Q_ASSERT(newShape);


It seems that the StaticMeshToShapeConverter combines all the submeshes into a single one. The problem arises later when I launch rays at my object. I get the index of the submesh it hits, and I want to use this to go through the mesh's vertex data and pull out some information like the texture coordinates and the vertex normals. I have to get this data from OGRE directly, so the mesh in OGRE still has multiple submeshes, while the shape in bullet is merged into a single object, so the indices I get from bullet can't be used to get the info from the mesh in OGRE.

I'm guessing there are two ways to go about this:
1) Is it possible to have the StaticMeshToShapeConverter preserve the submeshes in the shape? Does bullet even support sub-shapes? I see how I could create multiple shapes by creating a trimesh for each submesh's vertexdata, but is there any way to keep some kind of relationship between those shapes afterwards?

2) How hard / efficient would it be to transform my mesh and merge all the submeshes in it? It would have to be done dynamically while / after I load the mesh, because I have to support .mesh files on which I have no control. So just converting the .mesh file wouldn't work for me.


Thanks

AlexeyKnyshev

15-08-2013 20:56:26

Could you use Ogre scene ray query instead of Bullet's? Please, explain what exactly (in few words) you want to implement.

Samapico

17-08-2013 06:02:59

I'm using bullet to get the exact coordinate of my mesh for a given projection... i.e. a raycast. AFAIK the scene query can only give the object and not much else...
However, bullet doesn't keep the vertex normals of the mesh, and the standard raycast only returns the normal of the face. So I need to get that from the mesh.

But emm... I think I figured out a way to fix my problem. Basically I pre-process my mesh and combine the normals/positions/indices of all the submeshes into single arrays, and use that pre-processed data later. The indices then fit with what bullet gives me... This also avoids having to search through the vertex buffer thingy everytime, which requires a lock, which means I can't access it from multiple thread, which would slow me down a lot in my application.