I was trying to make a joint using generic6dof constraint between two dynamic bodies, but cant get it done.
All axes seem to be locked. I have tried many combinations with SetLimit but none of them worked. Both bodies seem to be joined together.
Three cases possible:
- Lowerlimit == Upperlimit -> the axis is locked.
- Lowerlimit > Upperlimit -> the axis is free
- Lowerlimit < Upperlimit -> the axis it limited in that range
Translation along the axis x : localA.setIdentity(); localB.setIdentity();
localA.setOrigin(btVector3(btScalar(0.), btScalar(0), btScalar(0.)));
localB.setOrigin(btVector3(btScalar(0.), btScalar(0.), btScalar(0.)));
slider = new btGeneric6DofConstraint(*m_bodies[Body1], *m_bodies[Body2], localA, localB, true);
//Specify the limit of translation of the two rigidbodies
btVector3 lowerSliderLimit = btVector3(0.,-0.4,0.);
btVector3 hiSliderLimit = btVector3(0.,0.3,0.);
/*
Three cases possible:
- Lowerlimit == Upperlimit -> axis is locked.
- Lowerlimit > Upperlimit -> axis is free
- Lowerlimit < Upperlimit -> axis it limited in that range
*/
slider->setLinearLowerLimit(lowerSliderLimit1);
slider->setLinearUpperLimit(hiSliderLimit1);
//Course of Slider = hiSliderLimit-lowerSliderLimit
slider->setAngularLowerLimit(btVector3(0,0,0));
slider->setAngularUpperLimit(btVector3(0,0,0));
m_joints[JOINT] = slider;
m_ownerWorld->addConstraint(m_joints[JOINT], true);
To understand better try to see the Demo Ragdoll in BULLET and try to change the settings and see what happen.