I'm new to BulletPhysics and I have the problem that my objects (spaceships) are "falling down" when my simulation starts. I set the gravity of my DynamicWorld to zero and I don't apply it anywhere. Also there are no forces in my world. It seems to be totally irrelevant to which value I set the gravity of the world - the objects are always falling in the same direction (positive y-direction). Here's some code:
The init-method
Code: Select all
[...]
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btBroadphaseInterface* broadphase = new btDbvtBroadphase();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btConstraintSolver *solver = new btSequentialImpulseConstraintSolver();
mDynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
mDynamicsWorld->setGravity(btVector3(0,0,0));
btRigidBody::btRigidBodyConstructionInfo info(
mass(), // > zero
mMotionState = new Scene::InterObjectMotionState(),
new btBoxShape(btVector3(400, 80, 90)),
btVector3(position().x, position().y, position().z)
);
mRigidBody = new btRigidBody(info);
mDynamicsWorld->addRigidBody(mRigidBody);
[...]
Code: Select all
[...]
// timer contains time since last tick
mDynamicsWorld->stepSimulation(mTimer->getMilliseconds() / 1000.0f, 1);
mTimer->reset();
[...]
Code: Select all
InterObjectMotionState::InterObjectMotionState(void)
{
}
InterObjectMotionState::~InterObjectMotionState(void)
{
}
void InterObjectMotionState::getWorldTransform(btTransform &worldTrans) const
{
//worldTrans = mTransform;
}
void InterObjectMotionState::setWorldTransform(const btTransform &worldTrans)
{
if(mSceneNode)
{
btVector3 const & pos = worldTrans.getOrigin();
mSceneNode->setPosition(pos.x(), pos.y(), pos.z());
std::cout << "\ny: " << worldTrans.getOrigin().y(); // y always gets larger, but why?
}
}
I really hope you can help me. I tried a lot, I looked at the demo's code, in the wiki-tutorials, the manual and the API but it seems, that i'm too stupid to find the answer there
TIA,
Boron