Why hurt your brain trying to figure out the math when you have the GLUE OBJECT TO LIMB command!
Ok, ok, I admit this will eventually grind to a halt, but it's fun while it lasts!
btw.. this should work in DBP and DBC.
objid=1
rem the main object
make object cube objid, 100
scale object objid,50,50,50
autocam off
sync on
sync rate 0
do
if spacekey()=1
rem randomly rotate the cube
rotate object 1, rnd(359), rnd(359), rnd(359)
unglue object 1
for i = 2 to objid
delete object i
next i
objid=1
endif
rem handle pitch
if upkey()=1
if axis<>1
inc objid
make object triangle objid,0,0,0,0,0,0,0,0,0
hide limb objid,0
glue object to limb objid-1,objid,0
endif
pitch object down objid,.3
axis=1
else
if downkey()=1
if axis<>1
inc objid
make object triangle objid,0,0,0,0,0,0,0,0,0
hide limb objid,0
glue object to limb objid-1,objid,0
endif
pitch object up objid,.3
axis=1
else
rem handle turn
if leftkey()=1
if axis<>2
inc objid
make object triangle objid,0,0,0,0,0,0,0,0,0
hide limb objid,0
glue object to limb objid-1,objid,0
endif
turn object right objid,.3
axis=2
else
if rightkey()=1
if axis<>2
inc objid
make object triangle objid,0,0,0,0,0,0,0,0,0
hide limb objid,0
glue object to limb objid-1,objid,0
endif
turn object left objid,.3
axis=2
else
rem handle roll
if shiftkey()=1
if axis<>3
inc objid
make object triangle objid,0,0,0,0,0,0,0,0,0
hide limb objid,0
glue object to limb objid-1,objid,0
endif
roll object left objid,.3
axis=3
else
if controlkey()=1
if axis<>3
inc objid
make object triangle objid,0,0,0,0,0,0,0,0,0
hide limb objid,0
glue object to limb objid-1,objid,0
endif
roll object right objid,.3
axis=3
endif
endif
endif
endif
endif
endif
set cursor 0,0
ink 0,0
print "Use the arrow keys to pitch and turn the object"
print "Use the SHIFT and CTRL to roll the object"
print "Hit SPACEBAR to randomly rotate the object and reset"
sync
loop