Super-compact ODE demo and a question

Blitz3D Forums/Blitz3D Userlibs/Super-compact ODE demo and a question

I hate looking at other programmer's demos. I hate sifting through bloated code that adds fancy little extras I could code myself in five seconds, just so I can find the two or three lines of stuff I actually need. A demo should be as compact as possible, and only demonstrate the aspect of programming it is designed to teach.

I like this demo because it gets rid of those ridiculous floaty dreamlike physics. Here ya go:
Const dParamLoStop 			= 0
Const dParamHiStop			= 1
Const dParamVel				= 2
Const dParamVel2			= 258
Const dParamFMax			= 3
Const dParamFMax2			= 259
Const dParamFudgeFactor		= 4
Const dParamBounce			= 5
Const dParamCFM				= 6
Const dParamStopERP			= 7
Const dParamStopCFM			= 8
Const dParamSuspensionERP	= 9
Const dParamSuspensionCFM	= 10

Const dContactMu2			= $001
Const dContactFDir1			= $002
Const dContactBounce		= $004
Const dContactSoftERP		= $008
Const dContactSoftCFM		= $010
Const dContactMotion1		= $020
Const dContactMotion2		= $040
Const dContactSlip1			= $080
Const dContactSlip2			= $100
Const dContactApprox0		= $0000
Const dContactApprox1_1		= $1000
Const dContactApprox1_2		= $2000
Const dContactApprox1		= $3000

Graphics3D 800,600,16,2

cam=CreateCamera()
RotateEntity cam,35,0,0
MoveEntity cam,0,0,-50

CreateLight()

plane=CreatePlane()
EntityFX plane,1
tex=CreateTexture(32,32)
SetBuffer TextureBuffer(tex)
Color 200,200,200
Rect 0,0,32,32
Color 200,0,0
Rect 0,0,16,16
Rect 16,16,16,16
ScaleTexture tex,6,6
EntityTexture plane,tex

world=ODE_dWorldCreate(1)
ODE_dSetContactMode(dContactSoftERP+dContactSoftCFM)
ODE_dSetSOFT_ERP 0.4
ODE_dWorldSetGravity 0,-1,0

body=ODE_dBodyCreate()
geom=ODE_dCreateBox(world,10,10,10,1)
ODE_dGeomSetBody geom,body
ODE_dBodySetPosition body,0,20,0
ODE_dBodySetRotation body,45,45,45
ODE_dBodySetMass body,10
mesh=CreateCube()
EntityColor mesh,0,0,255
ScaleMesh mesh,5,5,5
EntityPickMode mesh,2,1

While Not KeyHit(1)
	ODE_dWorldQuickStep 0.02
	PositionEntity mesh,ODE_dGeomGetPositionX(geom),ODE_dGeomGetPositionY(geom),ODE_dGeomGetPositionZ(geom)
	RotateEntity mesh,ODE_dGeomGetPitch(geom),ODE_dGeomGetYaw(geom),ODE_dGeomGetRoll(geom)
	RenderWorld
	Flip False
	Wend
ODE_dCloseODE()
End


As for the question, I figured it out.

A demo should be as compact as possible, and only demonstrate the aspect of programming it is designed to teach.
No that's "tutorials". Demos, would you believe, are designed to demonstrate what others have achieved. Hence, "demo".
I hate looking at other programmer's demos
Then don't do it? <edit> Bouncer got there first. Oh well.

Ummm, moderator?

yea,... I don't know what's up today, but those comments are totally uncalled for.

No they're not. Halo is always calling comments like that with his idiotic behaviour.

Did he in this occasion?

There's always such an emotional reaction any time I post source. People don't seem to get upset if it's some GUI technical thing, but if I post anything 3D, it seems like it makes people cry.

