Manifold 3.0
Robust geometry
 
Loading...
Searching...
No Matches
MeshIO

3D model file I/O based on Assimp More...

Classes

struct  Material
 
struct  ExportOptions
 

Functions

MeshGL ImportMesh (const std::string &filename, bool forceCleanup=false)
 
void ExportMesh (const std::string &filename, const MeshGL &mesh, const ExportOptions &options)
 

Detailed Description

3D model file I/O based on Assimp


Class Documentation

◆ manifold::Material

struct manifold::Material

PBR material properties for GLB/glTF files.

Class Members
double roughness = 0.2 Roughness value between 0 (shiny) and 1 (matte).
double metalness = 1 Metalness value, generally either 0 (dielectric) or 1 (metal).
vec3 color = vec3(1.0)

Color (RGB) multiplier to apply to the whole mesh (each value between 0 and 1).

int alpha = 1.0

Alpha multiplier to apply to the whole mesh (each value between 0 and 1).

int normalIdx = -1

Gives the property index where the first normal channel can be found. 0 indicates the first three property channels following position. A negative value does not save normals.

int colorIdx = -1

Gives the property index where the first color channel can be found. 0 indicates the first three property channels following position. A negative value does not save vertex colors.

int alphaIdx = -1

Gives the property index where the alpha channel can be found. 0 indicates the first property channel following position. A negative value does not save vertex alpha.

◆ manifold::ExportOptions

struct manifold::ExportOptions

These options only currently affect .glb and .gltf files.

Class Members
bool faceted = true

When false, vertex normals are exported, causing the mesh to appear smooth through normal interpolation.

Material mat = {} PBR material properties.

Function Documentation

◆ ImportMesh()

MeshGL ImportMesh ( const std::string & filename,
bool forceCleanup )

Imports the given file as a Mesh structure, which can be converted to a Manifold if the mesh is a proper oriented 2-manifold. Any supported polygon format will be automatically triangulated.

This is a very simple import function and is intended primarily as a demonstration. Generally users of this library will need to modify this to read all the important properties for their application and set up any custom data structures.

Parameters
filenameSupports any format the Assimp library supports.
forceCleanupThis merges identical vertices, which can break manifoldness. However it is always done for STLs, as they cannot possibly be manifold without this step.

◆ ExportMesh()

void ExportMesh ( const std::string & filename,
const MeshGL & mesh,
const ExportOptions & options )

Saves the Mesh to the desired file type, determined from the extension specified. In the case of .glb/.gltf, this will save in version 2.0.

This is a very simple export function and is intended primarily as a demonstration. Generally users of this library will need to modify this to write all the important properties for their application and read any custom data structures.

Parameters
filenameThe file extension must be one that Assimp supports for export. GLB & 3MF are recommended.
meshThe mesh to export, likely from Manifold.GetMeshGL().
optionsThe options currently only affect an exported GLB's material. Pass {} for defaults.