how to use ogre1.7 terrain in ogrebullet

planB

10-10-2010 03:12:47

hi, thereļ¼

the terrain_demo uses the terrain.cfg and setWorldGeometry() method to show the terrain, this seems out in the ogre1.7.

so how to use the ogre1.7 terrain in the OB?
for example, i create a Ogre::Terrain or get the Ogre::Terrain from the ogitor dotscene, how can i use it?

i use below code, but it does not work,


void test_bullet::createBulletTerrain( Ogre::Terrain *mterrain )
{
unsigned page_size = mterrain->getSize();

Ogre::Vector3 terrainScale( mterrain->getWorldSize()/(page_size-1), mterrain->getMaxHeight(),mterrain->getWorldSize()/(page_size-1));

float *heights = new float [page_size*page_size];

for(unsigned y = 0; y < page_size; ++y)
{
for(unsigned x = 0; x < page_size; ++x)
{
heights[x + y * page_size] = *mterrain->getHeightData(x,y) ;
}
}

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);
}


can anyone help this? tks!

planB

15-10-2010 13:44:37

solved this,

viewtopic.php?f=2&t=58756&p=402559&hilit=bullet+terrain#p402559

but if use in ogrebullet, the souce should changed, should add another constructor funtion in ogrebullet heightfieldshape(correspond to the bullet constructor function in btheightfieldshap)

Fish

15-10-2010 17:08:49

I think the link should be: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=58756

- Fish