So let me get this straight - You have a bullet shell object. It's center of rotation is at <0,0,0>, and it's rotated some arbitrary amount. right?
As you can see here:
make object box 1,.1,.1,1
position object 1,0,0,00
yrotate object 1,rnd(360)
zrotate object 1,rnd(360)
ShellW#=Cos(Object angle Z(1))
ShellH#=Sin(Object angle Z(1))
ShellL#=Sin(Object angle Y(1))
make object sphere 2,.3
position object 2, shellw#,shellh#,shellL#
do
yrotate object 1,object angle y(1)+mousemovex()
xrotate object 1, object angle x(1)+mousemovey()
ShellW#=Cos(Object angle Z(1))
ShellH#=Sin(Object angle Z(1))
ShellL#=Sin(Object angle Y(1))
position object 2, shellw#,shellh#,shellL#
sync
loop
your positioning is off. Trig+euler angles math needs ta be done.
So... Normals vectors and rotation matrices is how I'd do it.
Say "forward" is defined as the object with a direction <0,0,1> (1 forward on the z axis). Then say "perpendicular" is any direction on the unit circle on the xy plane. Basically, This:
type myVector
x as float
y as float
z as float
endtype
global ret_1 as myVector
global ret_2 as myVector
make object box 1,.1,.1,2
position object 1,0,0,00
xrotate object 1,rnd(360)
yrotate object 1,rnd(360)
zrotate object 1,rnd(360)
make object sphere 2,.3
perprot as float
make object sphere 3,.3
do
yrotate object 1, object angle y(1)+mousemovex()
xrotate object 1, object angle x(1)+mousemovey()
zrotate object 1, object angle z(1)+mousemovez()/10.0
inc perprot, (mouseclick()=1) - (mouseclick()=2)
get_rotation_directions(object angle x(1),object angle y(1), object angle z(1), perprot)
position object 2,ret_1.x,ret_1.y,ret_1.z
position object 3,ret_2.x,ret_2.y,ret_2.z
sync
loop
function get_rotation_directions(angx as float, angy as float, angz as float, perpendicularAng as float)
null = make matrix4(1)
null = make matrix4(2)
null = make matrix4(3)
null = make vector3(4) `forward vector
null = make vector3(5) `perpendicular vector
rotate x matrix4 1, angx*0.0174532925
rotate y matrix4 2, angy*0.0174532925
rotate z matrix4 3, angz*0.0174532925
multiply matrix4 3,2,3 `Z*Y
multiply matrix4 1,1,3 `R = matrix4 #1 = (Z*Y)*X
set vector3 4, 0,0,1
set vector3 5, sin(perpendicularAng),cos(perpendicularAng),0 `perpendicular to vector3 1
transform normals vector3 4,4,1 `Z*Y*X*<0,0,1>
transform normals vector3 5,5,1 `Z*Y*X*(point perpendicular to <0,0,1>)
ret_1.x=x vector3(4)
ret_1.y=y vector3(4)
ret_1.z=z vector3(4)
ret_2.x=x vector3(5)
ret_2.y=y vector3(5)
ret_2.z=z vector3(5)
null = delete vector3(4)
null = delete vector3(5)
null = delete matrix4(1)
null = delete matrix4(2)
null = delete matrix4(3)
null = delete matrix4(4)
endfunction