Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
Transform Class Reference

Represents the position, rotation, and scale of a GameObject in 3D space. The Transform class encapsulates the local and world transformations of a GameObject, including its position, rotation, and scale. It also supports hierarchical relationships through parent-child transforms. More...

#include <transform.h>

Public Member Functions

 Transform ()
 
 Transform (Vector3 position)
 
 Transform (Vector3 position, float rotation, Vector3 scale)
 
 Transform (Vector3 position, float rotation, Vector3 scale, std::optional< std::reference_wrapper< Transform > > parent)
 
Vector3 local_position () const noexcept
 Get the local position of the Transform.
 
Transformlocal_position (const Vector3 &pos) noexcept
 Set the local position of the Transform.
 
Vector3 position () const noexcept
 Get the world position of the Transform.
 
Transformposition (const Vector3 &pos) noexcept
 Set the world position of the Transform.
 
Transformrotation (float rot) noexcept
 Set the rotation of the Transform in degrees.
 
float rotation () const noexcept
 Get the rotation of the Transform in degrees.
 
Transformscale (Vector3 scale) noexcept
 Set the scale of the Transform.
 
Vector3 scale () const noexcept
 Get the scale of the Transform.
 
Transformparent (std::optional< std::reference_wrapper< Transform > > parent) noexcept
 Set the parent Transform.
 
std::optional< std::reference_wrapper< Transform > > parent () const noexcept
 Get the parent Transform.
 

Detailed Description

Represents the position, rotation, and scale of a GameObject in 3D space. The Transform class encapsulates the local and world transformations of a GameObject, including its position, rotation, and scale. It also supports hierarchical relationships through parent-child transforms.

Note
The position is represented as a Vector3, the rotation as a float (in degrees), and the scale as a Vector3.
The parent transform is optional, allowing for both root and child transforms.
Modifying the local position, rotation, or scale will affect the world transformation based on the parent's transformation.
This class does not handle matrix transformations; it focuses on the basic representation of position, rotation, and scale.

Constructor & Destructor Documentation

◆ Transform() [1/4]

Transform::Transform ( )

◆ Transform() [2/4]

Transform::Transform ( Vector3  position)
explicit

◆ Transform() [3/4]

Transform::Transform ( Vector3  position,
float  rotation,
Vector3  scale 
)

◆ Transform() [4/4]

Transform::Transform ( Vector3  position,
float  rotation,
Vector3  scale,
std::optional< std::reference_wrapper< Transform > >  parent 
)

Member Function Documentation

◆ local_position() [1/2]

Vector3 Transform::local_position ( ) const
noexcept

Get the local position of the Transform.

Returns
The local position as a Vector3.

◆ local_position() [2/2]

Transform & Transform::local_position ( const Vector3 pos)
noexcept

Set the local position of the Transform.

Parameters
posThe new local position as a Vector3.
Returns
A reference to this Transform for chaining.

◆ parent() [1/2]

std::optional< std::reference_wrapper< Transform > > Transform::parent ( ) const
noexcept

Get the parent Transform.

Returns
An optional reference to the parent Transform.

◆ parent() [2/2]

Transform & Transform::parent ( std::optional< std::reference_wrapper< Transform > >  parent)
noexcept

Set the parent Transform.

Parameters
parentAn optional reference to the new parent Transform.
Returns
A reference to this Transform for chaining.

◆ position() [1/2]

Vector3 Transform::position ( ) const
noexcept

Get the world position of the Transform.

Returns
The world position as a Vector3.

◆ position() [2/2]

Transform & Transform::position ( const Vector3 pos)
noexcept

Set the world position of the Transform.

Parameters
posThe new world position as a Vector3.
Returns
A reference to this Transform for chaining.

◆ rotation() [1/2]

float Transform::rotation ( ) const
noexcept

Get the rotation of the Transform in degrees.

Returns
The rotation in degrees.

◆ rotation() [2/2]

Transform & Transform::rotation ( float  rot)
noexcept

Set the rotation of the Transform in degrees.

Parameters
rotThe new rotation in degrees.
Returns
A reference to this Transform for chaining.

◆ scale() [1/2]

Vector3 Transform::scale ( ) const
noexcept

Get the scale of the Transform.

Returns
The scale as a Vector3.

◆ scale() [2/2]

Transform & Transform::scale ( Vector3  scale)
noexcept

Set the scale of the Transform.

Parameters
scaleThe new scale as a Vector3.
Returns
A reference to this Transform for chaining.

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