In the fork lift demo from the SDK, the slider constraint for the fork is set up like this:
Code: Select all
btTransform localA;
btTransform localB;
[...]
localA.setIdentity();
localB.setIdentity();
localA.getBasis().setEulerZYX(0, 0, M_PI_2);
localA.setOrigin(btVector3(0.0f, -1.9f, 0.05f));
localB.getBasis().setEulerZYX(0, 0, M_PI_2);
localB.setOrigin(btVector3(0.0, 0.0, -0.1));
m_forkSlider = new btSliderConstraint(*m_liftBody, *m_forkBody, localA, localB, true);
m_forkSlider->setLowerLinLimit(0.1f);
m_forkSlider->setUpperLinLimit(0.1f);
m_forkSlider->setLowerAngLimit(0.0f);
m_forkSlider->setUpperAngLimit(0.0f);
m_dynamicsWorld->addConstraint(m_forkSlider, true);
The parameters to create a new slider constraint are:
btSliderConstraint (btRigidBody &rbA, btRigidBody &rbB, const btTransform &frameInA, const btTransform &frameInB, bool useLinearReferenceFrameA)
Code: Select all
localA.getBasis().setEulerZYX(0, 0, M_PI_2);
[...]
localB.getBasis().setEulerZYX(0, 0, M_PI_2);
In this case the fork is moving upwards and downwards.
Changing it to (M_PI_2, 0, 0) allows it to move left / right, and with (0, M_PI_2, 0) it's forward / backward.
M_PI_2 is a rotation of 90 degrees so that makes sense to me. Problem is, this only seems to work if the angles are aligned on an axis, meaning something like (M_PI_4, M_PI_2, 0) ends up doing the same as (0, M_PI_2, 0), which I don't really understand.
Could someone please enlighten me on how to actually use setEulerZYX, or how to set up the slider constraint for a specific (non-world-axis-aligned) axis?