Sign in to follow this  
562538332

Physx Cook TriangleMesh always get unexpected result

Recommended Posts

562538332    134
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?

Share this post


Link to post
Share on other sites
JohnnyCode    1046

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.)

Share this post


Link to post
Share on other sites
Alundra    2316

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" );
Edited by Alundra

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this