Aspose.3D FOSS for .NET supports seven 3D file formats: OBJ, STL, glTF, GLB, FBX, Collada, and 3MF. This post is a practical, format-by-format guide showing how to load and save each one, what options are available, and how to convert between them.
All examples use the Aspose.ThreeD namespace:
using Aspose.ThreeD;
using Aspose.ThreeD.Formats;
NuGet package:
dotnet add package Aspose.3D.Converter --version 1.0.0
OBJ (Wavefront)
OBJ is a widely supported text-based format for mesh geometry. Aspose.3D FOSS loads OBJ files along with their companion .mtl material files.
Loading OBJ
var scene = new Scene();
scene.Open("model.obj");
Console.WriteLine("Nodes: " + scene.RootNode.ChildNodes.Count);
Loading with Options
var opts = new ObjLoadOptions();
// Configure loading behavior as needed
var scene = new Scene();
scene.Open("model.obj", opts);
Saving as OBJ
var scene = new Scene();
var box = new Entities.Box(2, 2, 2);
scene.RootNode.CreateChildNode("BoxNode", box);
scene.Save("output.obj");
OBJ with Save Options
var opts = new ObjSaveOptions();
scene.Save("output.obj", opts);
STL (Stereolithography)
STL is the standard format for 3D printing. It stores raw triangulated geometry without materials or hierarchy. Aspose.3D FOSS supports both binary and ASCII STL.
Loading STL
var scene = new Scene();
scene.Open("part.stl");
Console.WriteLine("Nodes: " + scene.RootNode.ChildNodes.Count);
Saving as STL
var scene = new Scene();
var sphere = new Entities.Sphere(1);
scene.RootNode.CreateChildNode("SphereNode", sphere);
scene.Save("output.stl");
STL with Save Options
var opts = new StlSaveOptions();
// Control binary mode, scale, and coordinate flipping
scene.Save("output.stl", opts);
STL Round-Trip
// Load an STL file and re-save it -- geometry is preserved
var scene = new Scene();
scene.Open("original.stl");
scene.Save("copy.stl");
glTF 2.0 and GLB
glTF is the modern standard for web and real-time 3D. It supports PBR materials, full scene hierarchies, and efficient binary packing (GLB).
Loading glTF
var scene = new Scene();
scene.Open("model.gltf");
Loading with Options
var opts = new GltfLoadOptions();
var scene = new Scene();
scene.Open("model.gltf", opts);
Saving as glTF
var scene = new Scene();
var box = new Entities.Box(2, 2, 2);
scene.RootNode.CreateChildNode("BoxNode", box);
scene.Save("output.gltf");
Saving as GLB (Binary glTF)
To produce a self-contained binary .glb file, save with a .glb extension. The library infers the binary glTF format from the extension:
scene.Save("output.glb");
FBX (Filmbox)
FBX is widely used in game development and digital content creation. Aspose.3D FOSS for .NET supports FBX import and export in both ASCII and binary modes.
Loading FBX
var scene = new Scene();
scene.Open("model.fbx");
Loading with Options
var opts = new FbxLoadOptions();
var scene = new Scene();
scene.Open("model.fbx", opts);
Saving as FBX ASCII
var scene = new Scene();
var box = new Entities.Box(2, 2, 2);
scene.RootNode.CreateChildNode("BoxNode", box);
var opts = new FbxSaveOptions() { IsAscii = true };
scene.Save("output.fbx", opts);
Saving as FBX Binary
var opts = new FbxSaveOptions() { IsAscii = false };
scene.Save("output.fbx", opts);
3MF (3D Manufacturing Format)
3MF is a modern 3D printing format developed by the 3MF Consortium. It supports rich metadata, materials, and multi-object scenes in a single ZIP-based package.
Loading 3MF
var scene = new Scene();
scene.Open("model.3mf");
Loading with Options
var opts = new TmfLoadOptions();
var scene = new Scene();
scene.Open("model.3mf", opts);
Saving as 3MF
var scene = new Scene();
var box = new Entities.Box(2, 2, 2);
scene.RootNode.CreateChildNode("BoxNode", box);
scene.Save("output.3mf");
Saving with Options
var opts = new TmfSaveOptions();
scene.Save("output.3mf", opts);
Stream-Based I/O
All formats support loading from and saving to streams, which is useful for web services and cloud processing:
using var stream = File.OpenRead("model.obj");
var scene = new Scene();
var opts = new ObjLoadOptions();
scene.Open(stream, opts);
// Save to a memory stream
using var output = new MemoryStream();
var saveOpts = new GltfSaveOptions();
scene.Save(output, saveOpts);
Format Detection
The library can auto-detect formats from file extensions or stream content:
// Auto-detect from extension
var scene = new Scene();
scene.Open("model.obj"); // Detects OBJ from .obj extension
// Auto-detect from stream content
using var stream = File.OpenRead("model.obj");
scene.Open(stream); // Inspects stream content to determine format
Batch Conversion
For converting multiple files, iterate over a directory and convert each one:
using Aspose.ThreeD;
using Aspose.ThreeD.Formats;
var inputDir = "assets/";
var outputDir = "converted/";
foreach (var file in Directory.GetFiles(inputDir, "*.fbx"))
{
var scene = new Scene();
scene.Open(file);
var outputPath = Path.Combine(outputDir,
Path.GetFileNameWithoutExtension(file) + ".glb");
scene.Save(outputPath);
Console.WriteLine("Converted: " + file);
}
Format Comparison
| Feature | OBJ | STL | glTF | FBX | 3MF |
|---|---|---|---|---|---|
| Materials | MTL | No | PBR | Yes | Yes |
| Scene hierarchy | No | No | Yes | Yes | Yes |
| Animation stubs | No | No | Yes | Yes | No |
| Binary mode | No | Yes | GLB | Yes | ZIP |
| 3D printing ready | Limited | Yes | No | No | Yes |
| Web delivery | No | No | Yes | No | No |
Summary
Aspose.3D FOSS for .NET gives you a single, consistent API for working with all major 3D file formats. The pattern is always the same: create a Scene, call Open() to load, optionally configure format-specific options, and call Save() to export. Format detection, stream-based I/O, and batch conversion make it straightforward to integrate into any .NET pipeline.
For more information:
- API Reference – detailed class and method documentation.
- Knowledge Base – practical how-to articles.
- GitHub – source code and issue tracker.