basically, rotation matrices. Without getting into the math:
x#=cos(xrot)*cos(zrot)*sin(yrot)+sin(xrot)*sin(zrot)
y#=cos(xrot)*sin(zrot)*sin(yrot)-sin(xrot)*cos(zrot)
z#=cos(xrot)*cos(yrot)
ex:
make object box 1,0.3,0.3,2
position object 1,0,0,0
color object 1,rgb(0,255,255)
make object sphere 2,0.4
position object 2,0,0,1
color object 2,rgb(0,255,255)
make object box 3,0.05,10,0.05
position object 3,0,0,0
color object 3,rgb(0,255,0)
make object box 4,10,0.05,0.05
position object 4,0,0,0
color object 4,rgb(255,0,0)
make object box 5,0.05,0.05,10
position object 5,0,0,0
color object 5,rgb(0,0,255)
xrot as float
yrot as float
zrot as float
do
if keystate(2)
if upkey() then inc xrot,0.1
if downkey()then dec xrot,0.1
Endif
if keystate(3)
if upkey() then inc yrot,0.1
if downkey()then dec yrot,0.1
Endif
if keystate(4)
if upkey() then inc zrot,0.1
if downkey() then dec zrot,0.1
Endif
rotate object 1,xrot,yrot,zrot
x#=cos(xrot)*cos(zrot)*sin(yrot)+sin(xrot)*sin(zrot)
y#=cos(xrot)*sin(zrot)*sin(yrot)-sin(xrot)*cos(zrot)
z#=cos(xrot)*cos(yrot)
position object 2,x#,y#,z#
text 0,0,"Xrot: "+str$(xrot)
text 0,16,"Yrot: "+str$(yrot)
text 0,32,"Zrot: "+str$(zrot)
sync
Loop
You could also calculate everything using the matrix4 commands, and honestly it would probably a lot faster to do so... but I remember having lots of problems with those in the past. I think I posted a response to someone's thread that used matrix4s to do what you're doing, but it took me a while to figure it out.
Basically, what you see there is the result of this matrix:
http://www.freeimagehosting.net/uploads/3b4c8dfbe1.png
multiplied by
[0]
[0]
[1]
that big matrix though, it the result of the matrices of the Z rotation times Y rotation times X rotation. basically, where that 0,0,1 matrix = V,
[x]
[y] = Z*Y*X*V
[z]