Accessing ShapeBase Class Collision Meshes
by John Kanalakis · in Torque Game Engine Advanced · 11/02/2006 (11:03 am) · 0 replies
I have a number of ShapeBase derrived objects within a scene that have one or more collision meshes and I need to get the list of verts for each collision mesh. I put together the following code but am having mixed results. Sometimes all collision meshes are found and sometimes one is left out. All shapes were were modeled and exported consistently from 3ds Max 8 using the latest exporter. I can't seem to find a pattern in the results but for the most part there often seems to be 1 collision mesh left out. Below is a trimmed version of the code and some sample output.
The question is... why does this code not return a list of all the collision meshes for a shape?
Here's a sample of the results...
The question is... why does this code not return a list of all the collision meshes for a shape?
void MyShapeBaseClass::Test()
{
TSShape* shapeDetail = mDataBlock->shape;
TSMesh* meshDetails = NULL;
char* meshName;
//find all of the collision meshes within this shape
for( int t = 0; t < shapeDetail->meshes.size(); t++ )
{
meshDetails = shapeDetail->meshes[t];
meshName = (char*)shapeDetail->names[t];
Con::printf("+++ Found Mesh Named: %s", meshNames[t]);
if( meshDetails )
{
//check to see if this is a collision mesh
if( meshDetails && dStrstr((const char*)dStrlwr(meshNames[t]), "collision-"))
{
Con::printf("+++ Found collision mesh, now adding: %s", meshNames[t]);
//
//code to add the collision mesh verts...
//
}
}
}
return;
}Here's a sample of the results...
[b]Sampe Result: Working with 1 Collision Mesh[/b] ---------------------------------- +++ Found Mesh Named: detail2 +++ Found Mesh Named: collision-1 +++ Found collision mesh, now adding: collision-1 +++ Found Mesh Named: col-1 ---------------------------------- [b]Sampe Result: Working with 1 Collision Mesh 8 collision meshes[/b] ---------------------------------- +++ Found Mesh Named: detail2 +++ Found Mesh Named: collision-1 +++ Found collision mesh, now adding: collision-1 +++ Found Mesh Named: collision-2 +++ Found collision mesh, now adding: collision-2 +++ Found Mesh Named: collision-3 +++ Found collision mesh, now adding: collision-3 +++ Found Mesh Named: collision-4 +++ Found collision mesh, now adding: collision-4 +++ Found Mesh Named: collision-5 +++ Found collision mesh, now adding: collision-5 +++ Found Mesh Named: collision-6 +++ Found collision mesh, now adding: collision-6 +++ Found Mesh Named: collision-7 +++ Found collision mesh, now adding: collision-7 +++ Found Mesh Named: collision-8 +++ Found collision mesh, now adding: collision-8 +++ Found Mesh Named: col-1 ---------------------------------- [b]Sampe Result: Failed to add collision-1 mesh[/b] ---------------------------------- +++ Found Mesh Named: detail2 +++ Found Mesh Named: collision-1 +++ Found Mesh Named: collision-2 +++ Found collision mesh, now adding: collision-2 +++ Found Mesh Named: collision-3 +++ Found collision mesh, now adding: collision-3 +++ Found Mesh Named: collision-4 +++ Found collision mesh, now adding: collision-4 +++ Found Mesh Named: col-1 [b]Sampe Result: Failed to add collision-1 mesh[/b] ---------------------------------- +++ Found Mesh Named: detail2 +++ Found Mesh Named: collision-1 +++ Found Mesh Named: collision-2 +++ Found collision mesh, now adding: collision-2 +++ Found Mesh Named: col-1
About the author
John Kanalakis is the owner of EnvyGames, an independent game development studio in Silicon Valley that produces games and tools for Xbox 360, Windows, and the Web.