First of all, thank you all for answering. Now let's see...
@ Shiny Edge Studios
Quote: "phy make rigid body dynamic spheres doesn't exist. it's sphere, box, capsule, convex, mesh as the last words in the command..."
Actually you're wrong. There are plural versions of all of them, but i only got the boxes one working, as you can see in the code below.
@ Kendor
Quote: "Out of curiosity, why are you using the plural instead of the singular?"
I don't like to use joints to setup complex models, they look too unstable. Look at the code below, it's a modified version of the Dark Physics chair joints demo. In my version the chairs look a lot more stable (I removed the needed media so other people could easily run the code).
@ BatVink and kaedroho
That's great! But as you can see in the code, i already use limbs, and still can't make the spheres version work.
My main goal is to use dynamic boxes as a character controller (a motorcycle), but when i use boxes it keeps bumping at the smallest obstacle in the way. I think i may have better results using spheres to compose the collision model, so if you could show me some code using the "phy make rigid body spheres" i would really appreciate. Here's my modified version of the chair demo:
` a collection of chairs that are constructed with boxes
` and then attached using joints
` prepare the program
autocam off
sync on
sync rate 60
hide mouse
randomize timer ( )
make light 1
set directional light 1, -5, -5, 5
position camera 0.0,30.0,-74.0
point camera 0.0,15.0,0.0
phy start
phy set gravity 0.0,-28.0,0.0
`make a physics material for the objects
phy make material 1, "wooden"
phy set material static friction 1, 25.0
phy set material restitution 1, 0.0
phy set material dynamic friction 1, 1.0
phy build material 1
`make the ground from a box
make object box 2, 150, 2, 150
position object 2, 0, -1, 0
color object 2,rgb(100,163,163)
phy make rigid body static box 2,1
make object box 3,150,100,2
position object 3,0,50,76
color object 3,rgb(100,163,163)
phy make rigid body static box 3,1
make object box 4,2,100,150
position object 4,-76,50,0
color object 4,rgb(100,163,163)
phy make rigid body static box 4,1
make object box 5,2,100,150
position object 5,76,50,0
color object 5,rgb(100,163,163)
phy make rigid body static box 5,1
make object box 6,150,100,2
position object 6,0,50,-76
color object 6,rgb(100,163,163)
phy make rigid body static box 6,1
`prepare the variables for creating chairs
make_chair_model()
create_chair(-15.0,-15.0,0.0,10)
create_chair(15.0,-15.0,0.0,20)
create_chair(-15.0,15.0,0.0,30)
create_chair(15.0,15.0,0.0,40)
create_chair(-30.0,-15.0,0.0,50)
create_chair(30.0,-15.0,0.0,60)
create_chair(-30.0,15.0,0.0,70)
create_chair(30.0,15.0,0.0,80)
create_chair(-45.0,-15.0,0.0,90)
create_chair(45.0,-15.0,0.0,100)
create_chair(-45.0,15.0,0.0,110)
create_chair(45.0,15.0,0.0,120)
create_chair(-45.0,-30.0,0.0,130)
create_chair(45.0,-30.0,0.0,140)
create_chair(-45.0,30.0,0.0,150)
create_chair(45.0,30.0,0.0,160)
create_chair(-30.0,-30.0,0.0,170)
create_chair(30.0,-30.0,0.0,180)
create_chair(-30.0,30.0,0.0,190)
create_chair(30.0,30.0,0.0,200)
create_chair(-15.0,-30.0,0.0,210)
create_chair(15.0,-30.0,0.0,220)
create_chair(-15.0,30.0,0.0,230)
create_chair(15.0,30.0,0.0,240)
` main program loop
do
` display instructions
set cursor 0, 0
print "A collection of chairs built using joints"
print "Press the arrow keys and space to apply velocity to them"
` apply velocity based on key presses
if upkey() = 1
for j = 1 to 24
phy set rigid body linear velocity j*10,0.0,0.0,50.0
next j
endif
if downkey() = 1
for j = 1 to 24
phy set rigid body linear velocity j*10,0.0,0.0,-50.0
next j
endif
if leftkey() = 1
for j = 1 to 24
phy set rigid body linear velocity j*10,-50.0,0.0,0.0
next j
endif
if rightkey() = 1
for j = 1 to 24
phy set rigid body linear velocity j*10,50.0,0.0,0.0
next j
endif
if spacekey() = 1
for j = 1 to 24
phy set rigid body angular velocity j*10,rnd(20.0)-10.0,50.0,rnd(20.0)-10.0
phy set rigid body linear velocity j*10,rnd(20.0)-10.0,50.0,rnd(20.0)-10.0
next j
endif
rotate object 2, object angle x ( 2 ) + 0.1, object angle y( 2 ) - 0.5, object angle z ( 2 ) + 0.3
` update the simulation and screen
phy update
sync
loop
function make_chair_model()
make object box 7,11.0,1.0,11.0
make object box 8,1.0,10.0,1.0
make mesh from object 1,8
add limb 7,1,1
offset limb 7,1,-5,-5.5,5
color limb 7,1,rgb(10,10,64)
delete mesh 1
delete object 8
make object box 8,1.0,10.0,1.0
make mesh from object 1,8
add limb 7,2,1
offset limb 7,2,5,-5.5,5
color limb 7,2,rgb(10,10,64)
delete mesh 1
delete object 8
make object box 8,1.0,10.0,1.0
make mesh from object 1,8
add limb 7,3,1
offset limb 7,3,-5,-5.5,-5
color limb 7,3,rgb(10,10,64)
delete mesh 1
delete object 8
make object box 8,1.0,10.0,1.0
make mesh from object 1,8
add limb 7,4,1
offset limb 7,4,5,-5.5,-5
color limb 7,4,rgb(10,10,64)
delete mesh 1
delete object 8
make object box 8,1.0,10.0,1.0
make mesh from object 1,8
add limb 7,5,1
offset limb 7,5,5,5.5,5
color limb 7,5,rgb(10,10,64)
delete mesh 1
delete object 8
make object box 8,1.0,10.0,1.0
make mesh from object 1,8
add limb 7,6,1
offset limb 7,6,-5,5.5,5
color limb 7,6,rgb(10,10,64)
delete mesh 1
delete object 8
make object box 8,11.0-2.0,4.0,1.0
make mesh from object 1,8
add limb 7,7,1
offset limb 7,7,0,7.5,5
delete mesh 1
delete object 8
set object specular 7,rgb(255,255,255)
set object specular power 7,100
set object smoothing 7,68.0
hide object 7
endfunction
function create_chair(xPos#,zPos#,yPos#,first_obj)
col_r = rnd(254)
col_g = rnd(254)
col_b = rnd(254)
clone object first_obj,7
color limb first_obj,0,rgb(col_r,col_g,col_b)
color limb first_obj,7,rgb(col_r,col_g,col_b)
phy make rigid body dynamic boxes first_obj,1
phy set rigid body position first_obj,xPos#,yPos#+10.5,zPos#
endfunction