CGVIS Utils
Loading...
Searching...
No Matches
OBJFile.h File Reference

Minimal Wavefront OBJ loader collecting vertices, triangle indices, and normals. More...

#include <vector>
#include <array>
#include <string>
#include <sstream>
#include "Vec3.h"
Include dependency graph for OBJFile.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  OBJFile

Detailed Description

Minimal Wavefront OBJ loader collecting vertices, triangle indices, and normals.

Parses a subset of the Wavefront OBJ format sufficient for simple triangle meshes. The constructor reads the file, extracts vertex positions ("v"), vertex normals ("vn"; optional), and triangular faces ("f"). Indices are stored zero-based. If normals are not provided, they are computed as area-weighted vertex normals from face geometry.

  • Faces are expected to be triangles; non-triangular faces are ignored.
  • Only position and normal records are recognized; texture coordinates are ignored.
  • When normalize is true, positions are recentered to the AABB center and uniformly scaled to fit into the unit cube (longest AABB side maps to 1).