Aspen
2D C++ Class-Based Object Oriented Game Engine
Aspen::Transform::Transform Class Reference

Transform class. More...

#include <Transform.hpp>

Inheritance diagram for Aspen::Transform::Transform:
Aspen::Object::Object

Public Member Functions

 Transform (Object *parent=nullptr, std::string name="Transform")
 Constructor Derived classes should call this in their constructors' initialization list. More...
 
void SetPosition (float x, float y)
 Sets the position. More...
 
void SetXPosition (float x)
 Sets the x position. More...
 
void SetYPosition (float y)
 Sets the y position. More...
 
void SetRotation (double r)
 Sets the rotation. More...
 
void SetScale (float x, float y)
 Sets the scale. More...
 
void SetXScale (float x)
 Sets the x scale. More...
 
void SetYScale (float y)
 Sets the y scale. More...
 
void ModifyPosition (float x, float y)
 Modifies the position. More...
 
void ModifyXPosition (float x)
 Modifies the x position. More...
 
void ModifyYPosition (float y)
 Modifies the y position. More...
 
void ModifyRotation (double r)
 Modifies the rotation. More...
 
void ModifyScale (float x, float y)
 Modifies the scale. More...
 
void ModifyXScale (float x)
 Modifies the x scale. More...
 
void ModifyYScale (float y)
 Modifies the y scale. More...
 
float GetXPosition () const
 Gets the total x position in world space. More...
 
float GetYPosition () const
 Gets the total y position in world space. More...
 
double GetRotation () const
 Gets the total rotation in world space. More...
 
float GetXScale () const
 Gets the total x scale in world space. More...
 
float GetYScale () const
 Gets the total y scale in world space. More...
 
float GetXPosition (const Transform *camera) const
 Gets the total x position in world space while taking the camera into account. More...
 
float GetYPosition (const Transform *camera) const
 Gets the total y position in world space while taking the camera into account. More...
 
double GetRotation (const Transform *camera) const
 Gets the total rotation in world space while taking the camera into account. More...
 
float GetXScale (const Transform *camera) const
 Gets the total x scale in world space while taking the camera into account. More...
 
float GetYScale (const Transform *camera) const
 Gets the total y scale in world space while taking the camera into account. More...
 
float GetInverseXPosition () const
 Gets the inverse x position in world space. More...
 
float GetInverseYPosition () const
 Gets the inverse y position in world space. More...
 
double GetInverseRotation () const
 Gets the inverse rotation in world space. More...
 
float GetInverseXScale () const
 Gets the inverse x scale in world space. More...
 
float GetInverseYScale () const
 Gets the inverse y scale in world space. More...
 
float GetLocalXPosition () const
 Gets the local x position. More...
 
float GetLocalYPosition () const
 Gets the local y position. More...
 
double GetLocalRotation () const
 Gets the local rotation. More...
 
float GetLocalXScale () const
 Gets the local x scale. More...
 
float GetLocalYScale () const
 Gets the local y scale. More...
 
float GetLocalInverseXPosition () const
 Gets the inverse local x position. More...
 
float GetLocalInverseYPosition () const
 Gets the inverse local y position. More...
 
double GetLocalInverseRotation () const
 Gets the inverse local rotation. More...
 
float GetLocalInverseXScale () const
 Gets the inverse local x scale. More...
 
float GetLocalInverseYScale () const
 Gets the inverse local y scale. More...
 
Transform Inverse () const
 Returns the inverse of this Transform. More...
 
Transform operator+ (const Transform &rhs) const
 Combines two Transform objects. More...
 
Transformoperator+= (const Transform &rhs)
 Combines two Transform objects and stores the result in this Transform. More...
 
void PopulateDebugger ()
 Fills out the Debugger if it exists with this Object's information Derived classes should call their base class's version of this method.
 
- Public Member Functions inherited from Aspen::Object::Object
 Object (Object *parent=nullptr, std::string name="Object")
 Constructor Derived classes should call this in their constructors' initialization list. More...
 
virtual ~Object ()
 Destructor This will End and then delete all child Objects.
 
const ObjectParent () const
 Gets the parent of this Object. More...
 
ObjectParent ()
 Gets the parent of this Object. More...
 
const ObjectRoot () const
 Gets the root Object of the parent/child tree this Object is a part of. More...
 
ObjectRoot ()
 Gets the root Object of the parent/child tree this Object is a part of. More...
 
Transform::TransformGetTransform ()
 Gets the first child Transform::Transform. More...
 
const Transform::TransformGetTransform () const
 Gets the first child Transform::Transform. More...
 
