Animation-driven rotations
Mark Williams <[email protected]> Thu, 25 Oct 2007 18:35:03 -0700
| Newsgroups | gmane.comp.lib.ode |
|---|---|
| Message-ID | <[email protected]> |
Hi all, I know the topic of 'animation import' has come up a number of times, but I've been through the mailing list history and as far as I can tell the subject of how to get external animated rotation data onto rigid bodies hasn't been discussed. What I'm trying to do should be quite straight forward. I have the rotation of the rigid body, bodyQuaternion, at the current time. I have a target rotation, targetQuaternion, which I'd like to rotate the body to within a single time step. So what I have so far is: rotationErrorQuaternion = bodyQuaternion.inverse() * targetQuaternion rotationError = rotationErrorQuaternion.asEuler() angularVelocity = rotationError / timeStep body.setAngularVel ( angularVelocity ) Which seems to work fine in a number of cases, but on occassion it can lead to what I can only describe as 'chaotic' behavior, with the body spinning out of control rapidly. Can anybody see anything wrong with what I'm doing? Should I be using an AMotor instead, with an infinite FMax? If so, briefly how should I go about setting up the angles on the motor? I had the exact same problems with applying torques rather than setting angular velocities directly so I think I'm neglecting something quite fundamental here. Could anybody offer any advice, please? Thanks in advance, Mark