CodeRecipe( );

one stop for all game coders..

Follow us on Twitter
Home
Linear Joint Print E-mail
User Rating: / 1
PoorBest 
Written by CR Team   
Sunday, 18 May 2008 00:00

Similar to Angular Joints the way in which it is created, the only difference between them is that in Linear Joint the rest length is not restricted in movement but the angular rotation of the rigid body is.

linear_joint

The above diagram shows that the restlength is not restricted and the angle/orientation of the rigid body is restricted based on the angle provided.

CreateLinearJoint() method takes a constraint descriptor and a list with a vector and the orientation.

Creation of Linear joint also requires a constraint descriptor.

Example to create a Linear Joint:

1
2
3
4
5
6
7
8
9
10
11
--Create linear Joint
pDirPhyz = member("physX") --your physics member name
POCA = vector(0,0,0) -- point of contact of rigidbody A
-- point of contact of rigidbody B, offset from the center:vector(0,0,0)
POCB = vector(60,0,0)
--read the help for constraint descriptor ConstraintDesc()
desc = ConstraintDesc("linear_constraint",rb_A,rb_B,POCA,POCB,100,30)
--Create a linearjoint maintaining an angle of 30 degree in y-axis
linearjoint = pDirPhyz.createLinearJoint(desc,[vector(0,1,0), 30])
--rb_B gets oriented at an angle of 30 degree wrt rb_A
put linearjoint --DEBUG

 

Note: While creating a constraint descriptor in the above example code, rb_B will get oriented at an angle of 30 degree wrt to rb_A in y-axis.