I'm creating a btHingeConstraint using the version of the constructor that takes btTransform "frames", and it's working except for that the limits seem to be acting the opposite way round from how I expect them to.
e.g. If I create a static rb at (-2, 0, 0) and a dynamic rb at (2, 0, 0), constrain the dynamic to the static with a hinge at (0, 0, 0) (with zero rotation), and set the "low" and "high" limits to -10° and 50° respectively (converted to radians of course), the dynamic rb will fall to 50° below the horizontal - which seems upside-down to me?
The code I use to create the constraint is:
Code: Select all
btVector3 pivot; // constraint position in world space
btQuaternion rot; // constraint rotation in world space
btTransform ctWorldTransform;
ctWorldTransform.setIdentity();
ctWorldTransform.setOrigin(pivot);
ctWorldTransform.setRotation(rot);
btTransform transformInA = rb1->getCenterOfMassTransform().inverse() * ctWorldTransform;
btTransform transformInB = rb2->getCenterOfMassTransform().inverse() * ctWorldTransform;
btHingeConstraint* ct = new btHingeConstraint(*rb1, *rb2, transformInA, transformInB);
double min = -0.174533, max = 0.872665;
ct->setLimit(min, max);
Many thanks,
Kate
(N.B. The image maybe doesn't show it clearly, but I am using a right-handed co-ordinate system).