Physx Cook TriangleMesh always get unexpected result

Started by
1 comment, last by Alundra 8 years, 5 months ago
The problem is this:
I have a rendering vertex set which will get a right result for rendering. But when i try to use Physx to Cook those vertices into a PxTriangleMesh it will always get unexpected result.
I wonder if is those vertices are too tough for Physx to cook into a right result.
I have tried many way to solve it including merging duplicated vertices but little improvement got.

This is the Cooking Paramters i set:
PxCookingParams params(scale);
params.meshWeldTolerance = 0.00001f;
params.meshPreprocessParams = PxMeshPreprocessingFlags(PxMeshPreprocessingFlag::eWELD_VERTICES | PxMeshPreprocessingFlag::eREMOVE_UNREFERENCED_VERTICES | PxMeshPreprocessingFlag::eREMOVE_DUPLICATED_TRIANGLES);

Is this is a commond problem or i just forgot something to set?
How to solve this problem?
Advertisement

It is not clear wheather you use indicies on the mesh, if not, you will have to properly explain raw verticies interpretation, as I believe there are more possible (triangle array, triangle strip etc.)

Here what I use to cook a triangle mesh collider :


// Set the triangle mesh desc.
physx::PxTriangleMeshDesc MeshDesc;
MeshDesc.points.count     = MeshVertices.GetSize();
MeshDesc.points.stride    = sizeof( physx::PxVec3 );
MeshDesc.points.data      = &MeshVertices[ 0 ];
MeshDesc.triangles.count  = MeshIndices.GetSize() / 3;
MeshDesc.triangles.stride = 3 * sizeof( physx::PxU32 );
MeshDesc.triangles.data   = &MeshIndices[ 0 ];

// Cook the triangle mesh.
physx::PxDefaultMemoryOutputStream WriteBuffer;
if( CEngine::GetPhysicsSystem().GetCooking()->cookTriangleMesh( MeshDesc, WriteBuffer ) == false )
  CEngine::GetLogger().LogError( "cookTriangleMesh failed" );

This topic is closed to new replies.

Advertisement