General question about btConeTwistConstraint

AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

General question about btConeTwistConstraint

Post by AlexSilverman »

Hello,

I'm trying to model a basketball net using the btConeTwistConstraint. My idea is to have several spheres connected to each other, and I'm trying to understand the steps that go into setting one constraint up. I'd like to just put down my thoughts and let you all correct me as needed. FYI, the code that I'm using to learn about this comes from the Ragdoll Demo.

There are two bodies, and for each, you specify a pivot point (the point to which the proverbial string or pole is attached) and a local axis, being the direction that the pole extends. These are then combined into a btTransform and passed in as arguments to the creation function. This means, that if the same axis is passed in for two bodies, they will have opposite orientations.

Is all this correct? I'd just like to make sure I have a good basis before I go setting things up incorrectly.

Thanks.

- Alex
AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

Post by AlexSilverman »

Ok, so after playing with it for a day, and a tiny epiphany on the way to work this morning, I'm going to revise my post, and see what happens.

My current understanding is as follows...

There are two btRigidBody objects (representing the bodies, obviously), and two btTransform objects per constraint. The transform objects consist of a matrix and a vector as we all know. The vector is, in local coordinates, a vector (of length n) to the center of the constraint (being the midpoint between the two bodies. That is to say that as defined by this vector, the body can be a maximum of n units from the center of the constraint. So if one wants two bodies to never be farther than 1 unit in the X from each other, they would create the following btTransform.

Code: Select all

btTransform trans;
trans.setIdentity();
trans.setOrigin(0.5, 0, 0);
and pass that same matrix in for each body.

The matrix part of the btTransform is what I'm less sure of. I believe that it is the maximum rotation allowed between the body and the constraint. So, if one wanted to keep object B in below object A at all times, one would create the following btTransform for object A

Code: Select all

btTransform trans;
trans.setIdentity();
trans.getBasis().setEulerXYZ(0, DEG_TO_RAD(90), 0);
Ok, so that's my current, long winded explanation of how I think things work. Any corrections are welcome, unless this is somehow correct :)

Thanks.

- Alex