|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Represents a node in a scene graph. More...
#include <node.hpp>
Public Member Functions | |
| Node (const std::string &name="Node") | |
| Constructor for the Node class. | |
| ~Node ()=default | |
| Destructor for the Node class. | |
| void | set_position (const glm::vec3 &position) |
| Set the position of the node. | |
| void | set_rotation (const glm::quat &rotation) |
| Set the rotation of the node. | |
| void | set_rotation (const glm::vec3 &euler_angles) |
| Set the rotation of the node using Euler angles. | |
| void | set_scale (const glm::vec3 &scale) |
| Set the scale of the node. | |
| void | set_scale (float scale) |
| Set the uniform scale of the node. | |
| const glm::vec3 & | get_position () const |
| Getters for position, rotation, scale, and transforms. | |
| const glm::quat & | get_rotation () const |
| Get the rotation of the node. | |
| const glm::vec3 & | get_scale () const |
| Get the scale of the node. | |
| void | rotate (float angle, const glm::vec3 &axis) |
| Rotate the node around a specified axis. | |
| glm::vec3 | get_euler_angles () const |
| Get the Euler angles of the node's rotation. | |
| void | look_at (const glm::vec3 &target, const glm::vec3 &up=glm::vec3(0.0f, 1.0f, 0.0f)) |
| Make the node look at a target point. | |
| glm::mat4 | get_local_transform () const |
| Get the local and world transforms of the node. | |
| glm::mat4 | get_world_transform () const |
| Get the world transform of the node. | |
| void | add_child (std::shared_ptr< Node > child) |
| Manage child nodes. | |
| void | remove_child (std::shared_ptr< Node > child) |
| Remove a child node. | |
| std::shared_ptr< Node > | get_parent () const |
| Getters for parent and children. | |
| const std::vector< std::shared_ptr< Node > > & | get_children () const |
| Get the list of child nodes. | |
| void | detach_from_parent () |
| Detach the node from its parent. | |
| void | update_transform (const glm::mat4 &par_transform=glm::mat4(1.0f)) |
| Update transforms. | |
| void | set_mesh (std::shared_ptr< Mesh > mesh) |
| Manage the mesh associated with the node. | |
| std::shared_ptr< Mesh > | get_mesh () const |
| Get the mesh associated with the node. | |
| bool | has_mesh () const |
| Check if the node has an associated mesh. | |
| std::string & | get_name () |
| Getters and setters for the node's name. | |
| void | set_name (const std::string &name) |
| Set the name of the node. | |
| std::shared_ptr< Light > | get_light () const |
| Retrieves the light associated with the node. | |
| void | set_light (std::shared_ptr< Light > light) |
| Set the light associated with the node. | |
| bool | has_light () const |
| Check if node has a light. | |
| void | set_lod (std::shared_ptr< LOD > lod) |
| Set the LOD (Level of Detail) for the node. | |
| std::shared_ptr< LOD > | get_lod () const |
| Get the LOD (Level of Detail) associated with the node. | |
| bool | has_lod () const |
| Check if the node has an associated LOD with levels. | |
| std::shared_ptr< Mesh > | get_mesh_for_rendering (const glm::vec3 &camera_pos) const |
| Get the appropriate mesh for rendering based on camera position. | |
Represents a node in a scene graph.
The Node class encapsulates the properties and behaviors of a node in a 3D scene graph. Each node can have a position, rotation, scale, and can contain child nodes, forming a hierarchical structure. Nodes can also hold a reference to a Mesh object.
| lmgl::scene::Node::Node | ( | const std::string & | name = "Node" | ) |
| void lmgl::scene::Node::add_child | ( | std::shared_ptr< Node > | child | ) |
Manage child nodes.
Methods to add and remove child nodes, retrieve the parent node, get the list of child nodes, and detach the node from its parent.
| child | Child node to be added or removed. |
| void lmgl::scene::Node::detach_from_parent | ( | ) |
Detach the node from its parent.
Removes this node from its parent's list of children.
|
inline |
Get the list of child nodes.
Provides access to the vector of child nodes.
| glm::vec3 lmgl::scene::Node::get_euler_angles | ( | ) | const |
Get the Euler angles of the node's rotation.
Converts the node's quaternion rotation to Euler angles (in radians).
|
inline |
Retrieves the light associated with the node.
|
inline |
Get the local and world transforms of the node.
Provides access to the node's local and world transformation matrices.
|
inline |
|
inline |
| std::shared_ptr< Mesh > lmgl::scene::Node::get_mesh_for_rendering | ( | const glm::vec3 & | camera_pos | ) | const |
Get the appropriate mesh for rendering based on camera position.
Selects the appropriate mesh level of detail based on the distance from the camera to the node.
| camera_position | Position of the camera in world space. |
|
inline |
Getters and setters for the node's name.
Provides access to the node's name property.
|
inline |
Getters for parent and children.
Provides access to the parent node and the list of child nodes.
|
inline |
Getters for position, rotation, scale, and transforms.
Provides access to the node's position, rotation, scale, local transform, and world transform.
|
inline |
Get the rotation of the node.
Provides access to the node's rotation as a quaternion.
|
inline |
Get the scale of the node.
Provides access to the node's scale.
|
inline |
Get the world transform of the node.
Provides access to the node's world transformation matrix.
|
inline |
|
inline |
| void lmgl::scene::Node::look_at | ( | const glm::vec3 & | target, |
| const glm::vec3 & | up = glm::vec3(0.0f, 1.0f, 0.0f) ) |
Make the node look at a target point.
Adjusts the node's rotation so that it faces the specified target point.
| target | Target point to look at as a glm::vec3. |
| up | Up direction for the node (default is world up). |
| void lmgl::scene::Node::remove_child | ( | std::shared_ptr< Node > | child | ) |
Remove a child node.
Detaches the specified child node from this node.
| child | Child node to be removed. |
| void lmgl::scene::Node::rotate | ( | float | angle, |
| const glm::vec3 & | axis ) |
Rotate the node around a specified axis.
Applies a rotation to the node by a given angle around the specified axis.
| angle | Rotation angle in radians. |
| axis | Axis of rotation as a glm::vec3. |
|
inline |
Set the light associated with the node.
| light | The new light associated with the node |
|
inline |
|
inline |
|
inline |
Set the name of the node.
Updates the node's name property.
| name | New name for the node. |
| void lmgl::scene::Node::set_position | ( | const glm::vec3 & | position | ) |
Set the position of the node.
Updates the node's position in 3D space.
| position | New position as a glm::vec3. |
| void lmgl::scene::Node::set_rotation | ( | const glm::quat & | rotation | ) |
Set the rotation of the node.
Updates the node's rotation using a quaternion.
| rotation | New rotation as a glm::quat. |
| void lmgl::scene::Node::set_rotation | ( | const glm::vec3 & | euler_angles | ) |
Set the rotation of the node using Euler angles.
Updates the node's rotation based on Euler angles (in radians).
| euler_angles | New rotation as a glm::vec3 representing Euler angles. |
| void lmgl::scene::Node::set_scale | ( | const glm::vec3 & | scale | ) |
Set the scale of the node.
Updates the node's scale in 3D space.
| scale | New scale as a glm::vec3. |
| void lmgl::scene::Node::set_scale | ( | float | scale | ) |
Set the uniform scale of the node.
Updates the node's scale uniformly in all dimensions.
| scale | New uniform scale as a float. |
| void lmgl::scene::Node::update_transform | ( | const glm::mat4 & | par_transform = glm::mat4(1.0f) | ) |
Update transforms.
Updates the world transformation matrices of the node. This method should be called whenever the node's position, rotation, or scale changes, or when the parent's transform is updated.
| par_transform | Parent's world transform matrix (default is identity). |