i'm using ogrebullet with ogre1.7, and i met some problem about ogrebullet+ogre1.7 terrain.
i create a ogre::terrain( or get a ogre::terrain from ogitor), and then want to create a btHeightfieldTerrainShape,
Code: Select all
void test_bullet::createTerrain( Ogre::Terrain *mterrain )
{
unsigned page_size = mterrain->getSize();
Ogre::Vector3 terrainScale( mterrain->getWorldSize()/(page_size-1), 1, mterrain->getWorldSize()/(page_size-1));
float *heights = new float [page_size*page_size];
float *terrainHeightData =mterrain->getHeightData() ;
for(int i=0;i<page_size;i++)
{
memcpy( heights+page_size * i,terrainHeightData + page_size * (page_size-i-1), sizeof(float)*(page_size));
}
OgreBulletCollisions::HeightmapCollisionShape *mTerrainShape = new HeightmapCollisionShape (page_size, page_size, terrainScale, heights, true);
RigidBody *defaultTerrainBody = new RigidBody("Terrain", mWorld);
const float terrainBodyRestitution = 0.1f;
const float terrainBodyFriction = 0.8f;
Ogre::SceneNode* pTerrainNode = mSceneMgr->getRootSceneNode ()->createChildSceneNode ("ter",mterrain->getPosition());
defaultTerrainBody->setStaticShape (pTerrainNode, mTerrainShape, terrainBodyRestitution, terrainBodyFriction, mterrain->getPosition());
mBodies.push_back(defaultTerrainBody);
mShapes.push_back(mTerrainShape);
}
may be use bullet directly will met the same proplem,
http://www.ogre3d.org/forums/viewtopic. ... in#p395171
anyone know about this? tks very much!