I'm on a project for uni about making a simple 3d game with our own engine and using Physx. Right now i succeeded to create a 3D terrain from a heighmap and cooking it so I could have a collider on it.
You can see on the following image what it looks like, but i have a problem. I can actually go through when on this side of the terrain
But when im on this side (so under):
I cant because collisions are good. Now i would like to have it in reverse, i'd like to have collisions on the top of the terrain not from under.
Here is my code :
meshDesc.points.count = static_cast<PxU32>(vertexes.size());
meshDesc.points.data = vertices;
meshDesc.points.stride = sizeof(PxVec3);
meshDesc.triangles.count = static_cast<PxU32>(faces.size())/3;
meshDesc.triangles.data = indices;
meshDesc.triangles.stride = 3 * sizeof(PxU32);
PxTolerancesScale scale1;
PxCookingParams params(scale1);
// disable mesh cleaning - perform mesh validation on development configurations
params.meshPreprocessParams |= PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH;
// disable edge precompute, edges are set for each triangle, slows contact generation
params.meshPreprocessParams |= PxMeshPreprocessingFlag::eDISABLE_ACTIVE_EDGES_PRECOMPUTE;
// lower hierarchy for internal mesh
params.midphaseDesc.mBVH33Desc.meshCookingHint = PxMeshCookingHint::eCOOKING_PERFORMANCE;
PhysXManager::get().getPxCooking()->setParams(params);
PxTriangleMesh* triMesh = NULL;
triMesh = PhysXManager::get().getPxCooking()->createTriangleMesh(meshDesc,
PhysXManager::get().getgPhysx()->getPhysicsInsertionCallback());
PxMeshScale geomScale = PxMeshScale((PxVec3(scale)));
PxTriangleMeshGeometry geom = physx::PxTriangleMeshGeometry(triMesh, geomScale);
body = PhysXManager::get().createTerrain(PxTransform(pos), geom,scene);
And in the createTerrain() :
PxRigidStatic* PhysXManager::createTerrain(const PxTransform& t, PxTriangleMeshGeometry& geom, int scene) {
PxShape* shape = PhysXManager::get().getgPhysx()->createShape(geom, *gMaterial, true);
shape->setName("Terrain");
PxRigidStatic* body = gPhysics->createRigidStatic(t);
body->attachShape(*shape);
addToScene(body, scene);
return body;
}
Can you help me figure out how to do that please ?
Thanks !