Physics::ColliderGetCollider ()
 Gets the first child Physics::Collider. More...
 
const Physics::ColliderGetCollider () const
 Gets the first child Physics::Collider. More...
 
Physics::RigidbodyGetRigidbody ()
 Gets the first child Physics::Rigidbody. More...
 
const Physics::RigidbodyGetRigidbody () const
 Gets the first child Physics::Rigidbody. More...
 
virtual void operator() ()
 Updates this object and all of its children Derived classes should call or reimplement this at some point in their operator() This won't run if the Object isn't Active.
 
void AddChild (Object *child)
 Adds child to this Object's list of children This will also set child's _parent to this This will do nothing if child is already in the list of children Useful for adding an already created Object as a child or passing in the return operator new with parameters. More...
 
template<typename T >
T * CreateChild ()
 Creates a new child of type T Useful for creating an object with no constructor parameters and/or modifying it later. More...
 
template<typename T >
T * CreateChild (std::string name)
 Creates a new child of type T Useful for creating an object with no constructor parameters and/or modifying it later. More...
 
void RemoveChild (Object *child)
 Removes child from this Object's list of children This will also set child's _parent to nullptr This will do nothing if child is not in the Object's list of children. More...
 
void RemoveChild (unsigned index)
 Removes the child at index from this Object's list of children This will also set the child's _parent to nullptr This will do nothing if index is out of range of the Object's list of children. More...
 
Objectoperator[] (unsigned index)
 Gets the child at index from this Object's list of children. More...
 
int operator[] (Object *child)
 Gets the index of a given child in this Object's list of children. More...
 
ObjectGetLastChild ()
 Gets the youngest child from this Object's list of children. More...
 
int ParentCount ()
 Determines the generation of this object in the parent/child tree. More...
 
template<typename T >
T * FindAncestorOfType () const
 Finds the closest ancestor Object of a type applicable to that which was requested. More...
 
template<typename T >
const T * FindChildOfType () const
 Finds the first child Object of a type applicable to that which was requested. More...
 
template<typename T >
T * FindChildOfType ()
 Finds the first child Object of a type applicable to that which was requested. More...
 
template<typename T >
const std::vector< T * > FindChildrenOfType () const
 Finds all children Objects of a type applicable to that which was requested. More...
 
template<typename T >
std::vector< T * > FindChildrenOfType ()
 Finds all children Objects of a type applicable to that which was requested. More...
 
template<typename T >
const std::vector< T * > FindDescendentsOfType () const
 Recursively finds all descendent Objects of a type applicable to that which was requested. More...
 
template<typename T >
std::vector< T * > FindDescendentsOfType ()
 Recursively finds all descendent Objects of a type applicable to that which was requested. More...
 
const bool & Valid () const
 Determines if the Object is valid. More...
 
bool Active () const
 Determines if the Object is active. More...
 
void SetActive (bool active)
 Sets active status of the object Triggers OnActivate or OnDeactivate appropriately. More...
 
void Activate ()
 Activates the object Triggers OnActivate appropriately.
 
void Deactivate ()
 Deactivates the object Triggers OnDeactivate appropriately.
 
 operator bool () const
 Converts Object to bool by calling Valid Example: ``` Object o; while (o) o(); ```.
 
virtual void End ()
 Shuts down and invalidates Object and all of its children An invalid child Object will be deleted by their parent after they update.
 
void PrintTree (Log::Log &log) const
 Uses Log::Log to print the parent/children tree of this Object. More...
 
void PrintTree () const
 Uses Log::Log to print the parent/children tree of this Object Uses Log::Debug.
 
std::string Name () const
 Gets the Object's name. More...
 
unsigned ChildrenCount () const
 Determines the number of immediate children the Object has. More...
 
std::vector< Object * > & Children ()
 Gets the list of Objects that are children of this Object. More...
 
bool HasAncestor (const Object *other) const
 Determines if the provided Object is an ancestor of this Object. More...
 
virtual void OnStart ()
 Run when the Object is created.
 
virtual void OnActivate ()
 Run when the Object is activated Run after OnStart.
 
virtual void OnUpdate ()
 Run every frame.
 
virtual void OnEarlyUpdate ()
 Run before OnUpdate.
 
virtual void OnLateUpdate ()
 Run after OnUpdate.
 
virtual void OnDeactivate ()
 Run when the Object is deactivated Run before OnEnd.
 
virtual void OnEnd ()
 Run when the Object is ended/destroyed.
 
virtual void OnCollision (Physics::Collision c)
 Run when a collision occurs. More...
 
virtual void OnMouseEnter ()
 Run when the mouse enters the Object.
 
