AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / Can't seem to grasp how to properly convert rotations on a camera
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

Can't seem to grasp how to properly convert rotations on a camera
Rate this thread
 
74655
 
Permlink of this thread  
avatar
  • Location: Los Angeles, CA
  • Total Posts: 6
  • Joined: 03 March 2009 09: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: 

[0000] RX;  90.0
[0001] RX
;  89.9860839844
[0002] RX
;  89.9787445068
[0003] RX
;  89.9641342163

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

[0000] RX;  0.0
[0001] RX
;  -0.0139158508
[0002] RX
;  -0.0212544315
[0003] 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(selfnodecurvepreRot=0postRot=0):

        
kCount curve.KeyGetCount()
        
keys [0]*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[i] = (frameval)
        ...

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



Replies: 0
avatar

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?



Replies: 0