<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Characterizing using FBX API in FBX Forum</title>
    <link>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9749881#M717</link>
    <description>&lt;P&gt;Hey guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive been getting to grips with the FBX API recently to try and take some of our tools away from DCC's and to run as stand alone exe's. So far I haven't had too many issues, just the standard learinng curve. Until now...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the last few days I have been trying to characterize a skeleton that has been exported from another DCC. This skeleton comes in with animation data and that is it, no character in the scene, no definition, nothing. What I want to do is..&lt;BR /&gt;&lt;BR /&gt;- Load the file&lt;/P&gt;&lt;P&gt;- Zero out the skeleton&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Add a character to the scene&lt;/P&gt;&lt;P&gt;- Create the definition&lt;/P&gt;&lt;P&gt;- Turn on the characterization&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have been able to...&lt;/P&gt;&lt;P&gt;- load the file&lt;/P&gt;&lt;P&gt;- add a character to the scene&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FbxCharacter.Create(scene, name)&lt;/P&gt;&lt;P&gt;- add the skeletal nodes to the definition&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; link = FbxCharacterLink(),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; link.mNode = skelNode,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char.SetCharacterLink(node, link)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing I can't get to work is that final step of turning on the characterization. It seems like when I querey the characterization in the file using -&amp;nbsp;char.Characterize.Get() - it returns True. When I open the file it isn't on. When I try and set it using -&amp;nbsp;char.Characterize.Set(True) - it changes nothing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The one thing I have noticed is that if I create the character by hand in MotionBuilder (dragging and dropping the character asset onto the hips) then save the file, all of this functionality becomes available. I can turn on and off characterizations and I get a proper read of the property.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a step im missing, I dont see much/any documentation on what the correct process is to achieve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TLDR; Anyone got a working example of characterizing a skeleton using the FBX API from scratch?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance to anyone with some info.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 11:01:04 GMT</pubDate>
    <dc:creator>Oli.Cooke</dc:creator>
    <dc:date>2020-09-16T11:01:04Z</dc:date>
    <item>
      <title>Characterizing using FBX API</title>
      <link>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9749881#M717</link>
      <description>&lt;P&gt;Hey guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive been getting to grips with the FBX API recently to try and take some of our tools away from DCC's and to run as stand alone exe's. So far I haven't had too many issues, just the standard learinng curve. Until now...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the last few days I have been trying to characterize a skeleton that has been exported from another DCC. This skeleton comes in with animation data and that is it, no character in the scene, no definition, nothing. What I want to do is..&lt;BR /&gt;&lt;BR /&gt;- Load the file&lt;/P&gt;&lt;P&gt;- Zero out the skeleton&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Add a character to the scene&lt;/P&gt;&lt;P&gt;- Create the definition&lt;/P&gt;&lt;P&gt;- Turn on the characterization&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have been able to...&lt;/P&gt;&lt;P&gt;- load the file&lt;/P&gt;&lt;P&gt;- add a character to the scene&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FbxCharacter.Create(scene, name)&lt;/P&gt;&lt;P&gt;- add the skeletal nodes to the definition&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; link = FbxCharacterLink(),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; link.mNode = skelNode,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char.SetCharacterLink(node, link)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing I can't get to work is that final step of turning on the characterization. It seems like when I querey the characterization in the file using -&amp;nbsp;char.Characterize.Get() - it returns True. When I open the file it isn't on. When I try and set it using -&amp;nbsp;char.Characterize.Set(True) - it changes nothing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The one thing I have noticed is that if I create the character by hand in MotionBuilder (dragging and dropping the character asset onto the hips) then save the file, all of this functionality becomes available. I can turn on and off characterizations and I get a proper read of the property.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a step im missing, I dont see much/any documentation on what the correct process is to achieve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TLDR; Anyone got a working example of characterizing a skeleton using the FBX API from scratch?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance to anyone with some info.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 11:01:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9749881#M717</guid>
      <dc:creator>Oli.Cooke</dc:creator>
      <dc:date>2020-09-16T11:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Characterizing using FBX API</title>
      <link>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9825667#M718</link>
      <description>&lt;P&gt;Hi, the following code will create a basic humanoid skeleton and the associated character. Note that this is the very basic process and a lot of information is not filled (including the creation of the control rig)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;#include &amp;lt;fbxsdk.h&amp;gt;
#include "../Common/Common.h"

