NewtonHeightFieldCollision's problem

devilatmay

29-06-2011 03:39:31

hello everyone, i have spent days to solve this problem,but i still get no ideas about it.So, can anyone help me?
I built my program with octreeSceneManager,and added terrain, just like tutorial 3 did.Then, I found original OgreNewt can not support terrain collision directly,I serached this page http://www.ogre3d.org/addonforums/viewtopic.php?f=4&t=11696
I was encouraged by that totally! But,when I modified my lib and code,it run without a correct behaviour.A rigidbody can collide terrain just once!!!,And then it was falling through my terrain!!
how can I do next ? Thanks for your help!
code Like this

………
………
if (mTerrainsImported)
{
Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
while(ti.hasMoreElements())
{
Ogre::Terrain* t = ti.getNext()->instance;
initBlendMaps(t);
//code about OgreNewt
OgreNewt::CollisionPtr mapcol = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::HeightField(_world, t, 200));
OgreNewt::Body* bod = new OgreNewt::Body(_world, mapcol );
}
}
……
……

devilatmay

30-06-2011 08:45:20

sorry about that,I got the answer
it caused by the difference of the coordinate between OgreNewt and Ogre's Terrain system.
when I set the mTerrainGroup's origin, every thing just works fine.
like this,mTerrainGroup->setOrigin(Ogre::Vector3(terrainsize/2,0,terrainsize/2));
thanks for this place!