virtual void OnMouseOver ()
 Run while the mouse is over the Object.
 
virtual void OnMouseExit ()
 Run when the mouse leaves the Object.
 
virtual void OnMouseClick ()
 Run when the mouse is clicked while over the Object.
 
virtual void OnMouseRelease ()
 Run when the mouse is released while over the Object.
 

Private Attributes

float _posx
 X position.
 
float _posy
 Y position.
 
double _r
 Rotation angle.
 
float _scalex
 X scale.
 
float _scaley
 Y scale.
 

Additional Inherited Members

- Protected Member Functions inherited from Aspen::Object::Object
void SetParent (Object *parent)
 Sets _parent to the given Object Used by AddChild, CreateChild, etc.
 
void TriggerOnStart ()
 Runs OnStart if the object is currently active for the first time.
 
void TriggerOnActivate ()
 Runs OnActivate if the object is currently active.
 
void TriggerOnDeactivate ()
 Runs OnDeactivate if the object is currently active (being deactivated)
 
- Protected Attributes inherited from Aspen::Object::Object
const std::string _name
 Name of object.
 
Object_parent
 Parent/owner of this Object.
 
std::vector< Object * > _children
 List of children Objects.
 
bool _valid
 Determines if the Object is valid Derived classes can set this to false in their Constructors if they couldn't be created properly.
 
bool _active
 Determines if the Object is currently updated.
 
bool _started
 Determines if the Object has been started Set to true during the first update.
 
Transform::Transform_transform
 First child Transform::Transform.
 
Physics::Collider_collider
 First child Physics::Collider.
 
Physics::Rigidbody_rigidbody
 First child Physics::Rigidbody.
 
- Static Protected Attributes inherited from Aspen::Object::Object
static int _count
 Total number of Objects in existence.
 

Detailed Description

Transform class.

Constructor & Destructor Documentation

◆ Transform()

Aspen::Transform::Transform::Transform ( Object parent = nullptr,
std::string  name = "Transform" 
)

Constructor Derived classes should call this in their constructors' initialization list.

Parameters
parentParent Object creating this Object
nameObject name Set by derived classes to a string representation of their type

Member Function Documentation

◆ GetInverseRotation()

double Aspen::Transform::Transform::GetInverseRotation ( ) const

Gets the inverse rotation in world space.

Returns
World space rotation

◆ GetInverseXPosition()

float Aspen::Transform::Transform::GetInverseXPosition ( ) const

Gets the inverse x position in world space.

Returns
World space x position

◆ GetInverseXScale()

float Aspen::Transform::Transform::GetInverseXScale ( ) const

Gets the inverse x scale in world space.

Returns
World space x scale

◆ GetInverseYPosition()

float Aspen::Transform::Transform::GetInverseYPosition ( ) const

Gets the inverse y position in world space.

Returns
World space y position

◆ GetInverseYScale()

float Aspen::Transform::Transform::GetInverseYScale ( ) const

Gets the inverse y scale in world space.

Returns
World space y scale

◆ GetLocalInverseRotation()

double Aspen::Transform::Transform::GetLocalInverseRotation ( ) const

Gets the inverse local rotation.

Returns
Local rotation

◆ GetLocalInverseXPosition()

float Aspen::Transform::Transform::GetLocalInverseXPosition ( ) const

Gets the inverse local x position.

Returns
Local x position

◆ GetLocalInverseXScale()

float Aspen::Transform::Transform::GetLocalInverseXScale ( ) const

Gets the inverse local x scale.

Returns
Local x scale

◆ GetLocalInverseYPosition()

float Aspen::Transform::Transform::GetLocalInverseYPosition ( ) const

Gets the inverse local y position.

Returns
Local y position

◆ GetLocalInverseYScale()

float Aspen::Transform::Transform::GetLocalInverseYScale ( ) const

Gets the inverse local y scale.

Returns
Local y scale

◆ GetLocalRotation()

double Aspen::Transform::Transform::GetLocalRotation ( ) const

Gets the local rotation.

Returns
Local rotation

◆ GetLocalXPosition()

float Aspen::Transform::Transform::GetLocalXPosition ( ) const

Gets the local x position.

Returns
Local x position

◆ GetLocalXScale()

float Aspen::Transform::Transform::GetLocalXScale ( ) const

Gets the local x scale.

Returns
Local x scale

◆ GetLocalYPosition()

float Aspen::Transform::Transform::GetLocalYPosition ( ) const

Gets the local y position.

Returns
Local y position

◆ GetLocalYScale()

float Aspen::Transform::Transform::GetLocalYScale ( ) const

Gets the local y scale.

