I´m studing Bullet constraints and creating little demos in C/C++. When testing the btConeTwistConstraint, I ran in an usual situation.
First, see the code below, where I create a static body and a dynamic body, and then I join them in a constraint.
Code: Select all
//DYNAMIC BODY
bracoForma = new btBoxShape(btVector3(0.5, 0.5, 0.5));
motionStateBraco = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(5,5.5,0)));
btScalar massaBraco(0.5f);
btVector3 inerciaBraco(0,0,0);
bracoForma -> calculateLocalInertia(massaBraco, inerciaBraco);
bracoCorpo = new btRigidBody(massaBraco, motionStateBraco, bracoForma, inerciaBraco);
//STATIC BODY
antebracoForma = new btBoxShape(btVector3(0.5, 0.5, 0.5));
motionStateAntebraco = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,5.5,0)));
btScalar massaAntebraco(0.0f);
btVector3 inerciaAntebraco(0,0,0);
antebracoForma -> calculateLocalInertia(massaAntebraco, inerciaAntebraco);
antebracoCorpo = new btRigidBody(massaAntebraco, motionStateAntebraco, antebracoForma, inerciaAntebraco);
//ADDING TO THE WORLD
mundoDinamico -> addRigidBody(bracoCorpo);
mundoDinamico -> addRigidBody(antebracoCorpo);
//CONSTRAINT
btTransform transA, transB;
transA = btTransform::getIdentity();
transB = btTransform::getIdentity();
transA.setOrigin(btVector3(0,4.5,0));
transB.setOrigin(btVector3(0,0,0));
btConeTwistConstraint* artObjTwist = new btConeTwistConstraint(*bracoCorpo, *antebracoCorpo, transA, transB);
artObjTwist -> setLimit(pi/4, pi/4, 0);
//artObjTwist -> setLimit(pi/4, pi/4, 0, 0, 0.3f, 1); //Setting the softness to zero
mundoDinamico -> addConstraint(artObjTwist, true);
In face of this, I´m asking for your help for the following questions:
1) Why the joint point moves? Since it´s a special P2P constraint, this point shouldn´t be fixed?
2) What exactly the softness, biasFactor, and relaxationFactor means to the constraint?
Sorry if this is a newbee questions. Thanks for the help!