This is Evolved's automap, it contains matrix math, you can used math just as is.
The code checks object normal vector. In your case you just need to use your three vectors (axis) instead of normals.
Vectors, as angles, are: 0.0 for 0* ... 0.5 for 90* ... 1.0 for 180* (I suppose).
`====================================================
` Auto UV mapping function example
`====================================================
` By EVOLVED
` www.evolved-software.com
`====================================================
`Set Up Display
Sw=1024:Sh=768
set display mode Sw,Sh,32,1
sync on : sync rate 0
hide mouse
`Set Text
set text font "Verdana"
set text size 15
set text to bold
ink rgb(200,200,0),0
`Setup Camera
autocam off
color backdrop rgb(128,128,128)
position camera 0,0,-150
set camera fov 85
xrotate camera 30
CamDis#=-100
`Make object
load image "brick1.dds",1
make object box 1,75,75,75
texture object 1,1
AutoUVMapping(1,0,0,256,256,5,5,0,0)
`Start loop
do
`Control Camera
position camera 0,0,0
if mouseclick()=0
xrotate camera camera angle x()-mousemovey()*0.25
yrotate camera camera angle y()+mousemovex()*0.25
if camera angle x()>80 then xrotate camera 80
if camera angle x()<-60 then xrotate camera -60
endif
if mouseclick()>0 then CamDis#=CamDis#-mousemovey()*0.25
CamDis#=CamDis#+mousemovez()*0.25
if upkey()=1 then CamDis#=CamDis#+2.5
if downkey()=1 then CamDis#=CamDis#-2.5
if CamDis#>-20 then CamDis#=-20
if CamDis#<-300 then CamDis#=-300
move camera CamDis#
if camera position y()<-60 then position camera camera position x(),-60,camera position z()
mousemovex()=0
mousemovey()=0
`Rotate object
if KEYSTATE(19)=1 and rotate=1 and nopress=0 then rotate=0:nopress=1
if KEYSTATE(19)=1 and rotate=0 and nopress=0 then rotate=1:nopress=1
if rotate=0
rotate object 1,0,object angle y(1)+1,0
endif
`Apply UV map
if spacekey()=1 then AutoUVMapping(1,0,0,256,256,5,5,0,0)
if scancode()=0 then nopress=0
`Text
center text sw/2,40,"FPS "+str$(screen fps())
`Sync Loop
sync
loop
`--------------
` Auto UV Mapping Geometry
`--------------
function AutoUVMapping(obj,lm,stage,TSizex#,TSizey#,ScaleU#,ScaleV#,ScrollU#,ScrollV#)
Null=make matrix4(1)
Null=make matrix4(2)
Null=make matrix4(3)
Null=make matrix4(4)
Null=make vector3(5)
rotate x matrix4 1,(-object angle x(obj)*0.0174532778)+(-limb angle x(obj,lm)*0.0174532778)
rotate y matrix4 2,(-object angle y(obj)*0.0174532778)+(-limb angle y(obj,lm)*0.0174532778)
rotate z matrix4 3,(-object angle z(obj)*0.0174532778)+(-limb angle z(obj,lm)*0.0174532778)
multiply matrix4 4,1,2
multiply matrix4 4,4,3
scale matrix4 1,(object size x(obj,1)/object size x(obj))*(limb scale x(obj,lm)/100),(object size y(obj,1)/object size y(obj))*(limb scale y(obj,lm)/100),(object size z(obj,1)/object size z(obj))*(limb scale z(obj,lm)/100)
multiply matrix4 4,4,1
transpose matrix4 4,4
translate matrix4 1,object position x(obj)+limb offset x(obj,lm),object position y(obj)+limb offset y(obj,lm),object position z(obj)+limb offset z(obj,lm)
multiply matrix4 4,4,1
lock vertexdata for limb obj,lm
for v =0 to get vertexdata vertex count()-1
set vector3 5,get vertexdata normals x(v),get vertexdata normals y(v),get vertexdata normals z(v)
transform normals vector3 5,5,4
normalize vector3 5,5
UvProj=0
if z vector3(5)>0.49 then UvProj=1
if z vector3(5)<-0.49 then UvProj=2
if x vector3(5)>0.49 then UvProj=3
if x vector3(5)<-0.49 then UvProj=4
if y vector3(5)>0.49 then UvProj=5
if y vector3(5)<-0.49 then UvProj=5
set vector3 5,get vertexdata position x(v),get vertexdata position y(v),get vertexdata position z(v)
transform coords vector3 5,5,4
select UvProj
case 1
U#=(x vector3(5)+ScrollU#)/TSizex#
V#=(y vector3(5)+ScrollV#)/TSizey#
endcase
case 2
U#=-(x vector3(5)+ScrollU#)/TSizex#
V#=(y vector3(5)+ScrollV#)/TSizey#
endcase
case 3
U#=-(z vector3(5)+ScrollU#)/TSizex#
V#=(y vector3(5)+ScrollV#)/TSizey#
endcase
case 4
U#=(z vector3(5)+ScrollU#)/TSizex#
V#=(y vector3(5)+ScrollV#)/TSizey#
endcase
case 5
U#=(z vector3(5)+ScrollU#)/TSizex#
V#=(x vector3(5)+ScrollV#)/TSizey#
endcase
endselect
set vertexdata uv v,stage,-U#*ScaleU#,-V#*ScaleV#
next v
unlock vertexdata
Null=delete matrix4(1)
Null=delete matrix4(2)
Null=delete matrix4(3)
Null=delete matrix4(4)
Null=delete vector3(5)
endfunction
*** Merry Chuckmas! ***