another use, using < rotate the object and watch the other object rise and fall.
Rem Project: Pulley Joints
Rem Created: 02/07/2008 15:39:20
Rem ***** Main Source File *****
phy start
sync on
sync rate 0
autocam off
position camera 0,0,0,-150
box1=1
box2=2
rem floor
make object box 10,100,1,100
position object 10,0,-50,0
phy make rigid body static box 10
size_box_0=100/2
rem make first box1
make object box box1, 1,30,1
color object box1,rgb(255,0,0)
position object box1,-15,-3,0
phy make rigid body dynamic box box1
phy set rigid body kinematic box1,1
PHY SET RIGID BODY LINEAR DAMPING box1, 1.5
size_box_1=30/2
rem make second box2
make object cone box2, 10
position object box2,15,0,0
Phy make rigid body dynamic box box2
PHY SET RIGID BODY LINEAR DAMPING box2, 1.5
`phy set rigid body mass box2,40000
box_1=0
box_2=1
phy make pulley joint 1,box1,box2
local_anchor_0=15
local_anchor_1=5
Joint_suspension_0=9
joint_suspension_1=59
joint_suspension_x0=-15
joint_suspension_x1=15
rem position on box1
PHY SET PULLEY JOINT LOCAL ANCHOR 1, box_1, 0, local_anchor_0, 0
rem position on box2
PHY SET PULLEY JOINT LOCAL ANCHOR 1, box_2, 0,local_anchor_1, 0
rem position above box1
PHY SET PULLEY JOINT SUSPENSION 1, box_1,joint_suspension_x0, joint_suspension_0, 0
rem position above box2
PHY SET PULLEY JOINT SUSPENSION 1, box_2, joint_suspension_x1, Joint_suspension_1, 0
rem ?
PHY SET PULLEY JOINT STIFFNESS 1, 1.0
rem lenght need form one point to other point
`PHY SET PULLEY JOINT DISTANCE 1, 48 :rem distance is width between -15 and 15 = 30 plus length of local anchor 9+9=18 + 30 = 48
PHY SET PULLEY JOINT DISTANCE 1,Joint_suspension_0+Joint_suspension_0+joint_suspension_x0j+oint_suspension_x1+size_box_0+size_box_1
rem ratio
PHY SET PULLEY JOINT RATIO 1,1.0
rem motor
`phy set pulley joint motor 1,1
rem enables min distance for anchor point.
PHY SET PULLEY JOINT RIGID 1,1
phy build pulley joint 1
rem make object to mark SUSPENSION joint
make object cylinder 3,1
position object 3,-15,joint_suspension_0,0
make object cylinder 4,1
position object 4,15, Joint_suspension_1,0
do
text 0,0,str$(cursorobj)
text object screen x(3)-190,object screen y(3)-8,"Suspension point box1 >"
text object screen x(4)+10,object screen y(4)-8,"< Suspension point box2"
text object screen x(1)-160,object screen y(1)-16-local_anchor_0,"Local Anchor box1 >"
text object screen x(2)+4,object screen y(2)-16-local_anchor_1,"< Local anchor box2"
line object screen x(1),object screen y(1)-10,object screen x(3),object screen y(3)
line object screen x(2),object screen y(2)-10,object screen x(4),object screen y(4)
line object screen x(3),object screen y(3),object screen x(4),object screen y(4)
gosub _drag_object
control camera using arrowkeys 0,.1,.1
if inkey$()=","
inc x#,.1
PHY SET RIGID BODY KINEMATIC ROTATION box1, 0, -3,x#
phy set pulley joint global anchor 1,box1,0,5,x#
phy set pulley joint global anchor 1,box2,0,5,x#
endif
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(),1,11)
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
return
Dark Physics makes any hot drink go cold.