I was hoping that perhaps someone could tell me what might prevent the spring from working?
Code: Select all
void BtVehicleBody::addAxisStabilizer(Point3F upperAngLimits, Point3F lowerAngLimits, Point3F angularStiffness, Point3F angularDamping)
{
btRigidBody *mBalancer = new btRigidBody(btRigidBody::btRigidBodyConstructionInfo( 0, 0, 0, btVector3( 0, 0, 0 )));
mWorld->getDynamicsWorld()->addRigidBody(mBalancer);
btVector3 btUpperAngLimits = btCast<btVector3>(upperAngLimits);
btVector3 btLowerAngLimits = btCast<btVector3>(lowerAngLimits);
btTransform frameA(btTransform::getIdentity());
btTransform frameB(btTransform::getIdentity());
frameA.getBasis().setEulerZYX( SIMD_2_PI, SIMD_2_PI, SIMD_2_PI );
mBalancer->getWorldTransform().getBasis().setEulerZYX( SIMD_2_PI, SIMD_2_PI, SIMD_2_PI );
mBalancer->setActivationState(DISABLE_DEACTIVATION);
btGeneric6DofSpringConstraint * axisStabilzer = new btGeneric6DofSpringConstraint(*mActor, *mBalancer, frameA, frameB, true);
axisStabilzer->setLinearUpperLimit(btVector3(SIMD_INFINITY, SIMD_INFINITY, SIMD_INFINITY));
axisStabilzer->setLinearLowerLimit(btVector3(-SIMD_INFINITY, -SIMD_INFINITY, -SIMD_INFINITY));
axisStabilzer->setAngularUpperLimit(btUpperAngLimits);
axisStabilzer->setAngularLowerLimit(btLowerAngLimits);
mWorld->getDynamicsWorld()->addConstraint(axisStabilzer);
axisStabilzer->enableSpring(3, true);
axisStabilzer->setStiffness(3, angularStiffness.x);
axisStabilzer->setDamping(3, angularDamping.x);
axisStabilzer->enableSpring(4, true);
axisStabilzer->setStiffness(4, angularStiffness.y);
axisStabilzer->setDamping(4, angularDamping.y);
axisStabilzer->enableSpring(5, true);
axisStabilzer->setStiffness(5, angularStiffness.z);
axisStabilzer->setDamping(5, angularDamping.z);
axisStabilzer->setEquilibriumPoint();
}