6dof in ageia physicsThere you go, its been a long time since i posted a tutorial. I have found that 6DOF ( 6 degree of freedom ) is a bit tough to imagine at times and one can easily lose track of whats happening in the scene.

So the best way to track it is to write don the axis and its association with the local, normal and biNormal axis with respect to 6DOF. The truck physics simulation was done with 6DOF available in Director bundled with Ageia physics ! Its kind of fun if you get hang of it and a nightmare if you get lost. So golden rule is to remember what axis is chosen and what properties have been set ( one can lock, limit and have free motion/rotation in a given axis for the rigidbody).

With 6dof one can create complex joints of any type like human elbow , chopper blades , atomic structures etc.

The following is the source code for the joints part of the truck simulation written in Director :). Have fun !!

on FcreateJoints
  --Create handler for ageia physics
  physX = member("physX")
 
  --create 6dof joint between the car body (rb_car) and the tyre
  D6joint1 = physX.createD6Joint("myJoint1",rb_car,rb_tyre_front,vector(1,1,1))
  D6joint1.localAnchorA = vector(-5,3,-5)
  D6joint1.localAnchorB = vector(0,3,0)
 
  D6joint1.localAxisA = vector(0,1,0)
  D6joint1.localNormalA = vector(1,0,0)
  D6joint1.localAxisB = vector(0,1,0)
  D6joint1.localNormalB = vector(1,0,0)
 
  D6joint1.axisMotion = #locked
  --Rigidbody has limited freedom of motion in X-axis
  D6joint1.normalMotion = #limited
  D6joint1.BiNormalMotion = #locked
 
  --twistMotion for rigidbody is free to move in Y direction
  D6joint1.twistMotion = #free
  D6joint1.swing1Motion = #locked
  D6joint1.swing2Motion = #locked
 
  --always make sure that he joint names are unique
  D6joint2 = physX.createD6Joint("myJoint2",rb_car,rb_tyre_rear,vector(1,1,1))
  D6joint2.localAnchorA = vector(-5,3,5)
  D6joint2.localAnchorB = vector(0,3,0)
 
  D6joint2.localAxisA = vector(0,1,0)
  D6joint2.localNormalA = vector(1,0,0)
  D6joint2.localAxisB = vector(0,1,0)
  D6joint2.localNormalB = vector(1,0,0)
 
  D6joint2.axisMotion = #locked
  D6joint2.normalMotion = #limited
  D6joint2.BiNormalMotion = #locked
 
  D6joint2.twistMotion = #free
  D6joint2.swing1Motion = #locked
  D6joint2.swing2Motion = #locked
 
  --set the limit in Y-axis for both the front and rear tyres
  --This is how you get suspension effect :)
  D6joint1.linearLimit =  [-5, 100, 0.01, 0.4]
  D6joint2.linearLimit =  [-5, 100, 0.01, 0.4]
end