JV-ODE Physics Thread 3

Blitz3D Forums/Blitz3D Userlibs/JV-ODE Physics Thread 3

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

To prevent roll I use Wayne's example for angular friction

For ode.ODE_object=Each ODE_object
   If ode\body
      If dBodyIsEnabled(ode\body)
         numjoints=dBodyGetNumJoints(ode\body)
         If numjoints>0      ; If joined to another body
            For joints=0 To numjoints-1
               ; for all joints attached to body...
               joint=dBodyGetJoint(ode\body,joints)
               If dJointGetType(joint)=dJointTypeContact   ; If joint type is a collision contact
                  ; Get Angular velocity vector
                  bx#=dBodyGetAngularVelX#(ode\body)
                  by#=dBodyGetAngularVelY#(ode\body)
                  bz#=dBodyGetAngularVelZ#(ode\body)
                  ; Calculate magnitudes
                  ForceB#=Sqr(bx*bx+by*by+bz*bz)
                  If forceb>.01
                     friction#=ode\mat\rotational_friction*-1.0
                     dBodyAddTorque ode\body,dBodyGetAngularVelX(ode\body)*friction,dBodyGetAngularVelY(ode\body)*friction,dBodyGetAngularVelZ(ode\body)*friction
                  End If
               End If
            Next
         EndIf
      EndIf
   EndIf
Next