FbxNode* CreateSkelMember(FbxScene* pScene, const char* pName, FbxNodeAttribute::EType pType, int pAttrType, FbxVector4 pT, FbxVector4 pR = FbxVector4(0,0,0))
{
    FbxNode* lNode = FbxNode::Create(pScene, pName);
    lNode-&amp;gt;LclTranslation.Set(pT);
    lNode-&amp;gt;LclRotation.Set(pR);

    FbxNodeAttribute* lAttr = nullptr;
    switch (pType)
    {
    case FbxNodeAttribute::eNull:
        lAttr = FbxNull::Create(pScene, "");
        FbxCast&amp;lt;FbxNull&amp;gt;(lAttr)-&amp;gt;Look.Set((FbxNull::ELook)pAttrType);
        break;
    case FbxNodeAttribute::eMarker:
        lAttr = FbxMarker::Create(pScene, "");
        FbxCast&amp;lt;FbxMarker&amp;gt;(lAttr)-&amp;gt;SetType((FbxMarker::EType)pAttrType);
        break;
    case FbxNodeAttribute::eSkeleton:
        lAttr = FbxSkeleton::Create(pScene, "");
        FbxCast&amp;lt;FbxSkeleton&amp;gt;(lAttr)-&amp;gt;SetSkeletonType((FbxSkeleton::EType)pAttrType);
        switch ((FbxSkeleton::EType)pAttrType)
        {
        case FbxSkeleton::eRoot:
        case FbxSkeleton::eEffector:
            break;
        case FbxSkeleton::eLimbNode:
            FbxCast&amp;lt;FbxSkeleton&amp;gt;(lAttr)-&amp;gt;Size.Set(100.0);
            break;
        case FbxSkeleton::eLimb:
            FbxCast&amp;lt;FbxSkeleton&amp;gt;(lAttr)-&amp;gt;LimbLength.Set(1.0);
            break;
        }
        
        break;
    }
    lNode-&amp;gt;SetNodeAttribute(lAttr);
    return lNode;
}

