[solved] bullet with ogre1.7 terrain problem

plan
Posts: 7
Joined: Sun Oct 10, 2010 8:49 am

[solved] bullet with ogre1.7 terrain problem

Post by plan »

hi, there!

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);
}
when run, the debugDrawer is a little under the terrain, and some object will fall through the terrain.

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!
Last edited by plan on Thu Oct 21, 2010 11:58 pm, edited 1 time in total.
plan
Posts: 7
Joined: Sun Oct 10, 2010 8:49 am

Re: [solved]bullet with ogre1.7 terrain problem

Post by plan »

yes, below url give the solution,
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=58756

a little changed, use the similar funtion of ogre::terrain, you will make it run with the ogre1.7 terrain, like in ogitor.