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,
can anyone help this? tks!
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!