Here's a demo program that demonstrates "the jiggles"
global Character_Object = 1
Ground_Object = 2
Shelf_Object = 3
global Box_Object = 100
Ground_Material = 1
Shelf_Material = 2
global Max_Objects = 400
global Spawn_Time = 100
phy start
sync on
sync rate 60
set display mode 1024, 768, 32
randomize timer()
REM light source
make light 1
color light 1, 255, 255, 255
autocam off
phy set gravity 0, -100, 0
REM camera
set camera range 0.5, 30000
REM ground material
phy make material Ground_Material, "ground"
phy set material restitution Ground_Material, 0.3
phy build material Ground_Material
REM ground
make object plain Ground_Object, 30000, 30000
xrotate object Ground_Object, -90
set object diffuse Ground_Object, RGB(0, 0, 120)
phy make rigid body static box Ground_Object, Ground_Material
REM shelf material
phy make material Shelf_Material, "shelf"
REM phy set material dynamic friction 25, 1.0
phy set material static friction Shelf_Material, 0.0
phy set material restitution Shelf_Material, 0.1
phy build material Shelf_Material
REM titled shelf
make object box Shelf_Object, 160, 10, 100
position object Shelf_Object, 0, 30, 0
xrotate object Shelf_Object, -30
set object diffuse Shelf_Object, RGB(255, 255, 128)
phy make rigid body static box Shelf_Object, Shelf_Material
REM box controller
make object box Character_Object, 20, 20, 20
phy make box character controller Character_Object, 30, 60, -250, 10, 35, 10, 1, 10.5, 45.0
hide object Character_Object
phy set auto fixed timing
global start = timer()
global counter = 0
global camx#, camy#, oldcamx#, oldcamy#
do
text 10, 10, "FPS: " + STR$(screen fps())
text 10, 30, "Count: " + STR$(counter)
MovePlayer()
SpawnBoxes()
text 10, 50, "Sleeping: " + STR$(SleepingBoxes())
phy update
sync
loop
function MovePlayer()
position camera object position x(Character_Object), object position y(Character_Object) + 10, object position z(Character_Object)
rotate camera object angle x(Character_Object), object angle y(Character_Object), object angle z(Character_Object)
oldcamx# = camx#
oldcamy# = camy#
camx# = wrapvalue( camx# + mousemovey() * 0.4 )
camy# = wrapvalue( camy# + mousemovex() * 0.4 )
xrotate object Character_Object, curveangle( camx#, oldcamx#, 24 )
yrotate object Character_Object, curveangle( camy#, oldcamy#, 24 )
key = 0
if upkey()
key = 1
phy move character controller Character_Object, 200.0
endif
if downkey()
key = 1
phy move character controller Character_Object, -200.0
endif
if key = 0 then phy move character controller Character_Object, 0.0
endfunction
function SpawnBoxes()
now = timer()
if (now - start > Spawn_Time) and (counter < Max_Objects)
sx = rnd(20) + 2
sy = rnd(20) + 2
sz = rnd(20) + 2
make object box Box_Object + counter, sx, sy, sz
position object Box_Object + counter, 50 - rnd(100), 200, 50 - rnd(100)
set object diffuse Box_Object + counter, RGB(64 + rnd(192), 64 + rnd(192), 64 + rnd(192))
rem set object specular 40 + counter, RGB( 255, 255, 255 )
rem set object specular power 40 + counter, 1.0
phy make rigid body dynamic box Box_Object + counter
phy set rigid body mass Box_Object + counter, (sx * sx + sy * sy + sz * sz) * 10
REM Treacle mode
REM phy set rigid body linear damping Box_Object + counter, 10.0
REM phy set rigid body angular damping Box_Object + counter, 10.0
start = now
inc counter
endif
endfunction
function SleepingBoxes()
count = 0
for i = 0 to counter
if phy get rigid body sleeping(Box_Object + i) = 1 then inc count
next
endfunction count
After it finishes creating all four hundred boxes, take a look by wandering around the scene at isolated boxes on their own. They're probably "jiggling", i.e. never completely coming to a rest.
I tried linear/angular damping but no real effect, it still jiggles. My SleepingBoxes function seems to show no boxes are sleeping.
Also, if you watch, some thin boxes hurtle through the floor never to be seen again. I'll see if
fixes this.
"Reality Bites"