[Closed] camera rotation
I’m trying to export object and camera rotations as euler angles. But I’m having a bit of trouble with (free)cameras, since their Y,Z axis is swapped (unlike normal objects the Y is pointing up rather than Z, while X remains the same).
I extract and store the object rotations like this:
in coordsys world r = ((inverse obj.rotation) as eulerangles)
WriteFloat fp r.x
WriteFloat fp r.z
WriteFloat fp -r.y
This does not work with camera rotations, the resulting rotation is incorrect.
How can I export camera rotations properly?
FYI, I managed to solve it:
[ul]
[li]copy and store the camera orientation
[/li][li]reset the camera orientation to identity matrix (to simulate world space orientation)
[/li][li]create a dummy object
[/li][li]attach dummy object to camera
[/li][li]restore the camera rotation
[/li][li]dummy is now rotated along with the camera
[/li][li]extract the dummy rotation like you would with normal objects
[/li][li]delete dummy object
[/li][/ul]Hacky, but the only reliable way to do it, or so it seems. I must credit the folks over at the Autodesk webboard for this one though.
WOW!
Thats exactly what I am looking for. I am currently working on a java3d engine and I need to export objects animation(position and rotation) from max to my system.
Can you please share your code?
That will be great!
I got some scripts but none of them seen to work properly on max8!
I am looking foward for your answer.
Thank you
Sure, here’s the snippet:
-- select coordsys
local csys
if (obj.parent == undefined) OR (getuserprop obj "joint") == true then
(
-- world
csys = matrix3 1
) else (
-- parent
csys = obj.parent
)
-- get rotation
tmprot = obj.transform
obj.transform = matrix3 1
in coordsys local rotate obj (eulerangles 90 0 0)
tmpdummy = dummy boxsize:[10,10,10]
tmpdummy.parent = obj
obj.transform = tmprot
in coordsys local rotate tmpdummy (eulerangles 0 0 180)
in coordsys csys r = ((inverse tmpdummy.rotation) as eulerangles)
delete tmpdummy
Where ‘r’ will be your resulting rotation (point3 value).
Cheers.