Ragdoll / Biped Class / Movement frustration

CagedFury

02-03-2007 02:45:56

Hi,

Ok so ie been struggling with this for weeks now, and although i am making progress im just not sure what to try next.

What i am attempting to do is make something similar to what is described in this topic
http://grotsnik.ogre3d.org/phpBB2addons ... d313b36c2a

I have managed to sort out the Ragdoll class to update to the ogre bones, and i can freeze unfreeze etc at will.

I also have a large cylinder which moves around the world using forces in a custome callback (I have used balls with torque but that makes the keeping of the ragdoll upright very difficult). Made a pair of materials that dont collide and assigned them to the ragdoll and the cylinder respectively.

I then created a Joint (Ball and Socket) to connect the Cylinder and the Ragdoll. Thinking that the Ragdoll will move along because its joined to the cylinder.

However it behaves a bit like an anchor and i have tried swapping the Ragdoll to be the parent of the joint, various limits, stiffness etc on the joint itself.

I then gave up on the idea and tried just to get the ragdoll moving around using the custom force callback. However it still behaves much the same, moves at a tiny fraction of the speed the cylinder does.

There are a couple of things that i think might work but im really not sure how to do them.

Set the material for the ragdoll to be null (its mentioned in the biped class post linked above, but trying setMAterialID(NULL) just has a runtime error.

Work out the whole joint thing between the two bodies, maybe that is the cause or at least the road to salvation.

Other than that i may have to resort t using setVelocity, as that is the only thing ive been able to get to work for it correctly. Maybe the different combinations of localForces (which smashed the ragdoll to peices), GlobalForces (which did nothing) or setForce (which worked for a while then smashed the ragdoll to peices) were wrong but ill post a little of the code here so you can point out any glaring mistakes :).


col = new OgreNewt::CollisionPrimitives::Cylinder(mWorld, size.x,size.y);
mCollisionBody = new OgreNewt::Body( mWorld, col );
mCollisionBody->setPositionOrientation( position, rotation );
mCollisionBody->attachToNode( mCollisionNode );
mCollisionBody->setCustomForceAndTorqueCallback(boost::bind(&RagCharacter::customForceCallback,this,_1));
mCollisionBody->setAutoFreeze(0);


if(mCollisionMass > 0)
{
inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid( mCollisionMass, size.x, size.y);
mCollisionBody->setMassMatrix( mCollisionMass, inertia );
}

OgreNewt::MaterialID * matRag = new OgreNewt::MaterialID(mWorld);
OgreNewt::MaterialID * matCyl = new OgreNewt::MaterialID(mWorld);
mCollisionBody->setMaterialGroupID(matCyl);
OgreNewt::MaterialPair * pair = new OgreNewt::MaterialPair(mWorld, matRag, matCyl);
pair->setDefaultCollidable(0);


for (RagDoll::RagBoneListIterator it = mRagdoll->mBones.begin(); it != mRagdoll->mBones.end(); it++)
{
(*it)->getBody()->setCustomForceAndTorqueCallback(boost::bind(&RagCharacter::customForceCallback,this,_1));
(*it)->getBody()->setMaterialGroupID(matRag);
(*it)->getBody()->setUserData((void*) mCollisionBody);
}

mRagdollSphereJoint = new OgreNewt::BasicJoints::BallAndSocket( mWorld,

mRagdoll->getRootBody(),
mCollisionBody,
(Vector3(0,10,0)+startPos)
);
//mCollisionBody->setJointRecursiveCollision(0);
//mRagdoll->getRootBody()->setJointRecursiveCollision(0);
//mRagdollSphereJoint->setCollisionState(0);
mRagdollSphereJoint->setStiffness(1);

void RagCharacter::customForceCallback(OgreNewt::Body * me)
{
Vector3 rLocation;
Quaternion rOrient;
me->getPositionOrientation(rLocation,rOrient);

Vector3 gravityForce(0,-9.8,0);

mForce = Vector3(0,0,0);
mForce.x += adjForce->x;
mForce.z += adjForce->z;

mForce = mQuat * mForce;
mForce.y += gravityForce.y;
mForce.y += adjForce->y;

me->addForce(mForce);
}


Ive been trying various things though i have no idea f they were ven on the right track, ive tried setting most of the things i can with ->set... on Bodys but its like fumbling around int eh dark. Plus i did alot of messing around with stuff before i worked out it was materials and the ragdoll colliding with the cylinder that made it explode previously.

Anyway any help or suggestions would be very much appreciated.

Thanks

CagedFury

02-03-2007 03:40:30

Oh erm nevermind, i was able to get a solution tying something i had tried before, making the ragdoll use the same node as the cylinder, since the cylinder moves the node the node then moves the ragdoll.

However the ragdoll body works fine, smooth but the mesh itself flickers and jumps a little. Not to mention more messing with orientation and quaternions now

Anouther problem for anouther day.

Why is it always just after you ask for help that you figure out an answer? :)