Returns
Local y scale

◆ GetRotation() [1/2]

double Aspen::Transform::Transform::GetRotation ( ) const

Gets the total rotation in world space.

Returns
World space rotation

◆ GetRotation() [2/2]

double Aspen::Transform::Transform::GetRotation ( const Transform camera) const

Gets the total rotation in world space while taking the camera into account.

Returns
World space rotation

◆ GetXPosition() [1/2]

float Aspen::Transform::Transform::GetXPosition ( ) const

Gets the total x position in world space.

Returns
World space x position

◆ GetXPosition() [2/2]

float Aspen::Transform::Transform::GetXPosition ( const Transform camera) const

Gets the total x position in world space while taking the camera into account.

Returns
World space x position

◆ GetXScale() [1/2]

float Aspen::Transform::Transform::GetXScale ( ) const

Gets the total x scale in world space.

Returns
World space x scale

◆ GetXScale() [2/2]

float Aspen::Transform::Transform::GetXScale ( const Transform camera) const

Gets the total x scale in world space while taking the camera into account.

Returns
World space x scale

◆ GetYPosition() [1/2]

float Aspen::Transform::Transform::GetYPosition ( ) const

Gets the total y position in world space.

Returns
World space y position

◆ GetYPosition() [2/2]

float Aspen::Transform::Transform::GetYPosition ( const Transform camera) const

Gets the total y position in world space while taking the camera into account.

Returns
World space y position

◆ GetYScale() [1/2]

float Aspen::Transform::Transform::GetYScale ( ) const

Gets the total y scale in world space.

Returns
World space y scale

◆ GetYScale() [2/2]

float Aspen::Transform::Transform::GetYScale ( const Transform camera) const

Gets the total y scale in world space while taking the camera into account.

Returns
World space y scale

◆ Inverse()

Transform Aspen::Transform::Transform::Inverse ( ) const

Returns the inverse of this Transform.

Returns
Inverse of this Transform

◆ ModifyPosition()

void Aspen::Transform::Transform::ModifyPosition ( float  x,
float  y 
)

Modifies the position.

Parameters
xX position modifier
yY position modifier

◆ ModifyRotation()

void Aspen::Transform::Transform::ModifyRotation ( double  r)

Modifies the rotation.

Parameters
rRotation modifier

◆ ModifyScale()

void Aspen::Transform::Transform::ModifyScale ( float  x,
float  y 
)

Modifies the scale.

Parameters
xX scale modifier
yY scale modifier

◆ ModifyXPosition()

void Aspen::Transform::Transform::ModifyXPosition ( float  x)

Modifies the x position.

Parameters
xX position modifier

◆ ModifyXScale()

void Aspen::Transform::Transform::ModifyXScale ( float  x)

Modifies the x scale.

Parameters
xX scale modifier

◆ ModifyYPosition()

void Aspen::Transform::Transform::ModifyYPosition ( float  y)

Modifies the y position.

Parameters
yY position modifier

◆ ModifyYScale()

void Aspen::Transform::Transform::ModifyYScale ( float  y)

Modifies the y scale.

Parameters
yY scale modifier

◆ operator+()

Transform Aspen::Transform::Transform::operator+ ( const Transform rhs) const

Combines two Transform objects.

Parameters
rhsTransform to the right of the operator
Returns
Result of the combination

◆ operator+=()

Transform& Aspen::Transform::Transform::operator+= ( const Transform rhs)

Combines two Transform objects and stores the result in this Transform.

Parameters
rhsTransform to the right of the operator
Returns
Result of the combination

◆ SetPosition()

void Aspen::Transform::Transform::SetPosition ( float  x,
float  y 
)

Sets the position.

Parameters
xNew x position
yNew y position

◆ SetRotation()

void Aspen::Transform::Transform::SetRotation ( double  r)

Sets the rotation.

Parameters
rNew rotation

◆ SetScale()

void Aspen::Transform::Transform::SetScale ( float  x,
float  y 
)

Sets the scale.

Parameters
xNew x scale
yNew y scale

◆ SetXPosition()

void Aspen::Transform::Transform::SetXPosition ( float  x)

Sets the x position.

Parameters
xNew x position

◆ SetXScale()

void Aspen::Transform::Transform::SetXScale ( float  x)

Sets the x scale.

Parameters
xNew x scale

◆ SetYPosition()

void Aspen::Transform::Transform::SetYPosition ( float  y)

Sets the y position.

Parameters
yNew y position

◆ SetYScale()

void Aspen::Transform::Transform::SetYScale ( float  y)

Sets the y scale.

Parameters
yNew y scale

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