Module obj

Module obj 

Source
Expand description

Wavefront OBJ format import and export.

This module provides conversion between OBJ files and 3MF Model structures.

§OBJ Format

The Wavefront OBJ format is a text-based 3D geometry format. This implementation supports a basic subset of the full OBJ specification:

Supported features:

  • v - Vertex positions (x, y, z)
  • f - Faces (vertex indices)
  • Polygon faces (automatically triangulated using fan triangulation)

Ignored features:

  • vt - Texture coordinates
  • vn - Vertex normals
  • g - Group names
  • usemtl - Material references
  • mtllib - Material library files

§Examples

§Importing OBJ

use lib3mf_converters::obj::ObjImporter;
use std::fs::File;

let file = File::open("model.obj")?;
let model = ObjImporter::read(file)?;
println!("Imported model with {} build items", model.build.items.len());

§Exporting OBJ

use lib3mf_converters::obj::ObjExporter;
use lib3mf_core::model::Model;
use std::fs::File;

let file = File::create("output.obj")?;
ObjExporter::write(&model, file)?;

Structs§

ObjExporter
Exports 3MF Model structures to Wavefront OBJ files.
ObjImporter
Imports Wavefront OBJ files into 3MF Model structures.