Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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