2#include <glm/gtc/matrix_transform.hpp>
3#include <glm/gtc/constants.hpp>
10 mPosition{ 0.0f, 0.0f },
41 return glm::vec2(world[3]);
48 float angle = atan2(world[1][0], world[0][0]);
49 return glm::degrees(angle);
57 glm::length(glm::vec2(world[0])),
58 glm::length(glm::vec2(world[1]))
79 const glm::mat4 S = glm::scale(glm::mat4(1.0f), glm::vec3(
mScale, 1.0f));
80 const glm::mat4 R = glm::rotate(glm::mat4(1.0f), r, glm::vec3(0.0f, 0.0f, 1.0f));
81 const glm::mat4 T = glm::translate(glm::mat4(1.0f), glm::vec3(
mPosition, 0.0f));
Represents a hierarchical 2D transform component.
void UpdateLocalMatrix()
Recomputes the local transformation matrix.
SceneComponent2D()
Constructs a SceneComponent2D with identity transform.
void UpdateWorldMatrix()
Recomputes the world transformation matrix.
glm::vec2 GetWorldScale() const
Returns the accumulated world-space scale.
glm::vec2 GetWorldPosition() const
Returns the world-space position of this component.
void AttachTo(SceneComponent2D *parent)
Attaches this scene component to a parent scene component.
void SetScale(const glm::vec2 &scale)
Sets the scale in each dimension.
float GetWorldRotation() const
Returns the accumulated world-space rotation.
const glm::mat4 & GetWorldMatrix()
Returns the world transformation matrix.
void SetRotation(float angleDegrees)
Sets the rotation angle in degrees.
void SetPosition(const glm::vec2 &position)
Sets the local position of this component.
SceneComponent2D * mParent