Game Development Reference
In-Depth Information
er to store various pieces of data relative to object A (the rigid body) or object B (the
constraint's pivot point in this case, but could also be a second rigid body). This be-
comes important when using the constraint later.
dof6->setAngularLowerLimit(btVector3(0,0,0));
dof6->setAngularUpperLimit(btVector3(0,0,0));
Also, calling the setAngularUpperLimit() and setAngularLowerLimit()
functions with zero's btVector3 s add a rotational limitation to the box while it is at-
tached to this constraint, preventing it from rotating.
m_pWorld->addConstraint(dof6,true);
Much like rigid bodies, it's not enough to create the object; we must also inform the
world of its existence, hence we call the addConstraint() function. The second
parameter disables the collisions between the two linked bodies. Since we don't
have two bodies in this constraint (we have a body and a pivot point), it would be
wise to tell Bullet to save itself some effort by setting the value to true . If we had
two rigid bodies connected via a weak constraint and were interested in having them
collide, we would want to set this value to false .
// define the 'strength' of our constraint
(each axis)
float cfm = 0.5f;
dof6->setParam(BT_CONSTRAINT_STOP_CFM,cfm,0);
dof6->setParam(BT_CONSTRAINT_STOP_CFM,cfm,1);
dof6->setParam(BT_CONSTRAINT_STOP_CFM,cfm,2);
dof6->setParam(BT_CONSTRAINT_STOP_CFM,cfm,3);
dof6->setParam(BT_CONSTRAINT_STOP_CFM,cfm,4);
dof6->setParam(BT_CONSTRAINT_STOP_CFM,cfm,5);
// define the 'error reduction' of our
constraint (each axis)
float erp = 0.5f;
dof6->setParam(BT_CONSTRAINT_STOP_ERP,erp,0);
dof6->setParam(BT_CONSTRAINT_STOP_ERP,erp,1);
dof6->setParam(BT_CONSTRAINT_STOP_ERP,erp,2);
Search WWH ::




Custom Search