cone constraint switching sides when simulation activates

Post Reply
nathn123
Posts: 7
Joined: Tue Jan 19, 2016 1:51 pm

cone constraint switching sides when simulation activates

Post by nathn123 »

Hi

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;
this is where i build the constraint

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);
also the function SetJointTransform takes the world position of where i want the constraint to be, and then get the relative positions of the for localA and localB

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);
}
sorry for the major code dump i just figured its best to give you guys am much info as you need to help

and thanks in advance
nathn123
Posts: 7
Joined: Tue Jan 19, 2016 1:51 pm

Re: cone constraint switching sides when simulation activate

Post by nathn123 »

bump

if anyone has any possible solutions please it might help
Post Reply