sync on
sync rate 0
autocam on
color backdrop 0,0
set physics frame rate 80
resX=16
resY=16
make cloth 1
generate rectangular cloth 1,10,10,resX,resY,1
fix cloth point 1,0
fix cloth point 1,resX
fix cloth point 1,get number of cloth points(1)-resX
fix cloth point 1,get number of cloth points(1)-1
make object sphere 2,5
make collision sphere 3
set collision sphere 3,2.7
bind collider to object 3,1
position object 3,object position x(2),object position y(2)+20,object position z(2)
CLOTH_MASS#=1.0
CLOTH_ELASTICITY#=1.0
autocam off
do
control camera using arrowkeys 0,0.5,0.5
CamX# = CamX# + mousemovey()/2.0 : CamY# = CamY# + mousemovex()/2.0 : CamZ# = CamZ# + mousemovez()/2.0
rotate camera CamX#,CamY#,CamZ#
text 10,10,"FPS: " + str$(screen fps())
text 10,20,"POLY: " + str$(statistic(1))
text 10,30,"CLOTH POINTS: " + str$(get number of cloth points(1))
text 10,40,"CLOTH MASS: " + str$(CLOTH_MASS#)
text 10,50,"CLOTH ELASTICITY: " + str$(CLOTH_ELASTICITY#)
if lower$(inkey$())="w" then move object up 2,0.1
if lower$(inkey$())="s" then move object down 2,0.1
if lower$(inkey$())="a" then move object left 2,0.1
if lower$(inkey$())="d" then move object right 2,0.1
if lower$(inkey$())="r" then CLOTH_MASS#=CLOTH_MASS#+0.1 : set cloth mass 1,CLOTH_MASS#
if lower$(inkey$())="f"
if CLOTH_MASS#-0.1>1
CLOTH_MASS#=CLOTH_MASS#-0.1
set cloth mass 1,CLOTH_MASS#
endif
endif
if lower$(inkey$())="t" then CLOTH_ELASTICITY#=CLOTH_ELASTICITY#+0.1 : set cloth elasticity 1,CLOTH_ELASTICITY#
if lower$(inkey$())="g"
if CLOTH_ELASTICITY#-0.1>1
CLOTH_ELASTICITY#=CLOTH_ELASTICITY#-0.1
set cloth elasticity 1,CLOTH_ELASTICITY#
endif
endif
if controlkey()=1 then freeze cloth 1,1
if shiftkey()=1 then freeze cloth 1,0
if spacekey()=1
if file exist("Cloth.clt")=1 then delete file "Cloth.clt"
save cloth state 1,"Cloth"
endif
if returnkey()=1
if file exist("Cloth.clt")=1
delete cloth 1
make cloth 1
load cloth state 1,"Cloth.clt",1
bind collider to object 3,1
endif
endif
position object 3,object position x(2),object position y(2),object position z(2)
update physics
sync
loop
Use WASD keys to position collider sphere, ARROWKEYS to move the camera. See teh code for other keys...
Have fun coding!
"Gangsters die, they don't go to heaven where angels fly!"
AMD Sempron 3.1+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP SP2, DirectX 9.0c