I'm trying to create a terrain with it. Here is my code:
Code: Select all
unsigned char heightfield[16]={
0,3,6,9,
0,3,6,9,
0,3,6,9,
0,3,6,9
};
....
btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, -1, 0)));
auto groundShape = new btHeightfieldTerrainShape(4, 4, heightfield, 9, 1, false, false);
btVector3 inertia(0, 0, 0);
int mass = 0;
btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(mass, groundMotionState, groundShape, inertia);
auto groundRigidBody = new btRigidBody(groundRigidBodyCI);
m_dynamicsWorld->addRigidBody(groundRigidBody);
m_shapes.push_back(std::unique_ptr<btCollisionShape>(groundShape));
m_rigidBodies.push_back(std::unique_ptr<btRigidBody>(groundRigidBody));
states.push_back(std::unique_ptr<btMotionState>(groundMotionState));