I tried to simulate cloak using ragdoll.
Configuring with one kinematic rigidbody and several rigidbody with it.
It's very unstable and I dont know what is wrong with it.
:setup kinematic
:setup otherspBody->setCollisionFlags(pBody->getCollisionFlags() |
btCollisionObject::CF_KINEMATIC_OBJECT);
pBody->setActivationState(DISABLE_DEACTIVATION);
and I using generic6DOFConstraintspBody->setActivationState(DISABLE_DEACTIVATION)
and update time I initialize Kinematic bodybtTransform tt;
tt.setIdentity();
tt.getBasis().setEulerZYX(x, y, z);
btVector3 parentAxis(_kParentAxis.x, _kParentAxis.y, _kParentAxis.z);
parentAxis = tt * parentAxis;
btVector3 childAxis(_kChildAxis.x, _kChildAxis.y, _kChildAxis.z);
btVector3 anchor(_kAnchor.x, _kAnchor.y, _kAnchor.z);
anchor = tt* anchor;
btVector3 zAxis = parentAxis.normalize();
btVector3 yAxis = childAxis.normalize();
btVector3 xAxis = yAxis.cross(zAxis); // we want right coordinate system
btTransform frameInW;
frameInW.setIdentity();
frameInW.getBasis().setValue(
xAxis[0], yAxis[0], zAxis[0],
xAxis[1], yAxis[1], zAxis[1],
xAxis[2], yAxis[2], zAxis[2]);
frameInW.setOrigin(anchor);
btTransform frameInA = _pkParent->getCenterOfMassTransform().inverse() * frameInW;
btTransform frameInB = _pkChild->getCenterOfMassTransform().inverse() * frameInW;
btGeneric6DofConstraint* pGen6DOF = new btGeneric6DofConstraint(
*_pkParent, *_pkChild, frameInA, frameInB, true);
pGen6DOF->setAngularLowerLimit(btVector3( -FLT_EPSILON , -NI_PI * 0.1f, -NI_PI * 0.1f));
pGen6DOF->setAngularUpperLimit(btVector3( FLT_EPSILON , NI_PI * 0.1f, NI_PI * 0.1f));
pImpl->m_pkWorld->addConstraint(pGen6DOF, true);
finally updaterb->setInterpolationWorldTransform(rb->getWorldTransform());
rb->setInterpolationLinearVelocity(btVector3(0,0,0));
rb->setInterpolationAngularVelocity(btVector3(0,0,0));
Problem is actor moves very fast and each rigid body become unstable.pImpl->m_pkWorld->stepSimulation(1.f/60.f, 100, 1.f/60.f);
even I set constraints' Linear Limit zero
all the body goes to their own way...
am I set someting wrong?