|
| 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.
|
| |
| void | set_transform (size_t index, const Mat4 &transform) |
| | Set the placement transform of the mesh at index.
|
| |
| void | set_name (size_t index, const std::string &name) |
| | Set the name of the mesh at index.
|
| |
| const Mat4 & | transform (size_t index) const |
| | The placement transform of the mesh at index (identity when unset).
|
| |
| const std::string & | name (size_t index) const |
| | The name of the mesh at index (empty when unset).
|
| |
| size_t | size () const |
| | Number of meshes in the scene.
|
| |
| bool | empty () const |
| | Whether the scene holds no meshes.
|
| |
| SceneNodeRef | node (size_t index) const |
| | A non-owning reference to the mesh at index (mesh + transform + name).
|
| |
| std::vector< SceneNodeRef > | nodes () const |
| | Non-owning references to all meshes, in draw order.
|
| |
| 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 transform.
|
| |
A collection of Mesh objects to be rendered together.
A Scene is a list of meshes with optional per-mesh placement transforms and names. When rendered, meshes are drawn in order — later meshes appear on top of earlier ones. Each mesh's placement transform is applied as a model matrix at render time (meshes themselves are never modified).
Construction
scene.
add(cube, glm::translate(
Mat4(1.0f),
Vec3(2.0f, 0.0f, 0.0f)));
scene.
add(arrow_mesh, glm::rotate(
Mat4(1.0f), 0.5f,
Vec3(0,1,0)),
"arrow");
glm::mat4 Mat4
4×4 floating-point matrix.
glm::vec3 Vec3
3-component floating-point vector (xyz).
A collection of Mesh objects to be rendered together.
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.
For convenience the raw meshes vector is still public and can be modified directly (e.g. scene.meshes.push_back(m)); any mesh without a matching transform is treated as identity.
Bounding box
The combined bounding box of all meshes (after their transforms) can be computed for camera framing:
Camera camera_look_at(const Vec3 ¢er, float radius, const Vec3 &direction, const Vec3 &up, float fov_degrees, float margin, ProjectionType projection)
Create a camera that looks at a point from a given distance and direction.
A virtual camera that defines the viewpoint for rendering.
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...
- See also
- Mesh, SceneNodeRef, Renderer::render_scene(), camera_fit_scene()
Definition at line 57 of file scene.h.