I thought I would help some here...
It has been a long time since I have played with ODE, but this should help.
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, October 24, 2010
Rem ***** Main Source File *****
sync on
set display mode 800,600,32,1
autocam off
set window on
ode start
ode set world gravity 0,0,0
` --- a little magic here, unknown what they do exactly, ODE docs seem to mention these for object collision and restitution
` --- these are my usual settings - although they can vary based on object sizes, etc.
`ode set world step 0.08 :`world step increment for calculations
`ode set world erp (0.4)*2.5 :`error correction each step
`ode set world cfm (10^-5)*2.5 :`constraint force mixing
` --- these settings seem to work for your simulation
ode set world step 0.02
ode set world erp (0.4)*5.5
ode set world cfm (10^-5)*2.5
for t=1 to 100
make object sphere t,10
color object t,rgb(rnd(255),rnd(255),rnd(255))
position object t,0,0,0
rotate object t,rnd(360),rnd(360),rnd(360)
move object t,50+rnd(50)
ode create dynamic sphere t
ode set body mass t,10
ode set contact bounce t,1 :`just setting a bounce factor, not really needed
next t
do
position camera 0,0,0
rotate camera mousey(),mousex(),0
move camera -200
for t=1 to 100
x#=object position x(t)
y#=object position y(t)
z#=object position z(t)
dist#=sqrt(x#^2+y#^2+z#^2)+10
g#=-10/(dist#^2)
gx#=g#*x#/dist#
gy#=g#*y#/dist#
gz#=g#*z#/dist#
ode add force t,gx#,gy#,gz#,0,0,0
next t
set cursor 0,0
print screen fps()
ODE update
sync
LOOP
Physics engines can have collision errors, but you can help constrain the errors within your simulation in ODE
by setting up some ODE world settings for the engine to use
Here is another version that moves the camera in & out using up and down arrow keys
Also a COOL feature, slowing down the ODE simulation using the left & right arrow keys.
Rem Project: Dark Basic Pro Project
Rem Created: Monday, October 25, 2010
Rem ***** Main Source File *****
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, October 24, 2010
Rem ***** Main Source File *****
sync on
set display mode 800,600,32,1
autocam off
set window on
ode start
ode set world gravity 0,0,0
` --- a little magic here, unknown what they do exactly, ODE docs seem to mention these for object collision and restitution
` --- these are my usual settings - although they can vary based on object sizes, etc.
`ode set world step 0.08 :`world step increment for calculations
`ode set world erp (0.4)*2.5 :`error correction each step
`ode set world cfm (10^-5)*2.5 :`constraint force mixing
` --- these settings seem to work for your simulation
ode set world step 0.01
ode set world erp (0.4)*6.5
ode set world cfm (10^-5)*2.5
numballs=300
odespeed#=0.01
for t=1 to numballs
make object sphere t,10
color object t,rgb(rnd(255),rnd(255),rnd(255))
position object t,0,0,0
rotate object t,rnd(360),rnd(360),rnd(360)
move object t,100+rnd(60)
ode create dynamic sphere t
ode set body mass t,10
ode set contact bounce t,50 :`just setting a bounce factor, not really needed
next t
camz=-600
do
position camera 0,0,0
rotate camera mousey(),mousex(),0
move camera camz
if upkey() and camz<-100 then inc camz,10
if downkey() and camz>-1500 then dec camz,10
if rightkey() and odespeed#<0.25 then inc odespeed#,0.001
if leftkey() and odespeed#>0.001 then dec odespeed#,0.001
for t=1 to numballs
x#=object position x(t)
y#=object position y(t)
z#=object position z(t)
dist#=sqrt(x#^2+y#^2+z#^2)+10
if dist#>1500.0 then ode set linear velocity t,0.0,0.0,0.0
` g#=-10.0/(dist#^2)
g#=-10.0/dist#
gx#=g#*x#/dist#
gy#=g#*y#/dist#
gz#=g#*z#/dist#
ode add force t,gx#,gy#,gz#,0,0,0
next t
set cursor 0,0
print screen fps()
print "Dist=";camz
print "ODE Speed=";odespeed#
ODE update odespeed#
sync
LOOP
I must confess, over time ODE errors get worse allowing objects to pass through each other, I don't know why.