Area :: Header
New tools, templates and workflows
Announcing Extension 2 for 3ds Max 2015 and 3ds Max Design 2015
Discussion Groups


Active Member
6 Posts
0 Kudos
Registered: ‎03-04-2009

Can't seem to grasp how to properly convert rotations on a camera

99 Views, 1 Replies
12-29-2012 10:04 PM
I have been working on a script to convert an fbx to a json format to bridge into another system. I'm using the fbx python bindings.
It seems I just cannot properly understand how to extract rotation values that match what Maya shows when I just do a straight FBX import of the same source file. Furthermore, I am not even using the proper number of frame samples to match Maya. I've tried researching and found a number of similar question talking about accounting for the pre/post rotation, or sampling the transform from the evaluator. No matter what I do, I am missing the mark.

I feel I am just sampling the wrong way. I did find this just recently from the faq, and would also love a bit of an expansion from someone:

4.8 How do I correctly get/set the number of frames and the frame rate in a FBX file?
Watch out. The number of keys in an animation curve is not the same as the number of frames in an animation.

Up until I had read this, I have been looping on FbxAnimCurve.KeyGetCount(), which I now understand is not really the right way. Here are the details of my siuation:

I am focusing right now only on the RX of the camera in my FBX file.

After import into Maya, the curve shows a range of frames 0-496 (unbaked), but GetKeyCount reports 506 keys. While other animation curves in the scene have their own varied time spans. Again, obviously this is the wrong way to sample, so I really need some help understanding FAQ 4.8 and how to properly sample for each anim curve to get the real keyed frames that Maya sees.

For the rotation values I am pulling, the first few frames of data from my script look like:

RX; 90.0
RX; 89.9860839844
RX; 89.9787445068
RX; 89.9641342163

... while the values from the Maya FBX import look like:

RX; 0.0
RX; -0.0139158508
RX; -0.0212544315
RX; -0.0358680114

I tried adding together (euler) preRot + val + postRot , and this resulted in values that seemed to agree with maya, but then diverged towards the end, I am assuming, because of my poor frame sampling approach.

A snippet of my sampling method looks like this:

def _getCurveKeys(self, node, curve, preRot=0, postRot=0):

kCount = curve.KeyGetCount()
keys = *kCount
fps = self.__fps

for i in xrange(kCount):
fbxTime = curve.KeyGetTime(i)
key = curve.KeyGet(i)
val = key.GetValue()

frame = int(round(fbxTime.GetSecondDouble() * fps))
# val = preRot + val + postRot # probably wrong?

keys = (frame, val)

Any insight would be greatly appreciated. I am attaching both the source fbx file, and a json output from my script containing just the RX animation for comparison.

* PitTest-1700.FBX
* out_fbx_script.js

In a nutshell I want to correct two issues:
1. Sample the same key frames in that 0-496 that Maya is seeing (I don't care if they are baked or not).
2. Produce a rotation value that matches what Maya shows me from import.PitTest-1700.FBX
Active Member
6 Posts
0 Kudos
Registered: ‎03-04-2009

Re: Can't seem to grasp how to properly convert rotations on a camera

01-04-2013 03:21 PM in reply to: Justin Israel
As an update to this problem, I have found that there is something specific to the camera in this FBX that I am handling incorrectly, versus another test I did...
In Maya I just create a simple camera in the root world, and added a couple keyframes to the rotation over a 1-48 frame range, and exported an FBX with default settings. Running this through my script, the rotations all match 1-to-1 with the unaltered value of each key in the curve.

Maybe someone could take a look at the previously reference fbx and offer some insight as to what is different about this camera that I need to consider in the rotation values?