Read and display animations from *.FBX file
<p>I want to read 3d model from <code>fbx</code> file and display it within <code>openGL es 2.0</code> engine on iPhone (not using <code>Unity</code>) and also I want to display animations for read 3d object.</p>

<p><strong>How can i get animations from <code>fbx</code> file?</strong> </p>

<p>Currently I able to get list of poses names with, as I understood, coming with transformation matrix, full list of poses in layer, stacks, layers, and a lot of curves. </p>

<p><strong>How this all information can be combined for displaying proper animations?</strong></p>

<p>I also try to parse some info within <code>TakeInfo</code>, but result a little bit strange as for me, for example: </p>

<pre><code>    FbxTakeInfo *ltakeInfo  =  pScene-&gt;GetTakeInfo(lAnimStack-&gt;GetName());
    FbxTime start = ltakeInfo-&gt;mLocalTimeSpan.GetStart();
    FbxTime end = ltakeInfo-&gt;mLocalTimeSpan.GetStop();

    self.startTime = start.GetSecondDouble();
    self.endTime = end.GetSecondDouble();
</code></pre>

<p>here i got <code>start = 0</code> and <code>end = 0.014</code> for each of parsed layers, so i guees this is incorrect (<code>fbx</code> file that I want to display contains 1 mesh with simple 5 sec duration animations). </p>

<hr>

<p><strong>Update</strong></p>

<p>After few hours of investigating I got next things:</p>

<p>For reference this is structure of test obj that i want to display:</p>

<p><a href="https://i.stack.imgur.com/0FA9r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0FA9r.png" alt="enter image description here"></a></p>

<p>Here u can see a lot of bones (more concrete - 19)
I able to get (as noted above) a 19 animated obj in list (like names of bone/obj) and 19 groups of curves within 151 frames each (with frame rate 30 exactly 5 sec of anim. - 30*5=150 + 1 last identity matrix).</p>

<p>If I try use each of curve group to my mesh one by one (I able to parse 1 mesh only) I see animation of different part of mesh applied to all mesh (for example vertical rotation or horizontal translation), so I think that this curves in each group should be applied exactly to specific bone and as result i will got animation for my mesh. The problem is that i don't know how to animate only selected bone vertex part only.</p>

<p>Now the problem is how to apply this all animations divided in to separate group specific to bone to whole obj (because I have only one mesh)? </p>

<p>How can I get 1 global curve's list for each frame from list with all  curve's groups?</p>

<hr>

<p><strong>Update2</strong></p>

<p>Thanks to @codetiger advice I follow instruction within provided link in comment and with that technique I'm able to retrieve list of bone-specific mat's with start and end time and required transforms, but this is almost same like I got before with curves - the only difference that with curves I should create mat from 9 curves (translate/ scale/ rotate for x y z) instead of using full matrix, but problem are still present -  how can i combine them in 1 global matrix?</p>

<p>The code that I use (found few links for it):</p>

<pre><code>FbxNode* modelNode = _fbxScene-&gt;GetRootNode();
FbxAMatrix geometryTransform = GetGeometryTransformation(modelNode);
for (unsigned int deformerIndex = 0; deformerIndex &lt; numOfDeformers; ++deformerIndex) {
    FbxSkin* currSkin = reinterpret_cast&lt;FbxSkin*&gt;(mesh-&gt;GetDeformer(deformerIndex, FbxDeformer::eSkin));
    if (!currSkin) {
        continue;
    }
    unsigned int numOfClusters = currSkin-&gt;GetClusterCount();
    for (unsigned int clusterIndex = 0; clusterIndex &lt; numOfClusters; ++clusterIndex) {
        FbxCluster* currCluster = currSkin-&gt;GetCluster(clusterIndex);
        std::string currJointName = currCluster-&gt;GetLink()-&gt;GetName();

        FbxAMatrix transformMatrix;
        FbxAMatrix transformLinkMatrix;
        FbxAMatrix globalBindposeInverseMatrix;

        currCluster-&gt;GetTransformMatrix(transformMatrix);   
        currCluster-&gt;GetTransformLinkMatrix(transformLinkMatrix);   
        globalBindposeInverseMatrix = transformLinkMatrix.Inverse() * transformMatrix * geometryTransform;

        FbxAnimStack* currAnimStack = _fbxScene-&gt;GetSrcObject&lt;FbxAnimStack&gt;(0);
        FbxString animStackName = currAnimStack-&gt;GetName();
        char *mAnimationName = animStackName.Buffer();
        FbxTakeInfo* takeInfo = _fbxScene-&gt;GetTakeInfo(animStackName);
        FbxTime start = takeInfo-&gt;mLocalTimeSpan.GetStart();
        FbxTime end = takeInfo-&gt;mLocalTimeSpan.GetStop();
        FbxLongLong mAnimationLength = end.GetFrameCount(FbxTime::eFrames24) - start.GetFrameCount(FbxTime::eFrames24) + 1;

        for (FbxLongLong i = start.GetFrameCount(FbxTime::eFrames24); i &lt;= end.GetFrameCount(FbxTime::eFrames24); ++i) {
            FbxTime currTime;
            currTime.SetFrame(i, FbxTime::eFrames24);

            FbxAMatrix currentTransformOffset = modelNode-&gt;EvaluateGlobalTransform(currTime) * geometryTransform;
            FbxAMatrix mat = currentTransformOffset.Inverse() * currCluster-&gt;GetLink()-&gt;EvaluateGlobalTransform(currTime);

        }
    }
}
</code></pre>

<p>Here I receive 121 matrix instead of 151 - but duration of some matrix transforms take more than duration of 1 frame draw, so the q-ty here I think also correct </p>

<pre><code>float duration = end.GetSecondDouble() - start.GetSecondDouble(); //return 5 as and expected
</code></pre>

<p>I guess that that <code>Autodesk SDK</code> there is a way to get 1 Global transform per each drawCall</p>

<p>Any suggestions? Is this possible?</p>

<hr>

<p>Add bounty for anyone who can describe how to display animations on iPhone within openGLES 2.0 with Autodesk SDK... (<strong>sorry typo instead of Facebook</strong>)</p>

<hr>

<p>Here what i'm able to get</p>

<p>Original object in <code>blender</code></p>

<p><a href="https://i.stack.imgur.com/nmAqx.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmAqx.gif" alt="enter image description here"></a></p>

<p>If i draw bone separately (same VBO with different transform and only indices for each bone accordantly)</p>

<p><a href="https://i.stack.imgur.com/fzlZe.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fzlZe.gif" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/hNJYK.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hNJYK.gif" alt="enter image description here"></a></p>