|
scimesh 0.3.2
Headless CPU-only 3D software renderer for scientific mesh visualization
|
A 3D triangle mesh using an indexed face set representation. More...
#include <mesh.h>

Public Member Functions | |
| bool | has_colors () const |
| Does the mesh have per-vertex colors? | |
| bool | has_face_colors () const |
| Does the mesh have per-face colors? | |
| bool | has_normals () const |
| Does the mesh have per-vertex normals? | |
| bool | has_uvs () const |
| Does the mesh have texture coordinates? | |
| bool | has_texture () const |
| Does the mesh have a texture image? | |
| bool | is_valid () const |
| Check whether the mesh is in a valid, renderable state. | |
| bool | empty () const |
| Is the mesh empty (no renderable geometry)? | |
| void | compute_bounding_box (Vec3 &min_bound, Vec3 &max_bound) const |
| Compute the axis-aligned bounding box (AABB) of the mesh. | |
Public Attributes | |
Required data | |
| std::vector< Vec3 > | vertices |
| 3D vertex positions. | |
| std::vector< Triangle > | triangles |
| Triangle index triplets. | |
Optional per-vertex data | |
| std::vector< Color > | colors |
| Per-vertex RGBA colors. | |
| std::vector< Color > | face_colors |
| Per-face RGBA colors. | |
| std::vector< Vec3 > | normals |
| Per-vertex surface normals (unit-length direction vectors). | |
| std::vector< Vec2 > | uvs |
| Per-vertex texture coordinates (UVs). | |
Optional texture | |
| Image | texture |
| An optional texture image mapped via UV coordinates. | |
Default appearance | |
| Color | default_color = DEFAULT_COLOR |
| Fallback color when no per-vertex or per-face color is set. | |
| bool | has_transparency = false |
| Whether the mesh contains any transparent fragments. | |
A 3D triangle mesh using an indexed face set representation.
The Mesh is the heart of scimesh. It holds:
The mesh uses an indexed face set. This means vertices are stored exactly once, and triangles store indices into the vertex array. This saves memory when vertices are shared by multiple triangles.
There is no special constructor — create an empty mesh and populate it:
Or use one of the generator functions:
Or load from a file:
Call is_valid() before rendering to detect common problems:
Compute the axis-aligned bounding box (AABB) of the mesh.
The bounding box is the smallest box aligned with the X, Y, and Z axes that contains all mesh vertices. Output is written to the two Vec3 reference parameters.
| [out] | min_bound | The corner with the smallest x, y, z values. |
| [out] | max_bound | The corner with the largest x, y, z values. |
|
inline |
Is the mesh empty (no renderable geometry)?
true if there are no vertices or no triangles.
|
inline |
|
inline |
|
inline |
Does the mesh have per-vertex normals?
true if normals is not empty.
|
inline |
|
inline |
|
inline |
Check whether the mesh is in a valid, renderable state.
This performs several checks:
vertices and triangles are non-empty.[0, vertices.size()).colors, face_colors, normals, uvs) are present, they must have the expected size (one element per vertex or per face, as appropriate).is_valid() to catch errors before rendering. A mesh that fails validation will either produce garbage output or crash the renderer.true if the mesh passes all checks. | std::vector<Color> scimesh::Mesh::colors |
Per-vertex RGBA colors.
If non-empty, must have exactly vertices.size() elements. Used for vertex-colored rendering (interpolated across triangles).
| Color scimesh::Mesh::default_color = DEFAULT_COLOR |
Fallback color when no per-vertex or per-face color is set.
Defaults to DEFAULT_COLOR (neutral light gray). You can change this to give a mesh a uniform color without populating colors.
| std::vector<Color> scimesh::Mesh::face_colors |
Per-face RGBA colors.
If non-empty, must have exactly triangles.size() elements. Overrides per-vertex colors when present (flat shading by face).
| bool scimesh::Mesh::has_transparency = false |
| std::vector<Vec3> scimesh::Mesh::normals |
Per-vertex surface normals (unit-length direction vectors).
If non-empty, must have exactly vertices.size() elements. Normals are used for lighting calculations (Blinn-Phong shading).
You can compute normals automatically with compute_vertex_normals().
| Image scimesh::Mesh::texture |
An optional texture image mapped via UV coordinates.
When set (width > 0), the rasterizer samples this image using the mesh's UV coordinates to color each pixel.
| std::vector<Triangle> scimesh::Mesh::triangles |
| std::vector<Vec2> scimesh::Mesh::uvs |
| std::vector<Vec3> scimesh::Mesh::vertices |