Bonjour,
J'ai récemment rencontré ce problème. Quand j'ajoute ma heightmap, le relief part vers le haut et les faces de collision sont en dessous. Pas très clair alors voici une image :

Je n'ai pas trouvé comment inversé , voici mon code :
/// Ajout du terrain à la scene.
ITexture *texture=driver->getTexture("media/terrain.png");
ITerrainSceneNode *terrain=smgr->addTerrainSceneNode(texture->getName(), 0 , -1, vector3df(0.0f, 0.0f, 0.0f), vector3df(0.0f, 0.0f, 0.0f), vector3df(1.0f, 1.0f, 1.0f));
terrain->setMaterialFlag(EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("media/terrain.png"));
terrain->setPosition(vector3df(0.0f, 0.0f, 0.0f));
terrain->setScale(vector3df(4.0f, 1.0f, 4.0f));
/// btHeightfieldTerrainShape.
vector3df scale=terrain->getScale();
aabbox3d<f32> box=terrain->getBoundingBox();
const vector3df size=box.getExtent()/scale;
f32 minHeight=((ITerrainSceneNode*)terrain)->getHeight(0, 0);
f32 maxHeight=minHeight;
int arraySize=texture->getSize().Height;
///f32 heightData[512*arraySize];
f32 heightData[512*arraySize];
const f32 stepWidthX=size.X/arraySize;
const f32 stepWidthZ=size.Z/arraySize;
u32 runVal=0;
vector3df minEdge=box.MinEdge/scale;
vector3df maxEdge=box.MaxEdge/scale;
//Récupération du min et du max de la hauteur du terrain
for(f32 z=minEdge.Z; z<maxEdge.Z; z+=stepWidthZ)
{
for(f32 x=minEdge.X; x<maxEdge.X; x+=stepWidthX)
{
const f32 curVal=((ITerrainSceneNode*)terrain)->getHeight(x, z);
heightData[runVal++]=curVal;
if(curVal>maxHeight){maxHeight=curVal;}
if(curVal<minHeight){minHeight=curVal;}
}
}
f32 *heightDataPtr=heightData;
// Collision Objects.
btCollisionShape *groundShape=new btHeightfieldTerrainShape(arraySize, arraySize, heightDataPtr, 1.f, minHeight, maxHeight, 1, PHY_FLOAT, false);
//btCollisionShape * groundShape = new btHeightfieldTerrainShape(512, 512, heightDataPtr, 1.f, minHeight, maxHeight, 1, PHY_FLOAT, true);
groundShape->setLocalScaling(btVector3(4.0f, 1.0f, 4.0f));
//btCollisionShape *sphereShape= new btSphereShape(10);
// Ground Motion State.
btTransform transform;
transform.setIdentity();
transform.setOrigin(btVector3(0.0f, 0.0f, 0.0f));
btDefaultMotionState *groundMotionState=new btDefaultMotionState(transform);
// Ground Rigid Body.
btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0, groundMotionState, groundShape, btVector3(0, 0, 0));
btRigidBody *groundRigidBody=new btRigidBody(groundRigidBodyCI);
groundRigidBody->setUserPointer((void *)terrain);
// Adding ground rigid body to the world.
World->addRigidBody(groundRigidBody);
Si vous avez une idée ... Merci pour vos réponses.