My question: Can someone please help me with getting a motorized cone twist constraint to work?
I modified the ragdoll demo to show the problem I'm running into. If I motorize the left hip joint, and set the target orientation to identity, everything works fine. But if I set the rotation part of "localA" and "localB" (the transforms that locate the constraint with respect to the rigid bodies) with a matrix instead of with Euler angles, the ragdolls go unstable and disappear. (Of course, setting the rotation matrix directly is unnecessary for this demo, but in my actual production code I don't keep track of rotations using Euler angles, so I need to either set the rotation using a matrix or quaternion.)
Attached is my modified RagdollDemo.cpp, but here are the changes I made to the left hip:
Code: Select all
localA.setIdentity(); localB.setIdentity(); // Line 218 of RagdollDemo.cpp
// Here's where I set the rotation matrices manually...
// localA.getBasis().setEulerZYX(0,0,-M_PI_4*5);
localA.getBasis().setValue(
-0.70710678118654746,-0.70710678118654746,0,
0.70710678118654746,-0.70710678118654746,0,
0,0,1);
localA.setOrigin(btVector3(btScalar(-0.18), btScalar(-0.10), btScalar(0.)));
// localB.getBasis().setEulerZYX(0,0,-M_PI_4*5);
localB.getBasis().setValue(
-0.70710678118654746,-0.70710678118654746,0,
0.70710678118654746,-0.70710678118654746,0,
0,0,1);
localB.setOrigin(btVector3(btScalar(0.), btScalar(0.225), btScalar(0.)));
coneC = new btConeTwistConstraint(*m_bodies[BODYPART_PELVIS], *m_bodies[BODYPART_LEFT_UPPER_LEG], localA, localB);
coneC->setLimit(M_PI_4, M_PI_4, 0);
coneC->setMotorTarget(btQuaternion(0,0,0,1)); // I added this line and the next for the motor
coneC->enableMotor(true);
m_joints[JOINT_LEFT_HIP] = coneC;
coneC->setDbgDrawSize(CONSTRAINT_DEBUG_SIZE);
Thanks!
Leslie