MaxScript: Get target camera rotation from each keyframe



First want to say that I’m a beginner in the 3d world, so probably I don’t have clear some basic concepts, but here comes my issue:

I’m creating a custom exporter in 3ds max for an external tool, using MAXScript language.

I would like to know how to get the 3x3 rotation matrix and position of each key frame of an animated target camera. I’m using this, but I always get: 1.0 0.0 0.0, 0.0 1.0 0.0, 0.0 0.0 1.0.
Here’s the code I’m using:

for i = 0 to endframe do
	local TimeMatrixRotation = at time i Cams[1].target.rotation as matrix3;
	local TimeCamPos = at time i Cams[1].pos;

It seems that gets the position correctly, but the rotation no.

What I’m doing wrong?


why would you need to have the target rotation? target is a dummy point around wich you’ll eventually rotate the camera

so i guess you’d need the camera rotation at time…


Well, the problem is that if I write:
local TimeMatrixRotation = at time i Cams[1].rotation as matrix3;
instead of writing:
local TimeMatrixRotation = at time i Cams[1].target.rotation as matrix3;

The script crashes and appears a message box that says:

—Unknown property: “rotation” in $Camera001

I don’t know what I’m doing wrong. To get the cameras I use this code:
local Cams = for Cam in cameras where (superclassof Cam == camera) collect Cam

But yes, what I need for the exporter is the camera rotation for each keyframe.


ok, i see

you’d probably need to recompose the transformation matrix of the original cam to a free camera to have the rotation, have a look at this post for reference (it is not your case but you can take some hints)

also this

personally i never used it so i don’t have an exact solution, but this should get you started


Thank you!!