Skip to main content

read_obj

Function read_obj 

Source
pub fn read_obj(filename: &str) -> Result<(Vec<[f64; 3]>, Vec<[usize; 3]>)>
Expand description

Reads a Wavefront OBJ file and extracts vertex and face data.

This function parses lines beginning with ’v ’ for vertices and ’f ’ for faces. It correctly handles the 1-based indexing of the OBJ format for faces and can parse complex face definitions (e.g., f v/vt/vn or f v//vn).

§Arguments

  • filename - The path to the .obj file.

§Returns

A Result containing a tuple with:

  • Vec<[f64; 3]>: The vector of vertex positions (nodes).
  • Vec<[usize; 3]>: The vector of triangle indices (cells).