in fact...these function are 2d... sorry
see that:
sync on
d#=rnd(4)+1
Ay#=wrapvalue(Rnd(360))
X1#=0
Z1#=0
X2#=0
Z2#=0
do
X1#=NewXValue(x1#,ay#,d#)
Z1#=NewzValue(z1#,ay#,d#)
X2#=XValue(x2#,ay#,d#)
Z2#=ZValue(z2#,ay#,d#)
cls
print "---DB Functions---"
Print "X#=",X1#
Print "Z#=",Z1#
print "---My Functions---"
Print "X#=",X2#
Print "Z#=",Z2#
sync
loop
end
rem my OWN NEWXZVALUE....
function Xvalue(x#,y_angle#,distance#)
NewX#=x#+(Distance#)*sin(y_angle#)
endfunction NewX#
function Zvalue(z#,y_angle#,distance#)
Newz#=z#+(Distance#)*cos(y_angle#)
endfunction Newz#
my functions..is EXACTLY the same thing..and this is for 2D.. it just take the distance..and decompose it in X and Z ..and add it to the original X and Z ...you cant use..it for 3D ..you should do some other ..math if you want to use XYZ ..at the same time..
but to move in 3d World..when your matrix..is not flat you need to do something like that:
sync on
sync rate 0
draw to front
create bitmap 1,1024,1024
ink rgb(100,0,0),0
box 0,0,512,512
ink rgb(0,100,0),0
box 512,0,1023,512
ink rgb(0,0,100),0
box 0,512,512,1023
ink rgb(0,0,0),0
box 512,512,1023,1023
get image 1,0,0,1024,1024
delete bitmap 1
make matrix 1,50000,50000,70,70
prepare matrix texture 1,1,1,1
fill matrix 1,0,0
for i=1 to 70
for j=1 to 70
set matrix height 1,i,j,rnd(1000)
next j
next i
update matrix 1
make object sphere 1,75
set object rotation ZYX 1
x#=25000
z#=25000
y#=get ground height(1,x#,z#)
ink rgb(255,255,255),0
do
oldX#=x#
oldZ#=z#
oldy#=y#
if leftkey()=1 then ay#=wrapvalue(ay#-1)
if rightkey()=1 then ay#=wrapvalue(ay#+1)
if upkey()=1 then x#=x#+XValue(x#,z#,ay#,5.0):y#=y#+yValue(x#,z#,ay#,5.0):z#=z#+zValue(x#,z#,ay#,5.0):xrotate object 1,wrapvalue(object angle x(1)+5)
yrotate object 1,ay#
position object 1,x#,y#+35,z#
position camera x#,y#,z#
rotate camera 25,ay#,0
move camera -250
if camera position y()<get ground height(1,camera position x(),camera position z() ) then position camera camera position x(),get ground height(1,camera position x(),camera position z() )+10,camera position z():point camera x#,y#,z#
set cursor 0,0
Print "3D distance between last loop (it should be 5)=",sqrt((x#-oldx#)^2+(z#-oldz#)^2+(y#-oldy#)^2)
sync
loop
end
rem my OWN 3d movement function
function Xvalue(x#,z#,ay#,L#)
zf#=(L#)*cos(ay#)
xf#=(L#)*sin(ay#)
lxzf#=sqrt(xf#^2.0+zf#^2.0)
yf#=get ground height(1,x#+xf#,z#+zf#)-get ground height(1,x#,z#)
ax#=(atan(yf#/lxzf#))
y2#=l#*sin(ax#)
lxz#=l#*cos(ax#)
x2#=lxz#*sin(ay#)
z2#=lxz#*cos(ay#)
endfunction x2#
function Yvalue(x#,z#,ay#,L#)
zf#=l#*cos(ay#)
xf#=l#*sin(ay#)
yf#=get ground height(1,x#+xf#,z#+zf#)-get ground height(1,x#,z#)
lxzf#=sqrt(xf#^2+zf#^2)
ax#=(atan(yf#/lxzf#))
y2#=l#*sin(ax#)
lxz#=l#*cos(ax#)
x2#=lxz#*sin(ay#)
z2#=lxz#*cos(ay#)
endfunction y2#
function Zvalue(x#,z#,ay#,L#)
zf#=l#*cos(ay#)
xf#=l#*sin(ay#)
yf#=get ground height(1,x#+xf#,z#+zf#)-get ground height(1,x#,z#)
lxzf#=sqrt(xf#^2+zf#^2)
ax#=(atan(yf#/lxzf#))
y2#=l#*sin(ax#)
lxz#=l#*cos(ax#)
x2#=lxz#*sin(ay#)
z2#=lxz#*cos(ay#)
endfunction z2#
i know...its the 3 same function...but with diffrent result...i could put another parameter to say wich ...value i want into the result..but..
and see the .."print"...it print the 3d distance between ..last loop......and its sopposed to be 5...and its ALMOST ..always 5..im precise..at 0.001 even more..
then IM THE KING OF 3D
i hope it will help you...
if you have any comment.......say it