[Closed] freecamera transformation read-out
hi everyone,
i want to script-export camera movement data to another application, which is no problem in general.
now, when I animate cameras, i usually create a free camera and RESET TRANSFORMATION before animating it (for reasons i never understood, a free camera has y-axis going up, instead of z, which in max world is confusing since we work z-up). I don’t want a x=90 from the start.
now, others, who might want to use my exporter, may not do this step, so their camera data will export differently and not work, if i adapt the script to my habit.
is there a way to either find out if the transformation has been reset
or to read out a somewhat general camera transformation that is independent of the pivot alignment (i guess not)
and does anyone know why the freecam has its pivot rotated by default ( if you just generate it be script, it even points down initially)?
thanks.
okay, i figured out the first part myself
i can check if the ObjectOffsetRot is not 0,0,0 (if it is , the pivot has been rotated)
and the script could convert the data acordingly.
but if max can measure the rotation.offset, it must have something to compare the current pivot orientation with, those values would have to be the same no matter if the camera has been transform-reset or not.
what are those values?
either apply a resetTransform to it? or just transform it into a new transform and export that.
something like this:
(
local trackPoint = point()
local xOffset = -90.0
trackPoint.transform = ((eulerangles xOffset 0 0)as matrix3) * $Camera01.transform
local trackPointTM = trackPoint.transform * inverse $Camera01.transform
local cameraTrackFileName = GetSaveFileName types: "txt(*.txt)|*.txt|"
if cameraTrackFileName != undefined do
(
disableSceneRedraw()
cameraTrackFile = createFile cameraTrackFileName
for f = animationRange.start to animationRange.end do
(
slidertime = f
trackPoint.transform = trackPointTM * $Camera01.transform
format "%
" trackPoint.transform to:cameraTrackFile
)
delete trackPoint
close cameraTrackFile
enableSceneRedraw()
)
)
hey thanks,
that works.
but still i am curious, how does max calculate the rotation offset?
What rotation offset? – I think a free camera naturally just gets built facing down – when you build it in a view point it basis direction of this viewports axis i.e in the front viewport it looking at you.
I think it was designed this way for efficiency, as you may need to throw in a camera quickly.
You can always compare a transform against another transform, by transforming it into it. I.e capturing the transform ‘space’ between the two.
$Camera01.transform * inverse base.transform)
This transform can be generalize down, with quattoeuler, .pos, row1,2,3,4 etc to get a parameter and attribute.
The is essentially a simple math summation, but matrices use multiplication. If we say camera = 20 and the world = 10, what were doing is 20 + -10 = 10. 10 being the ‘offset space’. This is how objects work in max. They have a node Transform and a object-offset Transform with the equation essentially:
object.transform = (nodeTransform * inverse worldTransform)*object-offsetTransform