Hi All
give this ago its a made up object and by just tilting just a little you can see it rock with a flat surface.
Rem Project: rocky1
Rem Created: 04/06/2008 14:48:14
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
position camera 0,0,0,-15
phy start
make object box 1,105,1,105
position object 1,0,-3,0
phy make rigid body static box 1
make object sphere 2,5
make object box 3,5,1,5
make mesh from object 1,2
make mesh from object 2,3
add limb 2,1,2
delete object 3
offset limb 2,1,0,-2.5,0
make mesh from object 3, 2
delete object 2
make object 2,3,0
rem doing this bit changes the camera position????????????
phy make rigid body dynamic sphere 2
phy set rigid body mass offset local 2, 0.0, -2.0, 0.0
do
text 0,0,"using the right mouse click button slowly tilt"
text 0,12,"the object a very small amout and whatch it rock"
control camera using arrowkeys 0,.1,.1
gosub _drag_object
phy update
sync
loop
_drag_object:
if mouseclick()=0 then pickmode=0 : cursorobj=0
mclick=mouseclick()
if mclick>0
if pickmode=0
cursorobj=pick object(mousex(),mousey(),2,3)
if cursorobj>0
pickmode=mclick
pickdistance#=get pick distance()
pickfromx#=get pick vector x()
pickfromy#=get pick vector y()
pickfromz#=get pick vector z()
if pickmode=1
objx#=object position x(cursorobj)
objy#=object position y(cursorobj)
objz#=object position z(cursorobj)
else
objx#=object angle x(cursorobj)
objy#=object angle y(cursorobj)
objz#=object angle z(cursorobj)
pickdiffx#=mousemovey() : pickdiffx#=0
pickdiffy#=mousemovex() : pickdiffy#=0
endif
else
highlightobj=0
endif
endif
if pickmode>0
if pickmode=1
pick screen mousex(),mousey(),pickdistance#
picktox#=get pick vector x()
picktoy#=get pick vector y()
picktoz#=get pick vector z()
pickdiffx#=picktox#-pickfromx#
pickdiffy#=picktoy#-pickfromy#
pickdiffz#=picktoz#-pickfromz#
grid=0
if grid=1
pickdiffx#=int(pickdiffx#/5)*5
pickdiffy#=int(pickdiffy#/5)*5
pickdiffz#=int(pickdiffz#/5)*5
endif
`position object cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
phy set rigid body position cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
else
pickdiffx#=pickdiffx#+mousemovey()
pickdiffy#=pickdiffy#+mousemovex()
grid=0
if grid=1
tpickdiffx#=int(pickdiffx#/22.5)*22.5
tpickdiffy#=int(pickdiffy#/22.5)*22.5
else
tpickdiffx#=pickdiffx#
tpickdiffy#=pickdiffy#
endif
` rotate object cursorobj,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
phy set rigid body rotation cursorobj,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
endif
endif
endif
phy update
return
Dark Physics makes any hot drink go cold.