TransformModule is a built-in Module that tracks a Unit’s spatial data in 2D space. It stores position, rotation, and scale asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/raoulkdev/MiniECS/llms.txt
Use this file to discover all available pages before exploring further.
glm::vec2 values from the GLM math library, and prints those values to stdout when start() is called via its lifecycle override. Attach it to any Unit in your scene to give that Unit a trackable location and orientation in 2D world space.
Class Definition
TransformModule inherits fromModule and extends it with three public glm::vec2 fields and a start() override. The constructor is inherited directly from the base class via using Module::Module.
Fields
position
Type:
glm::vec2The Unit’s 2D position in world space. Components are x and y. Default-initialized to {0, 0}.rotation
Type:
glm::vec2The Unit’s 2D rotation values. Components are x and y. Default-initialized to {0, 0}.scale
Type:
glm::vec2The Unit’s 2D scale values. Components are x and y. Default-initialized to {0, 0}.The start() Override
When start() is called, it prints the current values of all three transform fields to stdout in a single formatted line. The output follows this pattern:
position, rotation, and scale fields, so any modifications made before the scene is played are reflected in the output.
Attaching TransformModule to a Unit
CalladdModule on a Unit pointer, passing MiniECS::ModuleType::Transform as the argument. The module is constructed and stored internally by the Unit.
Retrieving and Modifying Transform Data
UsegetModule<MiniECS::TransformModule>() on the Unit to obtain a raw pointer to the attached TransformModule. Always check for nullptr before accessing fields — the module may not be attached.
rotation and scale fields are modified the same way:
GLM Dependency
TransformModule includes GLM using a hardcoded absolute path at the top ofTransformModule.h:
Expected Output
Given a Unit withposition set to {22.5f, 33.4f} and all other fields at their default {0, 0} values, TransformModule produces the following output when start() is called: