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.jsIn 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