Code: Select all
int upIndex = 1;
bool useFloatDatam=true;
bool flipQuadEdges=bFlip;
btHeightfieldTerrainShape* pHeightShape =
new btHeightfieldTerrainShape(width, length, pHeightData, scale.y, upIndex, useFloatDatam, flipQuadEdges);
pHeightShape->setUseDiamondSubdivision(true);
mShape = pHeightShape;
btVector3 sc(scale.x, scale.y, scale.z);
mShape->setLocalScaling(sc);
Code: Select all
reVector3Df terrainShiftPos(page_size, 0.0, page_size);
terrainShiftPos *= terrainScale;
terrainShiftPos /= 2;
Code: Select all
mState = new ObjectState(this);
mRootNode = node;
mShapeNode = mRootNode->createChildSceneNode(mName + "Node");
mShapeNode->attachObject(this);
node->setPosition (pos);
node->setOrientation (quat);
mShape = shape;
showDebugShape(mWorld->getShowDebugShapes());
btRigidBody *body = new btRigidBody(0.0, mState, mShape->getBulletShape ());
body->setRestitution(bodyRestitution);
body->setFriction(bodyFriction);
body->getWorldTransform().setOrigin(btVector3(pos.x, pos.y, pos.z));
body->getWorldTransform().setRotation(btQuaternion(quat.x, quat.y, quat.z, quat.w));
mObject = body;
getDynamicsWorld()->addRigidBody(this, mCollisionGroup, mCollisionMask);
Right now the only thing that happens is my test object just falls through the terrain. If I change the position to:
Code: Select all
reVector3Df terrainShiftPos( (terrainScale.x * (page_size - 1) / 2), \
(terrainScale.y * terrainScale.y / 2), \
(terrainScale.z * (page_size - 1) / 2));
Any ideas?