Introduction

Aspose.3D FOSS is a free, open-source .NET library for working with 3D file formats. It provides a comprehensive set of utility classes that go beyond simple file conversion, enabling developers to manipulate meshes, build transforms, and generate primitive geometry programmatically. The library is released under the MIT license, making it suitable for both personal and commercial projects without restrictions.

This post focuses on the utility capabilities within the library: the classes and methods you reach for when you need to triangulate a mesh, construct a transformation matrix step by step, or create parametric geometry. These building blocks complement the core scene-loading and scene-saving workflow covered in the introductory post.

Whether you are processing 3D assets in a build pipeline, preparing geometry for a game engine, or converting between formats, these utilities handle the common tasks that arise in real-world 3D workflows.


What’s Included

Mesh Operations

The Mesh class represents polygon-based geometry. You can create polygons from vertex indices, query polygon sizes, triangulate faces, and optimize vertex data. The ControlPoints property provides direct access to the vertex positions, while Polygons exposes the face index arrays.

using Aspose.ThreeD;
using Aspose.ThreeD.Entities;

var scene = new Scene();
var mesh = new Mesh("CustomMesh");

// Add control points (vertices)
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));

// Create a quad polygon from four vertices
mesh.CreatePolygon(0, 1, 2, 3);

// Triangulate all polygons in the mesh
mesh.Triangulate();

Transform Builder

The TransformBuilder class provides a fluent interface for constructing transformation matrices through a sequence of translate, rotate, and scale operations. You control the composition order (append or prepend) and can reset the builder to start a fresh chain.

using Aspose.ThreeD;
using Aspose.ThreeD.Utilities;

var builder = new TransformBuilder(ComposeOrder.Append);

// Build a combined transform: translate, then rotate, then scale
builder.Translate(5, 0, 3);
builder.RotateDegree(45, new Vector3(0, 1, 0));
builder.Scale(2, 2, 2);

// Retrieve the composed 4x4 matrix
Matrix4 result = builder.Matrix;

Polygon Modifier

The PolygonModifier class offers static utility methods for mesh processing. Its Triangulate method converts any n-sided polygon mesh into triangle-only geometry, which is the required input for most rendering engines and physics simulations.

using Aspose.ThreeD;
using Aspose.ThreeD.Entities;

var scene = new Scene();
var box = new Box(2, 2, 2);
Mesh boxMesh = box.ToMesh();

// Convert all polygons to triangles
Mesh triangulated = PolygonModifier.Triangulate(boxMesh);

Primitive Geometry Generation

The library includes parametric geometry classes such as Box, Sphere, and Cylinder. Each primitive can be configured with dimensions and segment counts, then converted to a Mesh via the ToMesh() method for further processing or export.

using Aspose.ThreeD.Entities;

// Create a parameterized sphere
var sphere = new Sphere(5.0, 32, 16);
Mesh sphereMesh = sphere.ToMesh();

// Create a cylinder (cone when one radius is zero)
var cone = new Cylinder(0, 3.0, 6.0);
Mesh coneMesh = cone.ToMesh();

Bounding Box Computation

Every Entity subclass exposes a GetBoundingBox() method that returns the axis-aligned bounding box of the geometry. The BoundingBox struct provides Minimum and Maximum corner vectors, useful for spatial queries and camera framing.

using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Utilities;

var box = new Box(4, 2, 6);
BoundingBox bounds = box.GetBoundingBox();

FVector3 min = bounds.Minimum;
FVector3 max = bounds.Maximum;

Quick Start

Install the package from NuGet:

dotnet add package Aspose.3D.Foss --version 1.0.0

Load a file, triangulate every mesh, and save the result:

using Aspose.ThreeD;
using Aspose.ThreeD.Entities;

// Load a scene from an OBJ file
var scene = new Scene();
scene.Open("input.obj");

// Walk child nodes and triangulate each mesh entity
foreach (var node in scene.RootNode.ChildNodes)
{
    foreach (var entity in node.Entities)
    {
        if (entity is Mesh mesh)
        {
            mesh.Triangulate();
        }
    }
}

// Save the triangulated scene as glTF
scene.Save("output.glb");

Supported Formats

FormatExtensionReadWrite
Collada.daeYesYes
FBX.fbxYesYes
glTF / GLB.gltf / .glbYesYes
3MF.3mfYesNo
Wavefront OBJ.objYesYes
PLY.plyYesNo
STL.stlYesYes
TMF.tmfNoYes

Open Source & Licensing

Aspose.3D FOSS is released under the MIT license. You can use, modify, and redistribute the library in both open-source and proprietary projects. The full source code is available on GitHub at aspose-3d-foss/Aspose.3D-FOSS-for-.NET.


Getting Started

  • Developer Guide – full documentation covering scene management, format options, and advanced features.
  • Knowledge Base – how-to articles and frequently asked questions.
  • API Reference – class-by-class reference with method signatures and property details.