![]() |
Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
|
Represents a hierarchical 2D transform component. More...
#include <scene_component_2d.hpp>
Public Member Functions | |
| SceneComponent2D () | |
| Constructs a SceneComponent2D with identity transform. More... | |
| virtual | ~SceneComponent2D ()=default |
| Destructor. More... | |
| void | SetPosition (const glm::vec2 &position) |
| Sets the local position of this component. More... | |
| void | SetRotation (float angleDegrees) |
| Sets the rotation angle in degrees. More... | |
| void | SetScale (const glm::vec2 &scale) |
| Sets the scale in each dimension. More... | |
| const glm::vec2 & | GetPosition () const |
| Gets the current position. More... | |
| float | GetRotation () const |
| Gets the current rotation angle (in degrees). More... | |
| const glm::vec2 & | GetScale () const |
| Gets the current scale. More... | |
| glm::vec2 | GetWorldPosition () const |
| Returns the world-space position of this component. More... | |
| float | GetWorldRotation () const |
| Returns the accumulated world-space rotation. More... | |
| glm::vec2 | GetWorldScale () const |
| Returns the accumulated world-space scale. More... | |
| const glm::mat4 & | GetWorldMatrix () |
| Returns the world transformation matrix. More... | |
| void | UpdateLocalMatrix () |
| Recomputes the local transformation matrix. More... | |
| void | UpdateWorldMatrix () |
| Recomputes the world transformation matrix. More... | |
| void | AttachTo (SceneComponent2D *parent) |
| Attaches this scene component to a parent scene component. More... | |
| SceneComponent2D (const SceneComponent2D &rhs)=delete | |
| SceneComponent2D & | operator= (const SceneComponent2D &rhs)=delete |
Protected Attributes | |
| glm::vec2 | mPosition |
| float | mRotation |
| glm::vec2 | mScale |
| glm::mat4 | mLocalMatrix |
| glm::mat4 | mWorldMatrix |
| SceneComponent2D * | mParent |
| bool | bIsDirty |
Represents a hierarchical 2D transform component.
SceneComponent2D stores local 2D transformation state:
It supports parent-child relationships, allowing hierarchical transform propagation. When attached to a parent component, its world transform is computed as:
World = ParentWorld * Local
The engine uses a left-handed coordinate system:
Transform order is:
M = T * R * S
which results in object-space vertices being scaled, then rotated, then translated when applied.
The component uses a dirty-flag mechanism. World matrices are recomputed lazily when requested.
Definition at line 51 of file scene_component_2d.hpp.
| rendering_engine::SceneComponent2D::SceneComponent2D | ( | ) |
Constructs a SceneComponent2D with identity transform.
Initial state:
Definition at line 8 of file scene_component_2d.cpp.
|
virtualdefault |
Destructor.
|
delete |
| void rendering_engine::SceneComponent2D::AttachTo | ( | SceneComponent2D * | parent | ) |
Attaches this scene component to a parent scene component.
After attachment, this component's transform becomes relative to the parent. The world transformation is computed by combining the parent's world transform with this component's local transform.
Passing nullptr detaches the component and makes it a root-level component.
| parent | Pointer to the parent SceneComponent2D, or nullptr to detach. |
Definition at line 101 of file scene_component_2d.cpp.
|
inline |
Gets the current position.
Definition at line 96 of file scene_component_2d.hpp.
|
inline |
Gets the current rotation angle (in degrees).
Definition at line 102 of file scene_component_2d.hpp.
|
inline |
Gets the current scale.
Definition at line 108 of file scene_component_2d.hpp.
| const glm::mat4 & rendering_engine::SceneComponent2D::GetWorldMatrix | ( | ) |
Returns the world transformation matrix.
If the component is marked dirty, the world matrix will be recomputed before returning.
Definition at line 62 of file scene_component_2d.cpp.
| glm::vec2 rendering_engine::SceneComponent2D::GetWorldPosition | ( | ) | const |
Returns the world-space position of this component.
Extracted from the world transformation matrix.
Definition at line 38 of file scene_component_2d.cpp.
| float rendering_engine::SceneComponent2D::GetWorldRotation | ( | ) | const |
Returns the accumulated world-space rotation.
If attached to a parent, this includes parent rotation.
Definition at line 44 of file scene_component_2d.cpp.
| glm::vec2 rendering_engine::SceneComponent2D::GetWorldScale | ( | ) | const |
Returns the accumulated world-space scale.
If attached to a parent, this includes parent scaling.
Definition at line 52 of file scene_component_2d.cpp.
|
delete |
| void rendering_engine::SceneComponent2D::SetPosition | ( | const glm::vec2 & | position | ) |
Sets the local position of this component.
Marks the component as dirty so that world transformation will be recalculated when needed.
| position | Local position in 2D space. |
Definition at line 20 of file scene_component_2d.cpp.
| void rendering_engine::SceneComponent2D::SetRotation | ( | float | angleDegrees | ) |
Sets the rotation angle in degrees.
| angleDegrees | Angle in degrees (counterclockwise). |
Definition at line 26 of file scene_component_2d.cpp.
| void rendering_engine::SceneComponent2D::SetScale | ( | const glm::vec2 & | scale | ) |
Sets the scale in each dimension.
| scale | New scale as glm::vec2. |
Definition at line 32 of file scene_component_2d.cpp.
| void rendering_engine::SceneComponent2D::UpdateLocalMatrix | ( | ) |
Recomputes the local transformation matrix.
The local matrix is constructed as:
Local = T * R * S
This method does not compute the world matrix. Called internally by UpdateWorldMatrix().
Definition at line 71 of file scene_component_2d.cpp.
| void rendering_engine::SceneComponent2D::UpdateWorldMatrix | ( | ) |
Recomputes the world transformation matrix.
Combines parent world matrix (if any) with the local matrix:
World = ParentWorld * Local
Clears the dirty flag after update.
Definition at line 86 of file scene_component_2d.cpp.
|
protected |
Definition at line 190 of file scene_component_2d.hpp.
|
protected |
Definition at line 186 of file scene_component_2d.hpp.
|
protected |
Definition at line 189 of file scene_component_2d.hpp.
|
protected |
Definition at line 182 of file scene_component_2d.hpp.
|
protected |
Definition at line 183 of file scene_component_2d.hpp.
|
protected |
Definition at line 184 of file scene_component_2d.hpp.
|
protected |
Definition at line 187 of file scene_component_2d.hpp.