Importing Custom .fbx Files



  • On 01/04/2016 at 10:26, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   13 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi,
    I'm learning the FBX SDK and I'm having trouble with setting the weight values for each vertice.
    I'm not sure if this is a C4D problem. Or if I'm doing something wrong in my FBX code.
    But since C4D comes with an .fbx importer. Perhaps you guys can give me hint what's going wrong?

    In my .fbx file I create a low res cylinder in the code.
    It has 3 loop segments. Each with 4 points. Totaling 12 points(0-11).
    In my code I create 3 joints. And position them inside of the cylinder as the joint skeleton rig.
    When I open the .fbx file in C4D I get the cylinder, Weight tag, Skin deformer, and the 3 joints.
    Everything is good, and in their proper places. Except the joint weights are doing wacky things.

    In my .fbx code. I have created three clusters. One cluster for each joint.
    Then I am setting the weight values for them by hand just as a test.

    clusterA->AddControlPointIndex(0, 100);
      clusterA->AddControlPointIndex(1, 100);
      clusterA->AddControlPointIndex(2, 100);
      clusterA->AddControlPointIndex(3, 100);
      clusterA->AddControlPointIndex(4, 100);
      clusterA->AddControlPointIndex(5, 100);
      clusterA->AddControlPointIndex(6, 100);
      clusterA->AddControlPointIndex(7, 100);
      clusterA->AddControlPointIndex(8, 0);
      clusterA->AddControlPointIndex(9, 0);
      clusterA->AddControlPointIndex(10, 0);
      clusterA->AddControlPointIndex(11, 0);

    clusterB->AddControlPointIndex(0, 0);
      clusterB->AddControlPointIndex(1, 0);
      clusterB->AddControlPointIndex(2, 0);
      clusterB->AddControlPointIndex(3, 0);
      clusterB->AddControlPointIndex(4, 0);
      clusterB->AddControlPointIndex(5, 0);
      clusterB->AddControlPointIndex(6, 0);
      clusterB->AddControlPointIndex(7, 0);
      clusterB->AddControlPointIndex(8, 100);
      clusterB->AddControlPointIndex(9, 100);
      clusterB->AddControlPointIndex(10, 100);
      clusterB->AddControlPointIndex(11, 100);

    clusterC->AddControlPointIndex(0, 0);
      clusterC->AddControlPointIndex(1, 0);
      clusterC->AddControlPointIndex(2, 0);
      clusterC->AddControlPointIndex(3, 0);
      clusterC->AddControlPointIndex(4, 0);
      clusterC->AddControlPointIndex(5, 0);
      clusterC->AddControlPointIndex(6, 0);
      clusterC->AddControlPointIndex(7, 0);
      clusterC->AddControlPointIndex(8, 0);
      clusterC->AddControlPointIndex(9, 0);
      clusterC->AddControlPointIndex(10, 0);
      clusterC->AddControlPointIndex(11, 0);

    I have the mode set to this:
    clusterA->SetLinkMode(FbxCluster::eTotalOne);
    clusterB->SetLinkMode(FbxCluster::eTotalOne);
    clusterC->SetLinkMode(FbxCluster::eTotalOne);

    But in C4D. All of the point weights in clusterA & clusterB are being set to 100!?
    And the total weight values are equaling 200!?

    Can anyone tell me what's going on here?
    Why are the weights getting messed up when the .fbx file opened in C4D?
    Is this a C4D problem. Or am I setting the weight values wrong in the FBX code?

    -ScottA



  • On 04/04/2016 at 08:47, xxxxxxxx wrote:

    Hi Scott,

    we are no experts on the FBX SDK here. But I'd like to suggest an approach to tackle this. As you probably know, FBX comes in two flavors, binary and human readable ASCII. Couldn't you set up a scene in C4D, similar to what you are trying to describe in FBX. Then export that scene into human readable FBX.
    Now, you have something to compare to and you can see where the scene exported by C4D differs from the one you create with your code.

    I will also forward your question to our development, perhaps it rings a bell somewhere.



  • On 04/04/2016 at 09:06, xxxxxxxx wrote:

    Hi Andreas,
    I was thinking the exact same thing yesterday. But the FBX SDK is really bad.
    Everything in their samples is broken up into separate files and methods. And they don't tell you how to set the ASCII option clearly.
    I really hate it when people do that in tutorial code.😠

    After a lot of head banging. I've managed to write a much more understandable example. But I'm still trying to figure out how to set the ASCII option so that I can see the weight values in the text.
    I have a gut feeling that C4D isn't changing the values. But I'd like to know for sure.

    I know this isn't technically C4D related. But If you guys would like to see my code. I'll be happy to post it.
    It's way easier to understand than the sample in the FBX SDK. And it's all in one file the does not need any other files to execute.

    -ScottA



  • On 04/04/2016 at 09:51, xxxxxxxx wrote:

    Hi Scott,

    I just got an answer from one of the developers, that it might be worth trying eNormalize for the link mode. He also doubts, that this is a problem of our import. But if you find, that your FBX file imports well in another application, it's probably best to contact our support and file a bug report there.

    I don't think, posting FBX code here makes much sense. But maybe I'm wrong and we have somebody in our community who knows the FBX SDK. So I'd say, wait with posting any code until somebody raises his hand.



  • On 04/04/2016 at 10:15, xxxxxxxx wrote:

    I tried eNormalize & eAdditive. With no success.
    The closest I can get is to set the weights using a nested for() loop for each joint cluster.
    Using: cluster->AddControlPointIndex(4 * i + j, 1.0);
    And then after I open it in C4D. I need to select the joints and press the Normalize button in the weight manager.

    I probably just don't understand the way weights work in the FBX SDK.
    That whole 4 * i +j stuff doesn't make sense to me. That's why I was trying to set them individually by hand.
    It's probably not a C4D issue.

    -ScottA


Log in to reply