FbxWriter icon indicating copy to clipboard operation
FbxWriter copied to clipboard

Feature/animations

Open RoyTheunissen opened this issue 2 years ago • 0 comments

Made this for my own fork but I figured it might be worth sharing to the original repository in case you found them worthwhile.

What's added?

  • Created an FbxBuilder utility to allow you to quickly create an FBX file by focusing on the data you want to write instead of having to re-create the entire FBX file format yourself
  • Added high-level classes for creating Joints and Animation Curves.
  • Added FBXTime wrapper to convert from frames or seconds to the internal FBX format
  • Added basic support for unique ID generation (could be improved, but it works)
  • Improved syntax for adding new nodes and property blocks
  • Expanded FBXWriter to support inline comments, headers and line breaks
  • Expanded FBXWriter to support FBXTime and various other data types

Here's an example of how to use the new FbxBuilder:

FbxBuilder builder = new FbxBuilder(@"C:\Output\Test.fbx", 30);

// Add a basic joint.
Joint joint1 = builder.AddJoint(new Joint("joint1", new Vector3D(0, 0, 100)));

// Add an animation for joint1's position attribute X-coordinate from frame 1 to 30.
Curve joint1PositionCurve = new Curve(joint1.Translation, Components.X)
{
    { 1, 0.0f },
    { 30, -100.0f },
};
builder.AddCurve(joint1PositionCurve);

builder.Write();

Known issues

  • FbxId generates ID's that are unique to the file, but they're not globally unique. Not sure if this is problematic. Works fine for me.
  • Custom tangent slopes, weights and velocities are not currently supported. This leaves the following possible tangents:
    • Constant
    • Linear
    • Cubic with flat tangents, or with automatic tangents.

RoyTheunissen avatar Jul 09 '22 14:07 RoyTheunissen