BlitzODE Physics Thread

Blitz3D Forums/Blitz3D Userlibs/BlitzODE Physics Thread

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.

thanks Cygnus,

How do I stop force acting upon a body -set with dBodyAddForce?

I tried getting and setting the angular-momentum as in the car demos but my cube doesnt slow down after I apply the force.

Do I get the list of commands from the ODE website?

;-----------------------------;
; BlitzODE ARKON Wrapper 0.5b ;
; Tutorial 1                  ;
;-----------------------------;

Include "BlitzODE.bb"

;------ Initialize Graphics --------

Graphics3D 800, 600
SetBuffer BackBuffer()

PV = CreatePivot()
cam = CreateCamera(PV)
PositionEntity cam, 0, 10, -20
PointEntity cam, PV
lh = CreateLight()


SeedRnd MilliSecs()
;--------- Initialize ODE ----------

Global space = ODE_dWorldCreate(0)
ODE_dWorldSetGravity(0,0,0)
;---- Setting contact parameters ---

ODE_dSetContactMode(dContactBounce + dContactSoftERP + dContactSoftCFM)
ODE_dSetBOUNCE(0.5)
ODE_dSetSOFT_ERP(0.4)
ODE_dSetSOFT_CFM(0.8)

;------- Create simple cube ---------

g.TODEGeom = New TODEGeom
g\body = ODE_dBodyCreate()
g\geom = ODE_dCreateBox(space, 1, 1, 1, 1)
ODE_dGeomSetBody g\geom, g\body
ODE_dBodySetPosition(g\body, 0, 10, 0)
ODE_dBodySetRotation(g\body, Rand(-180, 180), Rand(-180, 180), Rand(-180, 180))

g\mesh = CreateCube()
EntityColor g\mesh, 255, 255, 0
EntityShininess g\mesh, 0.7

;-----------------------------------

ODE_UpdateGeoms()

;-----------------------------------

gameFPS = 50.0
framePeriod = 1000 / gameFPS
frameTime = MilliSecs () - framePeriod

While Not KeyHit(1)
	Repeat
		frameElapsed = MilliSecs () - frameTime
	Until frameElapsed
	
	frameTicks = frameElapsed / framePeriod
	frameTween# = Float(frameElapsed Mod framePeriod) / Float(framePeriod)
	For frameLimit = 1 To frameTicks
		If frameLimit = frameTicks Then CaptureWorld
		frameTime = frameTime + framePeriod

For g.todegeom=Each todegeom
If KeyDown(57)
ODE_dBodyEnable g\body
ODE_dBodyAddForce g\body, 0, 0, 10
EndIf
Next

            ;------------ Update physics world ----------

		ODE_dWorldQuickStep 0.01

            ;--------------------------------------------
For g.todegeom= Each todegeom
ax# = ODE_dBodyGetAngularVelX(g\body) * .9
ay# = ODE_dBodyGetAngularVelY(g\body) * .9
az# = ODE_dBodyGetAngularVelZ(g\body) * .9

ODE_dBodySetAngularVel(g\body, ax#, ay#, az#)
Next
	Next
	
	;---- Set geometry position and rotation ----

	ODE_UpdateGeoms()

	;--------------------------------------------

	RenderWorld frameTween#
	For g.todegeom= Each todegeom
	Text 0,0,ODE_dBodyGetAngularVelX(g\body)
Text 0,10,ODE_dBodyGetAngularVely(g\body)
Text 0,20,ODE_dBodyGetAngularVelz(g\body)
next
	Flip 0
Wend

ODE_dCloseODE()
End