Features and Functionalities

Features and Functionalities

Features and Functionalities

This page covers every major feature area of aspose-3d-foss 26.1.0 with working Java examples.


Loading and Saving Scenes

scene.open() loads a file; scene.save() exports it:

import com.aspose.threed.Scene;

Scene scene = new Scene();
scene.open("input.obj");
scene.save("output.glb");

Static factory alternative:

Scene scene = Scene.fromFile("input.fbx");
scene.save("output.stl");

Format-Specific Options

Pass LoadOptions or SaveOptions subclasses for fine-grained control:

import com.aspose.threed.*;

Scene scene = new Scene();
ObjLoadOptions opts = new ObjLoadOptions();
opts.setFlipCoordinateSystem(true);
scene.open("model.obj", opts);

GltfSaveOptions saveOpts = new GltfSaveOptions();
saveOpts.setFlipCoordinateSystem(true);
scene.save("model.glb", saveOpts);

Note: FBX is supported for import only. FBX export is not implemented in the FOSS version.


Building a Scene Graph

Create nodes and attach entities:

Scene scene = new Scene();
Node root = scene.getRootNode();

Mesh mesh = new Mesh("myMesh");
mesh.getControlPoints().add(new Vector4(0, 0, 0));
mesh.getControlPoints().add(new Vector4(10, 0, 0));
mesh.getControlPoints().add(new Vector4(10, 10, 0));
mesh.createPolygon(0, 1, 2);

Node meshNode = root.createChildNode("triangle", mesh);

Mesh Operations

Create a Mesh programmatically with control points and polygons:

Mesh mesh = new Mesh("custom");
mesh.getControlPoints().add(new Vector4(0, 0, 0));
mesh.getControlPoints().add(new Vector4(10, 0, 0));
mesh.getControlPoints().add(new Vector4(10, 10, 0));
mesh.getControlPoints().add(new Vector4(0, 10, 0));
mesh.createPolygon(0, 1, 2, 3);

Transforms

Every Node carries a Transform:

Node node = scene.getRootNode().createChildNode("moved", new Mesh());
node.getTransform().setTranslation(10, 0, 5);
node.getTransform().setScale(2, 2, 2);

Read world-space via node.getGlobalTransform().getMatrix().


Materials

Assign materials to nodes:

PbrMaterial mat = new PbrMaterial("shiny");
mat.setAlbedo(new Vector4(0.8, 0.2, 0.2, 1.0));
mat.setMetallicFactor(0.5);
mat.setRoughnessFactor(0.3);

scene.getRootNode().createChildNode("red_mesh", mesh, mat);

Material types: Material (base), PbrMaterial (PBR metallic-roughness).


Tips and Best Practices

  • Use Scene.fromFile() for one-liner loads when custom options are not needed
  • Build meshes programmatically with createPolygon() for custom geometry
  • Use .glb extension for compact binary glTF output
  • Check node.getEntity() != null before casting
  • STL export automatically triangulates polygon faces

Common Issues

IssueCauseFix
Exception on loadUnsupported or corrupted fileVerify the file opens in a 3D viewer
Missing materials after OBJ load.mtl file not foundPlace .mtl next to .obj; ensure materials are enabled
Scale mismatch after importDifferent unit systemsApply a Transform scale after loading

FAQ

How do I detect a file’s format?

FileFormat format = FileFormat.detect("unknown.bin");
System.out.println(format.getExtension());

Can I load from a stream?

Yes. scene.open() accepts an InputStream.

Which formats support both import and export?

OBJ, STL, and glTF/GLB support both directions. FBX is import-only; export is not implemented in the FOSS version.


API Reference Summary

Class / MethodDescription
SceneTop-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
NodeScene hierarchy node
node.createChildNode()Create and attach a child node
MeshPolygon mesh with control points and face lists
mesh.createPolygon()Define a polygon face
Mesh.toMesh()Convert or clone mesh geometry
TransformLocal translation, rotation, and scale
FileFormatRegistry and detector for formats