Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 28, 2023 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/81b3c2b6c99bdfbe125cc828651731b0 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/81b3c2b6c99bdfbe125cc828651731b0 to your computer and use it in GitHub Desktop.
C# Convert FBX to glTF GLB or glTF to FBX Programmatically in .NET
// Initialize Scene class object.
Scene scene = new Scene();
// Initiate FBXLoadOptions class object.
FBXLoadOptions opt = new FBXLoadOptions();
// Output all properties defined in GlobalSettings in FBX file.
opt.KeepBuiltinGlobalSettings = true;
// Load input FBX file
scene.Open("test.FBX", opt);
// Export scene and embed the dependencies inside the target file.
GLTFSaveOptions options = new GLTFSaveOptions(FileContentType.ASCII);
options.EmbedAssets = true;
// Customize the name of the buffer file which defines model.
options.BufferFile = "mybuf.bin";
// Save glTF file.
scene.Save(dataDir + "glTFSaveOptions_out.gltf", options);
// OR save GLB file using KHR_binary_glTF extension
scene.Save("glTFSaveOptions_out.glb", FileFormat.GLTF_Binary);
// Initialize Scene class object
Scene scene = new Scene();
// Set glTF load options
GLTFLoadOptions loadOpt = new GLTFLoadOptions();
scene.Open("Test.gltf", loadOpt);
// Initialize FBXSaveOptions object
FBXSaveOptions saveOpts = new FBXSaveOptions(FileFormat.FBX7500ASCII);
// Save output FBX file
scene.Save("output.fbx", saveOpts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment