I wrote a small test program that made an animated windmill: The tower was a simple static shape, and the blade was a dynamic shape, constrained to the top of the tower with a hinge. I tested the various ways to define the blade (in it's local coords), and transforming that to align with the tower's pivot point. That wasn't too difficult, just had to figure it out.
Back to the sim... Right now there are no constraints, so as soon as the sim is unpaused all the dynamic objects fall to the ground as expected. One of these objects is a heavy counter weight, which I need to constrain to the vertical axis. In my sim, the XY plane is the ground plane, and +Z is up. So as I understand it, I should make a coord frame for the counter weight, with its +X axis aligned to the world's +Z. Here's how I'm doing it:
Code: Select all
// CW to world via slider. (Rotate frame around Y(-90) to align X with world Z.)
btTransform frame;
frame.setIdentity();
frame.setRotation( btQuaternion( btVector3(0, 1, 0), -M_PI/2.0) );
btSliderConstraint *slider = new btSliderConstraint( *cw_body, frame, false);
m_world->addConstraint(slider);
As for the above code, is my alignment right? Is that how one constrains an object to the world with a slider with the coord system I'm using?
Any comments appreciated.