I am trying to write a simple tool that with orientate an object to sit on a surface and align to the surface normal, so the Zaxis aligns to the face normal. This is not a problem. I then want to be able to rotate that object around the local Z axis, so I can effectively control the direction that the local X axis points. I need this to be done using maxscript, so I can automatically orientate a large number of objects in both the z and x local axis... and hence the entire object.
The problem that I am having is that when I am orientating something using the obj.dir property, max seems to decide to flip the orientation of the x and y axis. I,e The Z axis always points correctly, but the X axis and Y axis can change.
To illustrate the problem, I have attached an image of a load of scattered teapots that I have told to point towards the sphere. i.e
for t in teapots do
t.dir = normalize ($Sphere01.pos - t.pos)
As you can see from the image, max changes its orientation of the x and y axis. I cannot figure out how to prevent, or detect this flip, making it impossible for me to reliably orientate Objects....
Does it have anything to do with the "getEulerMatAngleRatio" command... I dont really understand that section!
Any help preventing or detecting this change in orientation would be really helpful, cause I know I can then complete the rest of the orientation without too much difficulty!
Thanks for your time everyone!