scimesh 0.3.4
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 and face indices 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
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
int x
Left edge of the bitmap, in image pixels.
Definition text.cpp:223
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) — no UVs are loaded, so textured rendering needs UVs that you assign yourself (see Mesh::uvs). The data is parsed by libfs, so supporting vt would be a small addition; until then the renderer gets no UVs from an OBJ file.
  • 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.