And by adding one more command we can get it to throw the object.
set rigid body position cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
phy set rigid body linear velocity cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
Working code.
Rem Project: phypickobject1
Rem Created: 10/08/2006 04:38:53
phy start
sync on
sync rate 0
autocam off
color backdrop 0
make light 1
set directional light 1, -5, -5, 5
position camera -20, 20, -25
point camera 0, 10, 0
make object box 1, 1000, 1, 1000
color object 1,RGB(0,128,128)
phy make rigid body static box 1
make object box 2,5,2,1
phy make rigid body dynamic box 2
phy set rigid body mass 2,1
phy set rigid body linear velocity 2,0,0.1,0
Rem ***** Main Source File *****
do
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,2)
text 0,0,"object = "+str$(cursorobj):sync
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
phy set rigid body position cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
phy set rigid body linear velocity cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
`position object 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#
rotate camera 0,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
endif
endif
endif
return
I'm not getting you down am I, Ho Look! another fancy Door?