cangine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
cangine::Transform Class Reference

Component holding an object's position, rotation and scale. More...

#include <transform_component.hpp>

Inheritance diagram for cangine::Transform:
Inheritance graph
[legend]
Collaboration diagram for cangine::Transform:
Collaboration graph
[legend]

Public Member Functions

 ~Transform () override
 
void firstFrame () override
 Called once before the first frame update.
 
void setPosition (Vector3 positionIn)
 Sets the position.
 
Vector3 getPosition () const
 Returns the position.
 
void setRotation (Vector3 rotationIn)
 Sets the rotation.
 
Vector3 getRotation () const
 Returns the rotation.
 
void setScale (Vector3 scaleIn)
 Sets the scale.
 
Vector3 getScale () const
 Returns the scale.
 
- Public Member Functions inherited from cangine::IComponent
 IComponent (GameObject *gameObject=nullptr)
 Constructs the component, optionally bound to a game object.
 
virtual ~IComponent ()
 
GameObject * getGameObject () const
 Returns the game object this component is attached to.
 
virtual void frame (double deltaTime)
 Called every frame to update the component.
 
virtual void onMouseEvent (const MouseEvent *e)
 Called when a mouse event is dispatched to the owning object.
 

Static Public Member Functions

static Transform * from (GameObject *go)
 Fetches the Transform component of a game object.
 
static Vector3 posFrom (GameObject *go)
 Reads the position of a game object's Transform.
 
static Vector3 rotFrom (GameObject *go)
 Reads the rotation of a game object's Transform.
 
static Vector3 scaleFrom (GameObject *go)
 Reads the scale of a game object's Transform.
 
static void posFor (GameObject *go, Vector3 pos)
 Sets the position on a game object's Transform.
 
static void rotFor (GameObject *go, Vector3 rot)
 Sets the rotation on a game object's Transform.
 
static void scaleFor (GameObject *go, Vector3 scale)
 Sets the scale on a game object's Transform.
 

Private Attributes

Vector3 position
 World position.
 
Vector3 rotation
 Rotation in degrees (per axis).
 
Vector3 scale
 Scale factor per axis.
 

Additional Inherited Members

- Public Attributes inherited from cangine::IComponent
bool isUnique = true
 If true, only one of this component type may exist per object.
 

Detailed Description

Component holding an object's position, rotation and scale.

Every spatial game object carries a Transform. Convenience static helpers (from, posFrom, posFor, ...) read or write the transform of a given GameObject without manually fetching the component.

Constructor & Destructor Documentation

◆ ~Transform()

cangine::Transform::~Transform ( )
overridedefault

Member Function Documentation

◆ firstFrame()

void cangine::Transform::firstFrame ( )
overridevirtual

Called once before the first frame update.

Reimplemented from cangine::IComponent.

◆ from()

static Transform * cangine::Transform::from ( GameObject *  go)
inlinestatic

Fetches the Transform component of a game object.

Parameters
goGame object to query.
Returns
The object's Transform component.

◆ getPosition()

Vector3 cangine::Transform::getPosition ( ) const

Returns the position.

Returns
Current position.

◆ getRotation()

Vector3 cangine::Transform::getRotation ( ) const

Returns the rotation.

Returns
Current rotation in degrees.

◆ getScale()

Vector3 cangine::Transform::getScale ( ) const

Returns the scale.

Returns
Current scale factor per axis.

◆ posFor()

static void cangine::Transform::posFor ( GameObject *  go,
Vector3  pos 
)
inlinestatic

Sets the position on a game object's Transform.

Parameters
goGame object to modify.
posNew position.

◆ posFrom()

static Vector3 cangine::Transform::posFrom ( GameObject *  go)
inlinestatic

Reads the position of a game object's Transform.

Parameters
goGame object to query.
Returns
The object's position.

◆ rotFor()

static void cangine::Transform::rotFor ( GameObject *  go,
Vector3  rot 
)
inlinestatic

Sets the rotation on a game object's Transform.

Parameters
goGame object to modify.
rotNew rotation in degrees.

◆ rotFrom()

static Vector3 cangine::Transform::rotFrom ( GameObject *  go)
inlinestatic

Reads the rotation of a game object's Transform.

Parameters
goGame object to query.
Returns
The object's rotation in degrees.

◆ scaleFor()

static void cangine::Transform::scaleFor ( GameObject *  go,
Vector3  scale 
)
inlinestatic

Sets the scale on a game object's Transform.

Parameters
goGame object to modify.
scaleNew scale factor per axis.

◆ scaleFrom()

static Vector3 cangine::Transform::scaleFrom ( GameObject *  go)
inlinestatic

Reads the scale of a game object's Transform.

Parameters
goGame object to query.
Returns
The object's scale.

◆ setPosition()

void cangine::Transform::setPosition ( Vector3  positionIn)

Sets the position.

Parameters
positionInNew position.

◆ setRotation()

void cangine::Transform::setRotation ( Vector3  rotationIn)

Sets the rotation.

Parameters
rotationInNew rotation in degrees.

◆ setScale()

void cangine::Transform::setScale ( Vector3  scaleIn)

Sets the scale.

Parameters
scaleInNew scale factor per axis.

Member Data Documentation

◆ position

Vector3 cangine::Transform::position
private

World position.

◆ rotation

Vector3 cangine::Transform::rotation
private

Rotation in degrees (per axis).

◆ scale

Vector3 cangine::Transform::scale
private

Scale factor per axis.


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