I have a none flat terrain as a triangle mesh( vertex & index buffer) . how to define physics to it using PhysX
I am trying to find out how they did it in their Sample bridge
P.S I am not using Game engines.
I am fiddling with the code but I have no clue about what am I suppose to do
I have mesh created with DirectX so i copied the mesh Vertex and index buffer for physics
I made PxTriangleMeshDesc
physx::PxTriangleMeshDesc meshDesc;
meshDesc.points.count = nVerts;
meshDesc.points.stride = sizeof(DirectX::XMFLOAT3);//I decided not to convert it for now and see how it goes
meshDesc.points.data = verts.data(); //this is unique vertices
meshDesc.triangles.count = nIndices;// each 3 indices are triangle
meshDesc.triangles.data = indexBuffer.data();
meshDesc.triangles.stride = sizeof(uint32_t);
then I cooked it or whatever using cookTriangleMesh
then I created triangle mesh PxTriangleMesh, then PxTriangleMeshGeometry then i made PxRigidStatic then i created exclusive shape then added the rigid actor to the scene and saved the actor
now I am lost, I have no idea the following code does, I can guess that it creates a mesh for render, but I already have rendered mesh so should I ignore it
PxShape* shape;
actor->getShapes(&shape, 1);
RenderMeshActor* meshActor = createRenderMeshFromRawMesh(data, shape);
link(meshActor, shape, actor);
meshActor->setEnableCameraCull(true);
but then what is linking
void PhysXSample::link(RenderBaseActor* renderActor, PxShape* shape, PxRigidActor* actor)
{
PhysXShape theShape(actor, shape);
mPhysXShapeToRenderActorMap[theShape] = renderActor;
renderActor->setPhysicsShape(shape, actor);
}