I have a question about point to point constraints. I am trying to create a series of stick bodies connected with ball joints, such that when I run the simulation they will droop (due to gravity) but retain their rigid shape (this is unlike a soft body situation where the bodies can elongate). In the example below I am making a series of five sticks 4x1x1 units each and spaced by 1 unit in between. The first one is fixed by zero mass. Then I create p2p joints at the middle of their intervals. The manual and demos show that the constraint point needs to be in local coordinates within each body so, if my sticks are 4 units centered about 0,0,0 then +/-2.5 should be 0.5 units off. The behavior I get is quite bizarre see this video http://youtu.be/pGHIKNExqdg. So the question is: what am I doing so wrong here? Thanks in advance and sorry for the bad C# code below
Code: Select all
world.Gravity = new Vec3D( 0, 0, -10 );
int count = 5;
for( int index = 0; index < count; index++ )
{
AddBox( 2 + index * 5, 0, 0, 4, 1, 1, index );
}
for( int index = 1; index < count; index++ )
{
world.AddConstraint(
new Point2PointConstraint(
bodies[index - 1],
bodies[index - 0],
new Vec3D( 2.5f, 0, 0 ),
new Vec3D( -2.5f, 0, 0 ) ) );
}
where: AddBox is simiar to localCreateRigidBody in the demos (the first three params are translations tx, ty, tz, the following three are the dimensions dx, dy, dz and the last is the mass)