Unstable Kinematics Object

magicb
Posts: 1
Joined: Mon Sep 07, 2009 10:46 am

Unstable Kinematics Object

Post by magicb »

Hi.

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
pBody->setCollisionFlags(pBody->getCollisionFlags() |
btCollisionObject::CF_KINEMATIC_OBJECT);
pBody->setActivationState(DISABLE_DEACTIVATION);
:setup others
pBody->setActivationState(DISABLE_DEACTIVATION)
and I using generic6DOFConstraints
btTransform 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);
and update time I initialize Kinematic body
rb->setInterpolationWorldTransform(rb->getWorldTransform());
rb->setInterpolationLinearVelocity(btVector3(0,0,0));
rb->setInterpolationAngularVelocity(btVector3(0,0,0));
finally update
pImpl->m_pkWorld->stepSimulation(1.f/60.f, 100, 1.f/60.f);
Problem is actor moves very fast and each rigid body become unstable.
even I set constraints' Linear Limit zero
all the body goes to their own way...

am I set someting wrong?