CGVIS Utils
Loading...
Searching...
No Matches
OBJFile Class Reference

#include <OBJFile.h>

Public Types

typedef std::array< size_t, 3 > IndexType
 Index triple forming one triangle (zero-based vertex indices).

Public Member Functions

 OBJFile (const std::string &filename, bool normalize=false)
 Load an OBJ file.

Public Attributes

std::vector< IndexType > indices
 Triangle index buffer (each element is one face as three indices).
std::vector< Vec3 > vertices
 Vertex positions parsed from "v" records (x,y,z).
std::vector< Vec3 > normals
 Per-vertex normals.

Member Typedef Documentation

◆ IndexType

typedef std::array<size_t, 3> OBJFile::IndexType

Index triple forming one triangle (zero-based vertex indices).

Note
Indices reference entries in vertices.

Constructor & Destructor Documentation

◆ OBJFile()

OBJFile::OBJFile ( const std::string & filename,
bool normalize = false )

Load an OBJ file.

Parameters
filenamePath to the .obj file.
normalizeIf true, recenter to AABB center and scale uniformly by the longest extent so the model fits into a unit cube.
Exceptions
std::runtime_errorOn I/O failures or malformed input (thrown from stream operations or conversions).
Here is the call graph for this function:

Member Data Documentation

◆ indices

std::vector<IndexType> OBJFile::indices

Triangle index buffer (each element is one face as three indices).

◆ normals

std::vector<Vec3> OBJFile::normals

Per-vertex normals.

If the file lacks "vn" records, these are computed by summing face normals around each vertex and normalizing.

◆ vertices

std::vector<Vec3> OBJFile::vertices

Vertex positions parsed from "v" records (x,y,z).


The documentation for this class was generated from the following files: