Usage: btGeneric6DofConstraint

davidotcom
Posts: 3
Joined: Fri Mar 21, 2008 4:04 pm

Usage: btGeneric6DofConstraint

Post by davidotcom »

Hi,

I started using Bullet recently and was wondering if someone can explain how to use btGeneric6DofConstraint.

I'm trying build a ragdoll given a mesh/skeleton. I've been having trouble figuring out what values to give "const btTransform& frameInA" and "const btTransform& frameInB" in the constructor to get my ragdoll to act correctly.

Thanks.

- David
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Usage: btGeneric6DofConstraint

Post by Erwin Coumans »

Have you already checked the GenericJointDemo? It builds a ragdoll using the btGeneric6DofConstraint.

In general, the frameInA is the connection of the constraint in local coordinates of A, this is a local 'pivot' point and 3 axis. If you only have one axis, you can compute two other orthogonal axis using btPlaneSpace1. Basically you can derive frameInB from frameInA by transforming frameInA into worldspace, and then back into B space using the inverse transformB.

Given a local pivot point in A, pivotInA, and axisInA, this is one way to compute the full frameInA and frameInB, as long as the objects are already positioned properly in worldspace:

Code: Select all

btTransform frameInA;
btTransform frameInB;

btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
if (axis1.length() == 0.0)
{
	btPlaneSpace1( axisInA, axis1, axis2 );
}

frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(),
	                          axisInA.y(), axis1.y(), axis2.y(),
							  axisInA.z(), axis1.z(), axis2.z() );
frameInA.setOrigin( pivotInA );

btTransform inv = rb1->getCenterOfMassTransform().inverse();

btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA;

frameInB = inv  * globalFrameA;

genericConstraint = new btGeneric6DofConstraint(
	*rb0,*rb1,
	frameInA,frameInB);
Hope this helps,
Erwin
davidotcom
Posts: 3
Joined: Fri Mar 21, 2008 4:04 pm

Re: Usage: btGeneric6DofConstraint

Post by davidotcom »

Thanks for the clarification.

That's exactly what I needed.

- David