NAP
Public Member Functions | List of all members
TransformComponentInstance Class Reference

#include <transformcomponent.h>

Public Member Functions

 TransformComponentInstance (EntityInstance &entity, Component &resource)
 
virtual bool init (utility::ErrorState &errorState)
 
const glm::mat4x4 & getLocalTransform () const
 
void setLocalTransform (const glm::mat4x4 &matrix)
 
const glm::mat4x4 & getGlobalTransform () const
 
void setDirty ()
 
bool isDirty () const
 
void update (const glm::mat4 &parentTransform)
 
void setTranslate (const glm::vec3 &translate)
 
const glm::vec3 & getTranslate () const
 
void setRotate (const glm::quat &rotate)
 
const glm::quat & getRotate () const
 
void setScale (const glm::vec3 &scale)
 
const glm::vec3 & getScale () const
 
void setUniformScale (float scale)
 
const float getUniformScale () const
 
virtual void update (double deltaTime)
 
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
 
virtual void update (double deltaTime)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

Describes the local transform of an entity, used to compute the global transform of an entity at runtime. When the transform is created the global and local transform is invalid. You can always query the current local matrix, the global matrix is updated on update().

Inheritance diagram for TransformComponentInstance:
[legend]
Collaboration diagram for TransformComponentInstance:
[legend]

Constructor & Destructor Documentation

◆ TransformComponentInstance()

TransformComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ getGlobalTransform()

const glm::mat4x4& getGlobalTransform ( ) const

Returns the global transform of this node. Note that the global transform can be out of sync as it's recomputed on update. point on resolve downwards

◆ getLocalTransform()

const glm::mat4x4& getLocalTransform ( ) const

Constructs and returns the local transform.

Returns
this transform local transformation matrix

◆ getRotate()

const glm::quat& getRotate ( ) const
Returns
component rotation

◆ getScale()

const glm::vec3& getScale ( ) const
Returns
component scale

◆ getTranslate()

const glm::vec3& getTranslate ( ) const
Returns
component translation

◆ getUniformScale()

const float getUniformScale ( ) const
Returns
uniform component scale.

◆ init()

virtual bool init ( utility::ErrorState errorState)
virtual

Initializes this component.

Parameters
errorStateThe error object

Reimplemented from ComponentInstance.

◆ isDirty()

bool isDirty ( ) const
Returns
if the local transform is dirty.

◆ setDirty()

void setDirty ( )

When set dirty, the transform component will re-compute the global and local transform matrices when requested.

◆ setLocalTransform()

void setLocalTransform ( const glm::mat4x4 &  matrix)

Set the local transform based on the given matrix. Note that the matrix is decomposed, result is stored in the individual elements: Uniform scale is discarded, ie: the result will be 1.

Parameters
matrixnew local transformation matrix.

◆ setRotate()

void setRotate ( const glm::quat &  rotate)

Sets the rotation part of this component.

Parameters
rotatenew component rotation.

◆ setScale()

void setScale ( const glm::vec3 &  scale)

Sets the scale factor of the x, y and z axis of this component. Note that the uniform scale is applied after axis dependent scale factor.

Parameters
scalethe new component scale.

◆ setTranslate()

void setTranslate ( const glm::vec3 &  translate)

Sets the transformation part of this component.

Parameters
translatenew component translation.

◆ setUniformScale()

void setUniformScale ( float  scale)

Sets the uniform scale factor, applied to all axis. Note that the uniform scale is applied after the axis independent scale factor.

Parameters
scalethe new component scale.

◆ update() [1/2]

void update ( const glm::mat4 &  parentTransform)

Updates the global matrix based on the parent matrix If this or the parent matrix was marked dirty the global matrix of this node is recomputed. This is a recursive call

◆ update() [2/2]

virtual void update

Update this component

Parameters
deltaTimethe time in between cooks in seconds