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.
|