I'm creating wrapper for working with Ogre+Bullet for iOS platform.
I created 2 objects:
- dynamic:
Code: Select all
btVector3 inertia;
shape->calculateLocalInertia(_mass, inertia);
MyMotionState *motionState = new MyMotionState(_node.node);
body = new btRigidBody(_mass, motionState, shape, inertia);
body->setUserPointer((__bridge void *)_node);
_world.world->addRigidBody(body);
Code: Select all
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshPtr planePtr = Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity *entGround = mSceneMgr.mSceneMgr->createEntity("GroundEntity", "ground");
Ogre::SceneNode *groundNode = mSceneMgr.mSceneMgr->getRootSceneNode()->createChildSceneNode("groundNode");
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0, -800, 0));
btScalar groundMass(0.); //the mass is 0, because the ground is immovable (static)
btVector3 localGroundInertia(0, 0, 0);
btCollisionShape *groundShape = new btBoxShape(btVector3(btScalar(1400.), btScalar(50.), btScalar(1000.)));
btDefaultMotionState *groundMotionState = new btDefaultMotionState(groundTransform);
groundShape->calculateLocalInertia(groundMass, localGroundInertia);
btRigidBody::btRigidBodyConstructionInfo groundRBInfo(groundMass, groundMotionState, groundShape, localGroundInertia);
btRigidBody *groundBody = new btRigidBody(groundRBInfo);
mWorld.world->addRigidBody(groundBody);
Please, have a look video: http://moevideo.net/video/97940.94cc239 ... 05f0982431
I had to set gravity vector to (0, -300, 0), then object is falling ok. But I don't like this decision. Maybe size of my objects are wrong and so on.
Please, help. Thanks