Problem with negative terrain values

tod

18-08-2011 19:55:19

OgreNewt does not work with negative terrain values on up axis. This is not a fault of OgreNewt itself but instead a fault of the fact that newton uses "unsigned short" for height data.
How do you know you have this problem? The lower parts of your terrain stick up to the sky!
What you need to do is this:
elevations = unsigned short((*(hData)-terrain->getMinHeight())*verticleScale);

This ensures that no negative floats get converted to very high unsigned integer values.
Then when creating your terrain don't forget to adjust it's position on Y axis (also X and Z because the coordinates of ogre terrain and newton height field are different)
terrainBody->setPositionOrientation(terrain->getPosition() - Vector3(mPageSize/2,-terrain->getMinHeight(),mPageSize/2) ,Quaternion::IDENTITY);

If no one is maintaining this is there any possibility I could be allowed to commit some patches myself?

Lax

29-10-2011 19:55:37

ah thanks for the code. I had the same problem.