Features and Functionalities
Features and Functionalities
This page covers every major feature area of Aspose.3D 26.1.0 with working C# examples.
Loading and Saving Scenes
Scene.Open() loads a file; Scene.Save() exports it. The format is detected from the file extension:
using Aspose.ThreeD;
var scene = new Scene();
scene.Open("input.obj");
scene.Save("output.glb");Use the static factory Scene.FromFile() as an alternative:
var scene = Scene.FromFile("input.fbx");
scene.Save("output.stl");Format-Specific Options
Pass LoadOptions or SaveOptions subclasses for fine-grained control:
using Aspose.ThreeD;
using Aspose.ThreeD.Formats;
var scene = new Scene();
scene.Open("model.obj", new ObjLoadOptions { FlipCoordinateSystem = true });
scene.Save("model.fbx");Available option classes:
| Class | Direction | Key Properties |
|---|---|---|
ObjLoadOptions | Import | FlipCoordinateSystem, EnableMaterials, Scale |
ObjSaveOptions | Export | FlipCoordinateSystem, EnableMaterials, PointCloud |
FbxLoadOptions | Import | (default settings) |
GltfLoadOptions | Import | (default settings) |
GltfSaveOptions | Export | (default settings) |
StlLoadOptions | Import | (default settings) |
StlSaveOptions | Export | (default settings) |
ColladaLoadOptions | Import | FlipCoordinateSystem |
ColladaSaveOptions | Export | Indented, TransformStyle |
PlyLoadOptions | Import | (default settings) |
Building a Scene Graph
Create nodes and attach entities to build a hierarchy:
var scene = new Scene();
var root = scene.RootNode;
var boxNode = root.CreateChildNode("box", new Box(5, 5, 5));
var sphereNode = root.CreateChildNode("sphere", new Sphere(3));Access children via node.ChildNodes and the attached entity via node.Entity.
Mesh and Primitives
Create a Mesh programmatically with control points and polygons:
var mesh = new Mesh("custom");
mesh.ControlPoints.Add(new Vector4(0, 0, 0));
mesh.ControlPoints.Add(new Vector4(10, 0, 0));
mesh.ControlPoints.Add(new Vector4(10, 10, 0));
mesh.ControlPoints.Add(new Vector4(0, 10, 0));
mesh.CreatePolygon(0, 1, 2, 3);Built-in primitives (Box, Sphere, Cylinder) can be converted to Mesh:
var box = new Box(10, 10, 10);
Mesh boxMesh = box.ToMesh();Vertex Elements
Attach normals, UVs, and vertex colours to geometry:
var normals = new VertexElementNormal(MappingMode.ControlPoint, ReferenceMode.Direct);
mesh.AddElement(normals);Available vertex element types: VertexElementNormal, VertexElementUV, VertexElementVertexColor, VertexElementBinormal, VertexElementTangent.
Transforms
Every Node carries a Transform with Translation, Rotation, and Scale:
var node = scene.RootNode.CreateChildNode("moved", new Box());
node.Transform.Translation = new FVector3(10, 0, 5);
node.Transform.Scale = new FVector3(2, 2, 2);Read world-space position via node.GlobalTransform.Matrix or node.EvaluateGlobalTransform().
Materials
Assign materials to nodes for shading data:
var mat = new PhongMaterial("shiny");
mat.Diffuse = new Vector4(0.8, 0.2, 0.2, 1.0);
mat.Specular = new Vector4(1, 1, 1, 1);
mat.Shininess = 32;
scene.RootNode.CreateChildNode("red_box", new Box(), mat);Material types: LambertMaterial, PhongMaterial, PbrMaterial.
Tips and Best Practices
- Use
Scene.FromFile()for one-liner load when you do not need customLoadOptions - Convert primitives to
MeshwithToMesh()before adding vertex elements - Use
GltfSaveOptionswith a.glbextension for compact binary output - Check
node.Entityfornullbefore casting — not every node carries geometry - Use
PolygonModifier.Triangulate()to convert quad meshes before export to triangle-only formats like STL
Common Issues
| Issue | Cause | Fix |
|---|---|---|
ImportException on load | Unsupported or corrupted file | Verify the file opens in a 3D viewer; check the format is in the supported list |
| Missing materials after OBJ load | .mtl file not found | Place the .mtl file next to the .obj or set ObjLoadOptions.EnableMaterials = true |
| Scale mismatch after FBX import | Different unit systems | Use ObjLoadOptions.Scale or apply a Transform after loading |
FAQ
How do I detect the format of an unknown file?
Use FileFormat.Detect():
var format = FileFormat.Detect("unknown_file.bin");
Console.WriteLine(format.Extension);Can I load from a stream instead of a file path?
Yes. Scene.Open() accepts a Stream:
using var stream = File.OpenRead("model.glb");
scene.Open(stream);Which formats support both import and export?
OBJ, STL, glTF/GLB, FBX, COLLADA, and 3MF support both directions. PLY supports import only (the PLY exporter is not wired).
API Reference Summary
| Class / Method | Description |
|---|---|
Scene | Top-level 3D scene container |
Scene.Open() | Load a 3D file by path or stream |
Scene.Save() | Export scene to file or stream |
Scene.FromFile() | Static factory to load and return a Scene |
Node | Scene hierarchy node holding entities and transforms |
Node.CreateChildNode() | Create and attach a child node |
Mesh | Polygon mesh with control points and face lists |
Mesh.CreatePolygon() | Define a polygon face by vertex indices |
Box / Sphere / Cylinder | Built-in parametric primitives |
Transform | Local translation, rotation, and scale |
FileFormat | Registry and detector for supported formats |
LambertMaterial / PhongMaterial / PbrMaterial | Material types for shading |