I tried to introduce the “createBV34TriangleMesh” function in the “SnippetTriangleMeshCreate” example into SnippetHelloWorld, to create a random terrain data. I added the following statement at the end of the function:
TriangleMeshGeo.triangleMesh = triMesh;
PxShape* shape = gPhysics->createShape(TriangleMeshGeo, *gMaterial);
PxTransform localTm(0.0, 1.0, 0.0);
PxRigidDynamic* body = gPhysics->createRigidDynamic(localTm);
But I cannot see the random terrain in the window.
But when I loaded ConvexMesh, there was no such problem. Through the above code, ConvexMesh can display it in the window well.
What should I do to make TriangleMesh appear in the window with physical effects? Thanks in advance.
When I use the following code, create a static rigid body
PxTriangleMesh* mesh = createMeshGround();
PxRigidStatic* groundMesh = gPhysics->createRigidStatic(PxTransform(PxVec3(0, 1.0, 0)));
PxRigidActorExt::createExclusiveShape(*groundMesh, geom, *gMaterial);
When I changed PxRigidStatic to PxRigidDynamic, the dynamic rigid body could not collide with the ground, and passed directly through the ground and then sank.
The ground is established by the following methods:
PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0,1,0,0), *gMaterial);