After much pain and struggle (of about 4 hours) I've come up with the code to find the normal of a face. It uses intersect object, so there are some limitations to its use (ie. you can't scale the object to which the face belongs).
Just type in the syntax as you would with intersect object, and the normal data will be stored in the second 3d vector, so to access it, you need to:
YourVariableX#=x vector(2)
YourVariableY#=y vector(2)
YourVariableZ#=z vector(2)
Put the following code at the beginning of the program:
make object cube 30,0
make object cube 31,0
make object cube 32,0
null = make vector3(1)
null = make vector3(2)
Put the following code with all your other functions or gosubs:
function normals(obj,x#,y#,z#,endx#,endy#,endz#)
position object 30,x#,y#,z#
point object 30,endx#,endy#,endz#
position object 31,object position x(30),object position y(30),object position z(30)
set object to object orientation 31,30
move object up 31,0.1
position object 32,object position x(30),object position y(30),object position z(30)
set object to object orientation 32,30
move object right 32,0.1
x1#=object position x(30)
x2#=object position x(31)
x3#=object position x(32)
y1#=object position y(30)
y2#=object position y(31)
y3#=object position y(32)
z1#=object position z(30)
z2#=object position z(31)
z3#=object position z(32)
set vector3 1,0,0,0
set vector3 2,0,0,0
set vector3 1,x2#-x1#,y2#-y1#,z2#-z1#
set vector3 2,x3#-x1#,y3#-y1#,z3#-z1#
col=0
for t=0 to 2
if t=0 then k#=intersect object(obj,object position x(30+t),object position y(30+t),object position z(30+t),endx#,endy#,endz#):dist#=k#
if t=1 then k#=intersect object(obj,object position x(30+t),object position y(30+t),object position z(30+t),endx#+x vector3(1),endy#+y vector3(1),endz#+z vector3(1))
if t=2 then k#=intersect object(obj,object position x(30+t),object position y(30+t),object position z(30+t),endx#+x vector3(2),endy#+y vector3(2),endz#+z vector3(2))
move object 30+t,k#
if k#>0 then col=col+1
next t
if col=3
x1#=object position x(30)
x2#=object position x(31)
x3#=object position x(32)
y1#=object position y(30)
y2#=object position y(31)
y3#=object position y(32)
z1#=object position z(30)
z2#=object position z(31)
z3#=object position z(32)
xvec1#=x2#-x1#
xvec2#=x3#-x1#
yvec1#=y2#-y1#
yvec2#=y3#-y1#
zvec1#=z2#-z1#
zvec2#=z3#-z1#
set vector3 1,xvec1#,yvec1#,zvec1#
set vector3 2,xvec2#,yvec2#,zvec2#
cross product vector3 2, 1, 2
normalize vector3 2,2
endif
endfunction dist#
NB: this function will return the distance between start point and collision point (the same as interect object).
http://www.nuclearglory.com/?i=453288050 , AMAZING COLLISION SYSTEM!