Kukanani
17-05-2010 19:45:09
Looking at the OgreBullet code I get the impression that OgreBullet still uses the old TerrainSceneManager for creating terrains. Are there plans to update this to the new v1.7 terrain? I have some code that I'm trying out for this sort of thing:
(the above code is not OgreBullet). Should this work?
int ogreHeightDataSize = 512; //<<<<512 should be replaced with the terrainSize (NOT worldSize) of your terrain.
float* heights = new float[ogreHeightDataSize*ogreHeightDataSize];
for(int i = 0; i < ogreHeightDataSize; i++)
{
for(int j = 0; j < ogreHeightDataSize; j++)
{
heights[i + (j * ogreHeightDataSize)] = terrain->getHeightAtWorldPosition((float)i*(terrain->getWorldSize()/ogreHeightDataSize)-terrain->getWorldSize()/2.f, 100.f, (float)j*(terrain->getWorldSize()/ogreHeightDataSize)-terrain->getWorldSize()/2.f);
}
}
btHeightfieldTerrainShape* heightfieldShape = new btHeightfieldTerrainShape(ogreHeightDataSize, ogreHeightDataSize, heights, 1, 0, 20, 1, PHY_FLOAT, false);
heightfieldShape->setLocalScaling(btVector3(1000.f/ogreHeightDataSize, 1, 1000.f/ogreHeightDataSize));
btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(btMatrix3x3().getIdentity(), btVector3(0.f, 0.f, 0.f)));
btRigidBody* body = new btRigidBody(0.f, motionState, heightfieldShape, localInertia);
//add the body to the dynamics world
dynamicsWorld->addRigidBody(body);(the above code is not OgreBullet). Should this work?