Hi All,
Here are the basic bits to making a Newtons Cradle, press the spacebar to launch the sphere in motion.
also found out that the twist and swing use something called Decomposition in Quaternion Components.
http://en.wikipedia.org/wiki/Quaternion for more info.
Rem Project: NewtonsCradle
Rem Created: 18/03/2009 13:17:24
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
phy enable debug
position camera 0,20,-30
point camera 0,0,0
phy start
motion_locked=0
x=1
for i=1 to 5
make object sphere i,1
position object i,-5+x,0,0
phy make rigid body dynamic sphere i
inc x,1
next i
x=1
for i=1 to 5
make object sphere 5+i,1
position object 5+i,-5+x,8,5
phy make rigid body static sphere 5+i
make object sphere 10+i,1
position object 10+i,-5+x,8,-5
phy make rigid body static sphere 10+i
inc x,1
next i
jointid=1
f=1
for i=6 to 10
PHY MAKE SPHERE JOINT jointID, f,i, object position x(i),object position y(i),object position z(i)
PHY SET SPHERE JOINT GLOBAL ANCHOR jointID, 0, object position x(i),object position y(i),object position z(i)
rem Twist and Swing Decomposition in Quaternion Components
PHY SET SPHERE JOINT SWING LIMIT jointID, 0.3*3.14, 0, 0
PHY SET SPHERE JOINT TWIST LIMIT jointID, -0.3*3.14, 0.3*3.14
PHY BUILD SPHERE JOINT jointID
inc f
inc jointid,1
next i
f=1
for i=11 to 15
PHY MAKE SPHERE JOINT jointID, f,i, object position x(i),object position y(i),object position z(i)
PHY SET SPHERE JOINT GLOBAL ANCHOR jointID, 0,object position x(i),object position y(i),object position z(i)
rem Twist and Swing Decomposition in Quaternion Components
PHY SET SPHERE JOINT SWING LIMIT jointID, 0.3*3.14, 0, 0
PHY SET SPHERE JOINT TWIST LIMIT jointID, -0.3*3.14, 0.3*3.14
PHY BUILD SPHERE JOINT jointID
inc f
inc jointid,1
next i
do
if spacekey()=1
phy add rigid body force 5, 75, 0, 0, 0
endif
phy update
sync
loop
Dark Physics makes any hot drink go cold.