So i am trying to create a rag-doll with muscles (so i cant use btMultiBody) anyway the issue i am having with the arms and legs is that when i create the rigidbodies they are in the correct position however when i begin to step the simulation they switch sides, soo left to right and right to left , i am not 100% sure why this is happening and would really appreciate some advice
this is where i build the bone(btRigidBody)
Code: Select all
mBuilder->SetDimensions(arm_Width, arm_height / 2);
mBuilder->SetRelativePosition(Ogre::Vector3(-torso_width, 0, 0), Ogre::Quaternion::IDENTITY, *mShouldernode->GetNode());
if (!mBuilder->BuildBone(*RUpperArm))
return false;
Code: Select all
offset = Ogre::Vector3(torso_width, 0, 0);
SetJointTransform(localA, localB, Utils::OgreBTVector(mShouldernode->GetNode()->_getDerivedPosition() + offset), mShouldernode, LUpperArm,btVector3(-M_PI,0,0));
btConeTwistConstraint* LshoulderConst = new btConeTwistConstraint(*mShouldernode->GetRigidBody(), *LUpperArm->GetRigidBody(), localA, localB);
LshoulderConst->setLimit(M_PI_2, M_PI_2, 0);
Code: Select all
void Skeleton_Builder::SetJointTransform(btTransform& TransformA, btTransform& TransformB,btVector3& JointPosWorld, Bone* boneA, Bone* boneB, btVector3& Axis)
{
TransformA.setIdentity(); TransformB.setIdentity();
TransformA.getBasis().setEulerZYX(Axis.x(),Axis.y(),Axis.z());
TransformB.getBasis().setEulerZYX(Axis.x(), Axis.y(), Axis.z());
auto testA = JointPosWorld - Utils::OgreBTVector(boneA->GetNode()->_getDerivedPosition());
auto testA2 = Utils::OgreBTVector(boneA->GetNode()->_getDerivedPosition()) - JointPosWorld;
auto testB = JointPosWorld - Utils::OgreBTVector(boneB->GetNode()->_getDerivedPosition());
auto testC = boneA->GetNode()->_getDerivedPosition();
auto testD = boneB->GetNode()->_getDerivedPosition();
TransformA.setOrigin(Utils::OgreBTVector(boneA->GetNode()->_getDerivedPosition()) - JointPosWorld);
TransformB.setOrigin(Utils::OgreBTVector(boneB->GetNode()->_getDerivedPosition()) - JointPosWorld);
}
and thanks in advance