Object2D
base class for all 2d nodes (hud, panels, images).
All other 2D objects inherit from this class. This is the foundation
class that provides:
- Basic identification (name, id, uuid)
- 2d transform (x, y, rotationZ, scale)
- size and opacity
- simple graph (parent, children)
- local/world matrices
Methods
Object2D::Object2D()
default constructor – initializes to identity and sensible defaults
Object2D::Object2D(const string& name)
constructor with custom name
| name | human-readable name for the object |
void Object2D::add(Object2D* child)
adds a child object to this node
| child | child node to add |
void Object2D::remove(Object2D* child)
removes a child from this node
| child | child node to remove |
void Object2D::removeFromParent()
detaches this node from its parent
void Object2D::clear()
removes all children from this node
void Object2D::translate(f32 dx, f32 dy)
translates the node in screen space
| dx | delta x | |
| dy | delta y |
void Object2D::translate(const Vector2& offset)
translates the node by vector offset
| offset | vector containing translation amounts |
void Object2D::rotate(f32 rad)
rotates the node
| rad | rotation in radians |
void Object2D::scale(f32 sx, f32 sy)
scales the node in x and y
| sx | scale x | |
| sy | scale y |
void Object2D::scale(const Vector2& scaleVec)
scales the node by vector
| scaleVec | vector containing scale factors |
void Object2D::updateMatrix()
updates local matrix from transform fields
void Object2D::updateMatrixWorld(bool force)
updates world matrix, optionally forcing child updates
| force | propagate to children |
void Object2D::updateWorldMatrix(bool updateParents, bool updateChildren)
updates world matrix with optional parent/child traversal
| updateParents | whether to update parents first | |
| updateChildren | whether to update children after |
Object2D* Object2D::clone(bool recursive) const
creates a copy of this node
| recursive | also clone descendants |
void Object2D::copy(const Object2D& object, bool recursive)
copies properties from another node
| object | source node | |
| recursive | also copy descendants |
virtual void render()
Renders this 2D object and its children
void renderText()
Renders text using console font
Properties
| backgroundColor | Color | background color |
| backgroundImage | Texture* | background image texture |
| children | vector<Object2D*> | possible children |
| color | Color | RGBA color for rectangle rendering |
| enabled | bool | active/inactive |
| fontCols | u32 | font texture columns (default 16) |
| fontRows | u32 | font texture rows (default 16) |
| fontTexture | Texture* | custom font texture (nullptr = use console font) |
| height | f32 | preferred height |
| id | u32 | unique identifier |
| isObject2D | bool | read-only tag |
| matrix | Mtx& | local pos / rot / scale matrix |
| matrixAutoUpdate | bool | auto-update matrices every frame |
| matrixNeedsUpdate | bool | flag to recalculate matrices |
| matrixWorld | Mtx& | global pos / rot / scale matrix |
| matrixWorldAutoUpdate | bool | auto-update world matrices |
| matrixWorldNeedsUpdate | bool | flag to recalculate world matrices |
| name | string | optional display name |
| opacity | f32 | 0..1 |
| parent | Object2D* | nullptr if not existing |
| position | Vector2 | position in 2D space |
| rotation | f32 | rotation in radians |
| scaleFactors | Vector2 | scale factors for X and Y axes |
| text | string | text to display |
| textColor | Color | text color (RGBA) |
| textEnabled | bool | enable/disable text rendering |
| textSize | u32 | text size multiplier |
| uuid | string | uuid string |
| version | u32 | bumps on change |
| visible | bool | visibility flag |
| width | f32 | preferred width |
| zIndex | int | draw order inside ui |