HeightmapCollision questions

JohnBoyManbullet

25-10-2011 04:58:52

Hello. I am trying to use the mTerrainShape = new OgreBulletCollisions::HeightmapCollisionShape(page_size, page_size, terrainScale, heights, true);

the problem is it will not work if i do this.



OgreBulletCollisions::HeightmapCollisionShape* mTerrainShape = new OgreBulletCollisions::HeightmapCollisionShape(page_size, page_size, terrainScale, heights, true);



I have used using namespace OgreBulletCollisions;
and linked OgreBullet collisions libs.
The problem is no matter what i do, HeightmapCollisionShape will underline in red and say that the namespace is an incomplete type. I think there might be something wrong with the lib file.

JohnBoyManbullet

25-10-2011 11:10:30

Actually i figured that out .thaniks

azer89

28-10-2011 08:37:30

Hi i got a problem, i'm using new Ogre Terrain System and.. it doesn't work well with OgreBullet Wrapper :(



as you can see on the image above i have problem with height scaling, i can't get the exact scale of my terrain height

here's my code:


Ogre::Terrain* pTerrain = mTerrainGroup->getTerrain(0, 0);
float * hData = pTerrain->getHeightData();
Vector3 pos = pTerrain->getPosition();

float *pDataConvert = new float[pTerrain->getSize() *pTerrain->getSize()];
for (int i = 0; i < pTerrain->getSize(); i++)
memcpy(pDataConvert + pTerrain->getSize() * i,
hData + pTerrain->getSize() * (pTerrain->getSize() - i - 1),
sizeof(float) * (pTerrain->getSize()));

float w = pTerrain->getSize();
float h = pTerrain->getSize();

float* data = pDataConvert;
float minH = pTerrain->getMinHeight();
float maxH = pTerrain->getMaxHeight();
float scale = pTerrain->getWorldSize() / (pTerrain->getSize() - 1);
float heightScale = (maxH - minH) / 2.0f;

Vector3 localScaling = Vector3(scale, heightScale, scale);

mTerrainShape = new HeightmapCollisionShape (
w,
h,
localScaling,
pDataConvert,
true);

RigidBody *defaultTerrainBody = new RigidBody(
"TerrainABC",
mBulletWorld);

const float terrainBodyRestitution = 0.1f;
const float terrainBodyFriction = 0.8f;

Ogre::SceneNode* pTerrainNode = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
defaultTerrainBody->setStaticShape (pTerrainNode, mTerrainShape, terrainBodyRestitution, terrainBodyFriction, Vector3.ZERO);

mBodies.push_back(defaultTerrainBody);
mShapes.push_back(mTerrainShape);