CheeseEngine
A 2D Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
phys2d::TransformComponent Struct Reference

#include <types.hpp>

Public Member Functions

void updateMatrix () const
 recalculates the model matrix
 
 TransformComponent ()=default
 default concstructor for TransformComponent
 
 TransformComponent (const glm::vec2 &position, float rotation, float scaling)
 constructor for TransformComponent with all fields
 
const glm::vec2 getForward () const
 gives the forward vector of an object. Can be used for cannons and bullets, for example
 
void move (const glm::vec2 &direction)
 changes the object's position: (x, y) -> (x + direction.x, y + direction.y)
 
void rotate (float angle_delta)
 rotates the object
 
void scale (float scale_coef)
 scales the object
 
Setters
void setPosition (const glm::vec2 &new_position)
 sets the new object's position on the grid
 
void setRotation (const float new_angle)
 sets the new object's rotation in radians, clockwise
 
void setScale (float new_scale)
 sets the new object's scaling coefficients
 

Public Attributes

glm::vec2 position {0.0f, 0.0f}
 global position of the object on the grid
 
float rotation {0.0f}
 rotation angle of the object, clockwise
 
float scaling {1.0f}
 scaling coefficient
 
bool dirty {true}
 should we update model_matrix or not
 
glm::mat3 modelMatrix {1.0f}
 model matrix for MVP-rendering
 

Constructor & Destructor Documentation

◆ TransformComponent() [1/2]

phys2d::TransformComponent::TransformComponent ( )
default

default concstructor for TransformComponent

◆ TransformComponent() [2/2]

phys2d::TransformComponent::TransformComponent ( const glm::vec2 &  position,
float  rotation,
float  scaling 
)

constructor for TransformComponent with all fields

Member Function Documentation

◆ getForward()

const glm::vec2 phys2d::TransformComponent::getForward ( ) const

gives the forward vector of an object. Can be used for cannons and bullets, for example

Parameters
None
Return values
forwarddirection

◆ move()

void phys2d::TransformComponent::move ( const glm::vec2 &  direction)

changes the object's position: (x, y) -> (x + direction.x, y + direction.y)

Note
(0, 0) - center of the screen
x-axis is horizontal
y-axis is vertical
Parameters
directionvector of movement
Return values
None

◆ rotate()

void phys2d::TransformComponent::rotate ( float  angle_delta)

rotates the object

Parameters
angle_deltavalue of rotation, given in radians, rotates clockwise
Return values
None

◆ scale()

void phys2d::TransformComponent::scale ( float  scale_coef)

scales the object

Parameters
scale_coefscaling coef to multiply
Return values
None

◆ setPosition()

void phys2d::TransformComponent::setPosition ( const glm::vec2 &  new_position)

sets the new object's position on the grid

Parameters
new_positionnew position where the object will be located
Return values
None

◆ setRotation()

void phys2d::TransformComponent::setRotation ( const float  new_angle)

sets the new object's rotation in radians, clockwise

Parameters
new_anglenew angle of the rotation of the object, in radians
Return values
None

◆ setScale()

void phys2d::TransformComponent::setScale ( float  new_scale)

sets the new object's scaling coefficients

Parameters
new_scalenew scale of the object
Return values
None

◆ updateMatrix()

void phys2d::TransformComponent::updateMatrix ( ) const

recalculates the model matrix

Parameters
None
Return values
None

Member Data Documentation

◆ dirty

bool phys2d::TransformComponent::dirty {true}
mutable

should we update model_matrix or not

◆ modelMatrix

glm::mat3 phys2d::TransformComponent::modelMatrix {1.0f}
mutable

model matrix for MVP-rendering

◆ position

glm::vec2 phys2d::TransformComponent::position {0.0f, 0.0f}

global position of the object on the grid

◆ rotation

float phys2d::TransformComponent::rotation {0.0f}

rotation angle of the object, clockwise

◆ scaling

float phys2d::TransformComponent::scaling {1.0f}

scaling coefficient


The documentation for this struct was generated from the following file: