First of all, sorry if it's the wrong section.
I'm making a simple physics simulation with a door with a friend (educational & research purpose) and we're having problems because we're using btHingeConstraint to make it rotate the door when we apply a force to the rigid body but it just stays in the same position.
We've seen the Constraint demo of the bullet package the last week but we haven't got any results so we decided to post our doubts here.
This is how we setup the rigid body:
(m_CustomMotionState inherits from btMotionState)
Code: Select all
float mass = 10.0f;
btCollisionShape *pShape = new btBoxShape(btVector3(200,10,200));
btScalar mass(mass);
btVector3 localInertia(0,0,0);
CalculateInertia(mass, pShape, localInertia);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, m_CustomMotionState, pShape, localInertia);
btRigidBody *pRigidBody;
pRigidBody = new btRigidBody(rbInfo);
pRigidBody->setAngularFactor(1.0f);
float vecLinearFactor = 1.0f;
pRigidBody->setLinearFactor(btVector3(vecLinearFactor, vecLinearFactor, vecLinearFactor));
g_btWorld->addRigidBody(pRigidBody);
Code: Select all
pRigidBody->setActivationState(DISABLE_DEACTIVATION);
btVector3 pivot;
btScalar minLimit, maxLimit;
btScalar targetVelocity;
btVector3 axis;
pivot.setValue(0,0,200);
axis.setValue(0,0,1);
minLimit = 0.0f;
maxLimit = 3.1415f / 2.0f;
targetVelocity = -1.0f;
btHingeConstraint *g_hinge = new btHingeConstraint(*pRigidBody, pivot, axis);
g_hinge->enableAngularMotor(true, targetVelocity, 100.0);
g_hinge->setLimit(minLimit, maxLimit);
g_btWorld->addConstraint(g_hinge, true);
Code: Select all
g_hinge->setMotorTarget(3.1415f/2.0f, 0.001f);
Everything else is working just fine because we've balls colliding (btSphereShape) and they do collide even with the door (btBoxShape).
But still, we can't be able to rotate our door.
Any tip or help would be really appreciated.
Xavier.
PS: sorry about the messy code we'll write it again once we known what we did wrong.