void CreateSkeleton(FbxScene* pScene)
{
    // Define a Humanoid skeleton
    //

    FbxNode* lRootNode = pScene-&amp;gt;GetRootNode();
    FbxNode *lNode, *lParent, *lRoot;
    lNode = CreateSkelMember(pScene, "Hips", FbxNodeAttribute::eSkeleton, FbxSkeleton::eRoot, FbxVector4(0, 92, 0));
    lRootNode-&amp;gt;AddChild(lNode);
    lRoot = lNode;
    lParent = lNode;

    // left leg
    // hip
    lNode = CreateSkelMember(pScene, "LeftUpLeg", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(6, -8, 0), FbxVector4(-10.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // knee
    lNode = CreateSkelMember(pScene, "LeftLeg", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, -43, 0), FbxVector4(20.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // ankle
    lNode = CreateSkelMember(pScene, "LeftFoot", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, -40, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // foot
    lNode = CreateSkelMember(pScene, "LeftToeBase", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, 0, 12));
    lParent-&amp;gt;AddChild(lNode);

    // right leg
    lParent = lRoot;
    // hip
    lNode = CreateSkelMember(pScene, "RightUpLeg", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(-6, -8, 0), FbxVector4(-10.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // knee
    lNode = CreateSkelMember(pScene, "RightLeg", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, -43, 0), FbxVector4(20.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // ankle
    lNode = CreateSkelMember(pScene, "RightFoot", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, -40, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // foot
    lNode = CreateSkelMember(pScene, "RightToeBase", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, 0, 12));
    lParent-&amp;gt;AddChild(lNode);

    // waist
    lParent = lRoot;
    lNode = CreateSkelMember(pScene, "Spine", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, 8, 0), FbxVector4(0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode; 
    // chest
    lNode = CreateSkelMember(pScene, "Spine1", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, 50, 0), FbxVector4(0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    lRoot = lParent;

    // Neck
    lParent = lNode;
    lNode = CreateSkelMember(pScene, "Neck", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, 2, -1), FbxVector4(0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;

    // Head
    lNode = CreateSkelMember(pScene, "Head", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(0, 20, 0), FbxVector4(0, 0, -7));
    lParent-&amp;gt;AddChild(lNode);

    // Left Arm
    // collar
    lParent = lRoot;
    lNode = CreateSkelMember(pScene, "LeftShoulder", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(20, 2, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // shoulder
    lNode = CreateSkelMember(pScene, "LeftArm", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(5, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // elbow
    lNode = CreateSkelMember(pScene, "LeftForeArm", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(27.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // wrist
    lNode = CreateSkelMember(pScene, "LeftHand", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(24.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);

    // Right Arm
    // collar
    lParent = lRoot;
    lNode = CreateSkelMember(pScene, "RightShoulder", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(-20, 2, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // shoulder
    lNode = CreateSkelMember(pScene, "RightArm", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(-5, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // elbow
    lNode = CreateSkelMember(pScene, "RightForeArm", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(-27.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
    lParent = lNode;
    // wrist
    lNode = CreateSkelMember(pScene, "RightHand", FbxNodeAttribute::eSkeleton, FbxSkeleton::eLimbNode, FbxVector4(-24.0, 0, 0));
    lParent-&amp;gt;AddChild(lNode);
}

void FillCharacterLink(FbxCharacterLink&amp;amp; pLink, FbxNode* pNode)
{
    // Fill basic link data (typically, you also need to set limits and pre/post rotation vectors, rotation order, etc.)
    pLink.mNode = pNode;

    // CharacterLink needs global transforms 
    FbxAMatrix pNodeGM = pNode-&amp;gt;EvaluateGlobalTransform();
    pLink.mOffsetT = pNodeGM.GetT();
    pLink.mOffsetR = pNodeGM.GetROnly();
    pLink.mOffsetS = pNodeGM.GetS();
}

void CreateCharacter(FbxScene* pScene)
{
    if (!pScene) return;
    FbxCharacter* lCharacter = FbxCharacter::Create(pScene, "Character");
    FbxArray&amp;lt;FbxCharacterLink&amp;gt; link;

    for (int i = 0; i &amp;lt; pScene-&amp;gt;GetSrcObjectCount&amp;lt;FbxNode&amp;gt;(); i++)
    {
        FbxNode* lNode = pScene-&amp;gt;GetSrcObject&amp;lt;FbxNode&amp;gt;(i);
        if (lNode == pScene-&amp;gt;GetRootNode()) continue;

        // create the character link based on the skeleton bones name
        FbxCharacter::ENodeId nodeId;
        if (FbxCharacter::GetCharacterNodeIdFromNodeName(lNode-&amp;gt;GetName(), nodeId))
        { 
            FbxCharacterLink l;
            FillCharacterLink(l, lNode);
            lCharacter-&amp;gt;SetCharacterLink(nodeId, l);
        }
    }
}

int main(int argc, char** argv)
{    
    FbxManager* lSdkManager = NULL;
    FbxScene* lScene = NULL;
    bool lResult = true;

    // Prepare the FBX SDK.
    //The first thing to do is to create the FBX Manager which is the object allocator for almost all the classes in the SDK
    lSdkManager = FbxManager::Create();
    if (!lSdkManager)
    {
        FBXSDK_printf("Error: Unable to create FBX Manager!\n");
        exit(1);
    }

    //Create an IOSettings object. This object holds all import/export settings.
    FbxIOSettings* ios = FbxIOSettings::Create(lSdkManager, IOSROOT);
    lSdkManager-&amp;gt;SetIOSettings(ios);

    //Load plugins from the executable directory (optional)
    FbxString lPath = FbxGetApplicationDirectory();
    lSdkManager-&amp;gt;LoadPluginsDirectory(lPath.Buffer());

    //Create an FBX scene. This object holds most objects imported/exported from/to files.
    lScene = FbxScene::Create(lSdkManager, "My Scene");
    if (!lScene)
    {
        FBXSDK_printf("Error: Unable to create FBX scene!\n");
        exit(1);
    }

    // parse arguments
    FbxString lFilePath("");
    FbxString lOutFilePath("");

    for( int i = 1, c = argc; i &amp;lt; c; ++i )
    {
        if( FbxString(argv[i]) == "-test" ) continue;
        else if( lFilePath.IsEmpty() ) lFilePath = argv[i];
        else if (lOutFilePath.IsEmpty()) lOutFilePath = argv[i];
    }

    if (!lFilePath.IsEmpty() &amp;amp;&amp;amp; lFilePath != "-dummy")
    {
        lResult = LoadScene(lSdkManager, lScene, lFilePath.Buffer());
    }

    if (lResult)
    {
        CreateSkeleton(lScene);
        CreateCharacter(lScene);
    }

    if (lResult &amp;amp;&amp;amp; !lOutFilePath.IsEmpty())
    {
        lResult = SaveScene(lSdkManager, lScene, lOutFilePath.Buffer(), 1);
    }

    // Destroy all objects created by the FBX SDK.
    DestroySdkObjects(lSdkManager, lResult);
    return 0;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Oct 2020 20:13:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9825667#M718</guid>
      <dc:creator>regalir</dc:creator>
      <dc:date>2020-10-26T20:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Characterizing using FBX API</title>
      <link>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9928146#M719</link>
      <description>&lt;P&gt;Thanks for the run down, it all makes sense and is similar to what I have in python. My issue is turning on the characterization, when I load the fbx into Mobu the character is unlocked and the defenition is mostly red.&lt;/P&gt;&lt;P&gt;I can't see anything in your code there that suggests turning on or locking the character&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 22:57:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9928146#M719</guid>
      <dc:creator>Oli.Cooke</dc:creator>
      <dc:date>2020-12-09T22:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Characterizing using FBX API</title>
      <link>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9942269#M720</link>
      <description>&lt;P&gt;Okay, for anyone in the future, I figured out what it was that wasn't allowing me to charecterize. Turns out it was the hierarchy, not of the character skeleton but the nodes above it. Usually I put all of my root nodes under a single scene node, somewhere in my script I create the node (a null) to act at the top level parent everything else is parented to. When parented like this the characterization fails, saying that bones are esentially positioned on top of eachother. When I unparent the hips from this parent node, it all characterizes fine. (apart from zeroing out the skeleton for a T pose).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I've moved away from using this set up but I thought it was worth mentioning that I had trouble characerizing when the hips were parented to a node I created in script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks regalir&amp;nbsp;&lt;SPAN class="UserName lia-user-name lia-user-rank-Employee lia-component-message-view-widget-author-username"&gt;for the response&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 20:11:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fbx-forum/characterizing-using-fbx-api/m-p/9942269#M720</guid>
      <dc:creator>Oli.Cooke</dc:creator>
      <dc:date>2020-12-15T20:11:25Z</dc:date>
    </item>
  </channel>
</rss>

