@Z_MAN
One option is to review and adjust the speed on the fly using a simple function.
Function MaintainVelocity(ID,MinVelocity#)
x# = phy get rigid body linear velocity x(ID)
y# = phy get rigid body linear velocity y(ID)
z# = phy get rigid body linear velocity z(ID)
TotalVelocity# = abs(x#)+abs(y#)+Abs(z#)
If TotalVelocity# < MinVelocity#
phy add rigid body force ID, x#*MinVelocity#, y#*MinVelocity#,z#*MinVelocity#,0
endif
Endfunction
Here is the rest of the program if you are interested
Rem Project: Glass Box by Codger
Rem Created: 11/23/2006 9:00:23 PM
Rem ***** Main Source File *****
randomize timer()
phy start
phy set gravity 0,0,0
SET AMBIENT LIGHT 50
autocam off
SYNC ON : SYNC RATE 60
GLOBAL MyTimer
ID = 1 :Width = 80 : Height = 60 : Depth = 100 : Thickness = 5
makebox(ID,Width, Height, Depth, Thickness, 0.0,0.0,0.0)
ID = 7
make object sphere ID, 15,15,15
color object ID, rgb(255,0,0)
position object ID,15,15,15
phy make rigid body static sphere ID
ID = 8
make object Box ID, 15,15,15
color object ID, rgb(255,0,0)
position object ID,-15,-15,-15
phy make rigid body static box ID
position camera 0, 0,0,-50
point camera 0,0,0,0
FirstSphere = 100 : LastSphere = 700
for ID = FirstSphere to LastSphere
make object sphere ID, ((rnd(20)+2)/10.0) ,10,10
color object ID, rgb(rnd(255),rnd(255),rnd(255))
position object ID,rnd(Width)-Width/2,rnd(Height)-Height/2,Rnd(Depth)-Depth/2
phy make rigid body dynamic sphere ID
phy set rigid body linear velocity ID, rnd(50)-25,rnd(50)-25,rnd(50)-25
phy update
rem SYNC
next i
Mytimer = timer() + 5000
do
if shiftkey() then position camera 0, camera position x(), camera position y ()+.1, camera position z()
if controlkey() then position camera 0, camera position x(), camera position y ()-.1, camera position z()
CONTROL CAMERA USING ARROWKEYS 0, 1, 2
if scancode() = 0 and timer() < MyTimer
text 10,20, "FPS : "+ str$(screen FPS())
text 10,40, "Press spacekey to toggle box"
text 10,60, " Use arrow keys to move fwd,back, tuen left & right"
text 10,80, " Use shift, ctrl to move up & down"
endif
for ID = FirstSphere to LastSphere
MaintainVelocity(ID,20.0)
next ID
if spacekey() and timer() > mytimer then FlipBox(1)
phy update
SYNC
loop
Function FlipBox(ID)
if object visible(ID)
For i = ID to ID+5
hide object i
next i
else
For i = ID to ID+5
show object i
next i
endif
mytimer = timer() + 500
Endfunction
Function MaintainVelocity(ID,MinVelocity#)
x# = phy get rigid body linear velocity x(ID)
y# = phy get rigid body linear velocity y(ID)
z# = phy get rigid body linear velocity z(ID)
TotalVelocity# = abs(x#)+abs(y#)+Abs(z#)
If TotalVelocity# < MinVelocity#
phy add rigid body force ID, x#*MinVelocity#, y#*MinVelocity#,z#*MinVelocity#,0
endif
Endfunction
Function makebox(ID,x#,y#,z#,w#,xp#,yp#,zp#)
rem this function creates a total of 6 objects
rem floor
make object box ID, x#,w#,z# : position object ID,0+xp#,(-y#/2.0)+yp#,0+zp# : Phy make rigid body static box ID : ghost object on ID
Rem Ceiling
inc ID,1 : make object box ID, x#,w#,z# : position object ID,0+xp#,(y#/2.0)+yp#,0+zp# : Phy make rigid body static box ID : ghost object on ID
Rem Front Wall
inc ID,1 : make object box ID, x#,y#,w# : position object ID,0+xp#,0+yp#,(-z#/2.0)+zp# : Phy make rigid body static box ID : ghost object on ID
Rem Rear Wall
inc ID,1 : make object box ID, x#,y#,w# : position object ID,0+xp#,0+yp#,(z#/2.0)+zp# : Phy make rigid body static box ID : ghost object on ID
Rem Right Wall
inc ID,1 : make object box ID, w#,y#,z# : position object ID,(x#/2.0)+xp#,0+yp#,0+zp# : Phy make rigid body static box ID : ghost object on ID
Rem left Wall
inc ID,1 : make object box ID, w#,y#,z# : position object ID,(-x#/2.0)+xp#,0+yp#,0+zp# : Phy make rigid body static box ID : ghost object on ID
Endfunction
Hope you find it helpful
Codger
p.s. The material property you may wish to look at is "Restitution"
System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem