CodeRecipe( );

one stop for all game coders..

Follow us on Twitter
Home >> Tutorials >> Game Physics >> Constraint Descriptor
Coderecipe Downloads

Constraint Descriptor Print E-mail
User Rating: / 3
PoorBest 
Written by CR Team   
Monday, 18 May 2009 00:00

Before jumping into joints Director/Ageia requires the user to create a constraint Descriptor. A constraint descriptor is a structure that stores the required parameters that are later on used to create Linear or angular Joints.physics

A constraint descriptor is of the following format (syntax and parameter list) :

Constraint Descriptor
1
ConstraintDesc(sname,ObjectA,ObjectB,vPointA,vPointB,fStiffness,fDamping)

Cname - name for the constraint , has to be unique

rbA - Rigid body A ( created via createrigidbody() )

rbB - Rigid body B ( created via createrigidbody() )

vector pocA - point at which the joint is created within rigid body A’s coordinate,

vector pocB - point at which the joint is created within rigid body B’s coordinate

Stiffness - Value of the stiffness of the constrain. How flexible is the spring...

damping - Value of the damping of the constraint. What is the damping applied on the movement of the rigid body.

code Snippet
1
2
3
4
5
--Lingo Syntax 
-- Spring constraint Descriptor between two rigid bodies' b1 and b2. 
SpringDesc = ConstraintDesc("SpringDesc",b1,b2,vector(0.0,0.0,0.0),vector(0.0,0.0,0.0),500,1) 
-- Linear Joint constraint Descriptor between a rigid body b1 and point in world. 
LJointDesc = ConstraintDesc("LJoinDesc",b1,void,vector(0.0,0.0,0.0),vector(0.0,0.0,0.0),500,1) 

The code snippet shows the Point of contact values for b1 and b2 to be vector(0,0,0) which means that the spring will be created at the center of mass of the 2 rigid bodies. It can be changed based on the requirement. [ make sure that the point does not lie outside the rigid bodies local axis )

The constraint descriptor created can be used to create linear, angular and spring joints.

Note: Based on the mass/size of the rigid body one has to tweak the damping and stiffness parameters of the constraint descriptor.