Hinge/Contraints and setting up the AFrame and BFrame

logic7error
Posts: 4
Joined: Tue Oct 21, 2008 12:59 am

Hinge/Contraints and setting up the AFrame and BFrame

Post by logic7error »

Hey All,

I've hit stumbling block and could really use some help or a nudge to put me back on the right track. I've been implementing a ragdoll system in our engine using Bullet. When I use the default Frame values from the ragdoll demo for the constraints, everything works as it should. I'm at a loss on how to properly setup the Frame data for the hinges and any help would be greatly appreciated.

<Added>

Alright, I figured it out and it was due to my lack of experience with Bullet. I'm going to go ahead and post what I have learned and hopefully this will help out someone else who might be struggling with constraints and thanks mickey for the response.


Hinge

The hinge constraint is a simple constraint with only one axis of influence, the axis in which the attached object(s) revolve around. An easy way to visualize the hinge constraint is to think of a default orientation at the origin with the +z axis being the axis of influence. Whenever you rotate the attached object around the hinge, the orientation of the objects will be the rotation around the z axis.

When setting up the Frame(s), you must remember that the information must be in the attached object(s) local space. This also includes the hinge's rotation as well. An easy way to figure this out is to use the following equation: btMtxLocalBoneOffset = btMtxAttachedObjectTransform.inverse() * btWorldBoneTransform;
btMtxLocalBoneOffset would then be used as AFrame or BFrame's transform.

Conetwist

The conetwist constraint follows a slightly different axis influence then the hinge constraint. However, the frame setup is exactly the same. To visualize a conetwist, take the constraint at a default orientation at the origin. The conetwist constraint twists around the Z axis. While the X and Y axis control the cone aspect of the constraint.

Some points to remember that can lead to some unexpected results. The first is that if the rotation is 180 degrees (PI rads) then the constraint's limits will be "backwards". the second is to be aware that if your engine uses the left-handed coordinate system, you must compensate for this before setting up the Frame data. An easy way is to convert the orientation matrix from your engine into a quaternion and then into a btTransform matrix.

This doesn't go into too much depth but hopefully it will help out.

L7E
Last edited by logic7error on Sat Dec 20, 2008 3:54 am, edited 2 times in total.
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: Hinge/Contraints and setting up the AFrame and BFrame

Post by mickey »

Hi

Are you trying to orient the mesh properly to match that of the hinge's orientation / angle?

Anyway, I have my own similar set of problem orienting my ragdoll properly but not with the hinge constraint. I use the btHingeConstraint::getHingeAngle() to properly orient my elbow and knee joints.

I am however having similar orientation problem using the cone twist or 6-dof, there's no similar method that I can use to get their orientation like the hinge constraint has.

I hope that helps a little, if you do manage to find out how to orient your ragdoll with the cone twist or 6-dof, please do let me know.

Thanks.