Here's another example, with delta timing. I'll just keep posting these as I develop it.
Const dParamLoStop 			= 0
Const dParamHiStop			= 1
Const dParamVel				= 2
Const dParamVel2			= 258
Const dParamFMax			= 3
Const dParamFMax2			= 259
Const dParamFudgeFactor		= 4
Const dParamBounce			= 5
Const dParamCFM				= 6
Const dParamStopERP			= 7
Const dParamStopCFM			= 8
Const dParamSuspensionERP	= 9
Const dParamSuspensionCFM	= 10

Const dContactMu2			= $001
Const dContactFDir1			= $002
Const dContactBounce		= $004
Const dContactSoftERP		= $008
Const dContactSoftCFM		= $010
Const dContactMotion1		= $020
Const dContactMotion2		= $040
Const dContactSlip1			= $080
Const dContactSlip2			= $100
Const dContactApprox0		= $0000
Const dContactApprox1_1		= $1000
Const dContactApprox1_2		= $2000
Const dContactApprox1		= $3000

Graphics3D 800,600,16,2

cam=CreateCamera()
RotateEntity cam,45,0,0
MoveEntity cam,0,0,-50
CameraRange cam,1,10000

CreateLight()

plane=CreatePlane()
EntityFX plane,1
tex=CreateTexture(32,32)
SetBuffer TextureBuffer(tex)
Color 64,64,64
Rect 0,0,32,32
Color 0,200,0
Line 0,0,0,32
Line 0,0,32,0
ScaleTexture tex,6,6
EntityTexture plane,tex

world=ODE_dWorldCreate(1)
ODE_dSetContactMode(dContactSoftERP+dContactSoftCFM)
ODE_dSetSOFT_ERP 0.4
ODE_dWorldSetGravity 0,-1,0

body=ODE_dBodyCreate()
geom=ODE_dCreateBox(world,10,10,10,1)
ODE_dGeomSetBody geom,body
ODE_dBodySetPosition body,1000,20,0
ODE_dBodySetMass body,10
mesh=CreateCube()
EntityColor mesh,0,0,255
ScaleMesh mesh,5,5,5
EntityPickMode mesh,2,1

Global ODE_SPEED#=0.01
Global ODE_DETAIL=1
Global ODE_LASTUPDATETIME
Global ODE_UPDATEPAUSETIME
Global ODE_PAUSEOFFSET
Global ODE_MAXSTEPTIME#=0.01

While Not KeyHit(1)
	If KeyHit(57)
		PausePhysics()
		While KeyDown(57)
			Wend
		ResumePhysics()
		EndIf
	UpdatePhysics()
	PositionEntity mesh,ODE_dGeomGetPositionX(geom)-1000,ODE_dGeomGetPositionY(geom),ODE_dGeomGetPositionZ(geom)
	RotateEntity mesh,ODE_dGeomGetPitch(geom),ODE_dGeomGetYaw(geom),ODE_dGeomGetRoll(geom)
	RenderWorld
	Flip False
	Wend
ODE_dCloseODE()
End

Function PausePhysics()
ODE_UPDATEPAUSETIME=MilliSecs()
End Function

Function ResumePhysics()
ODE_PAUSEOFFSET=ODE_PAUSEOFFSET+MilliSecs()-ODE_UPDATEPAUSETIME
ODE_UPDATEPAUSETIME=0
End Function

Function UpdatePhysics()
If ODE_UPDATEPAUSETIME Return
time=MilliSecs()-ODE_PAUSEOFFSET
If ODE_LASTUPDATETIME
	steptime#=(time-ODE_LASTUPDATETIME)*ODE_SPEED
	Else
	steptime#=0.0
	EndIf
ODE_LASTUPDATETIME=time
Repeat
	ODE_dWorldQuickStep ODE_MAXSTEPTIME
	steptime=steptime-ODE_MAXSTEPTIME
	If steptime<=0 Or ODE_MAXSTEPTIME=0 Exit
	Forever
End Function


What .dll and .decls are you using for these examples?

Is there a fully working ODE wrapper available now or are you using the one that freezes the physics simulation periodically?

I use the one that freezes up!

nice one :)


but if I post anything 3D, it seems like it makes people cry.




Your '3D' breath must stink of garlick (sp?)