76 const std::string &
name =
"") {
84 if (index >=
meshes.size())
93 if (index >=
meshes.size())
95 while (
names.size() <= index)
102 static const Mat4 kIdentity(1.0f);
109 const std::string &
name(
size_t index)
const {
110 static const std::string kEmpty;
111 if (index >=
names.size())
134 std::vector<SceneNodeRef>
nodes()
const {
135 std::vector<SceneNodeRef> out;
136 out.reserve(
meshes.size());
137 for (
size_t i = 0; i <
meshes.size(); ++i)
138 out.push_back(
node(i));
154 for (
size_t i = 0; i <
meshes.size(); ++i) {
158 Vec3 mesh_min, mesh_max;
161 for (
int c = 0; c < 8; ++c) {
163 (c & 1) ? mesh_max.x : mesh_min.x,
164 (c & 2) ? mesh_max.y : mesh_min.y,
165 (c & 4) ? mesh_max.z : mesh_min.z);
172 min_bound = glm::min(min_bound, t);
173 max_bound = glm::max(max_bound, t);
178 min_bound =
Vec3(0.0f);
179 max_bound =
Vec3(0.0f);
Low-level math utilities for the rendering pipeline.
The Mesh — the central data structure for 3D geometry in scimesh.
glm::mat4 Mat4
4×4 floating-point matrix.
glm::vec3 Vec3
3-component floating-point vector (xyz).
Vec3 transform_point(const Mat4 &m, const Vec3 &p)
Transform a point by a 4×4 matrix (with implicit w=1).
A 3D triangle mesh using an indexed face set representation.
void compute_bounding_box(Vec3 &min_bound, Vec3 &max_bound) const
Compute the axis-aligned bounding box (AABB) of the mesh.
std::vector< Vec3 > vertices
3D vertex positions.
A lightweight, non-owning reference to one mesh in a scene, together with its placement transform (an...
std::string name
Optional node name (used by exporters / debugging).
Mat4 transform
Model matrix placing the mesh in world space (identity = as-is).
const Mesh * mesh
Pointer to the owned mesh (never null for a valid node).
A collection of Mesh objects to be rendered together.
void set_transform(size_t index, const Mat4 &transform)
Set the placement transform of the mesh at index.
std::vector< Mesh > meshes
The meshes in this scene, drawn in order.
bool empty() const
Whether the scene holds no meshes.
void compute_bounding_box(Vec3 &min_bound, Vec3 &max_bound) const
Compute the combined axis-aligned bounding box of all meshes, after applying each mesh's placement tr...
std::vector< Mat4 > transforms
Per-mesh placement transforms, parallel to meshes.
const Mat4 & transform(size_t index) const
The placement transform of the mesh at index (identity when unset).
size_t size() const
Number of meshes in the scene.
void set_name(size_t index, const std::string &name)
Set the name of the mesh at index.
std::vector< SceneNodeRef > nodes() const
Non-owning references to all meshes, in draw order.
std::vector< std::string > names
Optional per-mesh node names, parallel to meshes.
void add(const Mesh &mesh, const Mat4 &transform=Mat4(1.0f), const std::string &name="")
Add a mesh to the scene with an optional placement transform and name.
const std::string & name(size_t index) const
The name of the mesh at index (empty when unset).
SceneNodeRef node(size_t index) const
A non-owning reference to the mesh at index (mesh + transform + name).