scimesh 0.3.2
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
scimesh::obj_io Namespace Reference

Functions for reading OBJ files. More...

Functions

Mesh read_obj (const std::string &path)
 Load a mesh from a Wavefront OBJ file.
 

Detailed Description

Functions for reading OBJ files.

Function Documentation

◆ read_obj()

Mesh scimesh::obj_io::read_obj ( const std::string &  path)

Load a mesh from a Wavefront OBJ file.

Reads vertex positions, face indices, and optionally normals and texture coordinates from the file. OBJ is a text format — you can open .obj files in any text editor to inspect them.

Parameters
pathFilesystem path to the .obj file.
Returns
A Mesh populated with the file's geometry.
Exceptions
std::runtime_errorif the file cannot be opened or parsed.
Example
Mesh model = scimesh::obj_io::read_obj("teapot.obj");
if (!model.is_valid()) {
std::cerr << "Failed to load valid mesh from OBJ file\n";
}
Mesh read_obj(const std::string &path)
Load a mesh from a Wavefront OBJ file.
Definition obj_io.cpp:8
A 3D triangle mesh using an indexed face set representation.
Definition mesh.h:76
bool is_valid() const
Check whether the mesh is in a valid, renderable state.
Definition mesh.h:231
Supported features
  • Vertex positions (v)
  • Faces as triangles (f v1 v2 v3)
  • Quads and n-gons (fan-triangulated automatically)
  • Negative relative indices (e.g., f -1 -2 -3)
  • Face index slash notation (e.g., f 1/2/3, f 1//3)
Unsupported
  • Vertex normals (vn) — call compute_vertex_normals() after loading
  • Texture coordinates (vt) — UVs default to (0,0)
  • Materials (.mtl) — only geometry is loaded, colors are not imported from material files.
See also
read_ply(), read_stl(), Mesh::is_valid(), compute_vertex_normals()

Definition at line 8 of file obj_io.cpp.