Cafu Engine
cf::GameSys::ComponentTransformT Class Reference

This component adds information about the position and orientation of its entity. More...

#include "CompTransform.hpp"

Inheritance diagram for cf::GameSys::ComponentTransformT:

Public Member Functions

 ComponentTransformT ()
 The constructor. More...
 
 ComponentTransformT (const ComponentTransformT &Comp)
 The copy constructor. More...
 
bool IsIdentity () const
 Returns whether the transformation described by this component is the identity ("no") transform. More...
 
const Vector3fTGetOriginPS () const
 Returns the origin of the transform (in "parent-space"). More...
 
void SetOriginPS (const Vector3fT &Origin)
 Sets the origin of the transform (in "parent-space"). More...
 
const cf::math::QuaternionfT GetQuatPS () const
 Returns the orientation of the transform (in "parent-space"). More...
 
void SetQuatPS (const cf::math::QuaternionfT &Quat)
 Sets the orientation of the transform (in "parent-space"). More...
 
Vector3fT GetOriginWS () const
 Returns the origin of the transform (in world-space). More...
 
void SetOriginWS (const Vector3fT &OriginWS)
 Sets the origin of the transform (in world-space). More...
 
const cf::math::QuaternionfT GetQuatWS () const
 Returns the orientation of the transform (in world-space). More...
 
void SetQuatWS (const cf::math::QuaternionfT &QuatWS)
 Sets the orientation of the transform (in world-space). More...
 
MatrixT GetEntityToWorld () const
 Returns the transformation matrix from local entity-space to world-space. More...
 
void LookAt (const Vector3fT &Pos, unsigned int AxisNr=0, bool NoPitch=false)
 Sets the orientation of the transform so that it "looks at" the given position. More...
 
ComponentTransformTClone () const
 The virtual copy constructor. More...
 
const char * GetName () const
 Returns the name of this component. More...
 
const cf::TypeSys::TypeInfoTGetType () const
 
- Public Member Functions inherited from cf::GameSys::ComponentBaseT
 ComponentBaseT ()
 The constructor. More...
 
 ComponentBaseT (const ComponentBaseT &Comp)
 The copy constructor. More...
 
virtual ~ComponentBaseT ()
 The virtual destructor. More...
 
EntityTGetEntity () const
 Returns the parent entity that contains this component, or NULL if this component is currently not a part of any entity. More...
 
TypeSys::VarManTGetMemberVars ()
 Returns the variable manager that keeps generic references to our member variables, providing a simple kind of "reflection" or "type introspection" feature. More...
 
template<class T >
void SetMember (const char *Name, const T &Value)
 Sets the member variable with the given name to the given value. More...
 
ArrayT< ApproxBaseT * > & GetInterpolators ()
 Returns the interpolators that have been registered with this component. More...
 
bool InitClientApprox (const char *VarName)
 Registers the member variable with the given name for interpolation over client frames in order to bridge the larger intervals between server frames. More...
 
void Serialize (cf::Network::OutStreamT &Stream) const
 Writes the current state of this component into the given stream. More...
 
void Deserialize (cf::Network::InStreamT &Stream, bool IsIniting)
 Reads the state of this component from the given stream, and updates the component accordingly. More...
 
bool CallLuaMethod (const char *MethodName, int NumExtraArgs, const char *Signature="",...)
 Calls the given Lua method of this component. More...
 
virtual void UpdateDependencies (EntityT *Entity)
 This method is called whenever something "external" to this component has changed: More...
 
virtual unsigned int GetEditorColor () const
 Returns a color that the Map Editor can use to render the representation of this component's entity. More...
 
virtual BoundingBox3fT GetEditorBB () const
 Returns a bounding-box that the Map Editor can use to render the representation of this component's entity and for related hit tests in the 2D and 3D views after mouse clicks. More...
 
virtual BoundingBox3fT GetCullingBB () const
 This method returns a bounding-box that encloses the visual representation of this component. More...
 
virtual const
cf::ClipSys::ClipModelT
GetClipModel ()
 This method returns the clip model of this component, if any. More...
 
virtual void PreCache ()
 Initializes any resources that may be needed on the client or server ahead of time. More...
 
virtual bool Render (bool FirstPersonView, float LodDist) const
 This method implements the graphical output of this component. More...
 
virtual void PostRender (bool FirstPersonView)
 This method provides an opportunity for another render pass. More...
 
virtual void OnPostLoad (bool OnlyStatic)
 This method is called after all entities and their components have been loaded. More...
 
virtual bool OnInputEvent (const CaKeyboardEventT &KE)
 This method handles keyboard input events. More...
 
virtual bool OnInputEvent (const CaMouseEventT &ME, float PosX, float PosY)
 This method handles mouse input events. More...
 
void OnServerFrame (float t)
 Advances the component one frame (one "clock-tick") on the server. More...
 
void OnClientFrame (float t)
 Advances the component one frame (one "clock-tick") on the client. More...
 
- Public Member Functions inherited from RefCountedT
unsigned int GetRefCount () const
 

Static Public Member Functions

static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 
- Static Public Member Functions inherited from cf::GameSys::ComponentBaseT
static void * CreateInstance (const cf::TypeSys::CreateParamsT &Params)
 

Static Public Attributes

static const cf::TypeSys::TypeInfoT TypeInfo
 
- Static Public Attributes inherited from cf::GameSys::ComponentBaseT
static const cf::TypeSys::TypeInfoT TypeInfo
 

Static Protected Member Functions

static int GetOriginWS (lua_State *LuaState)
 
static int SetOriginWS (lua_State *LuaState)
 
static int GetAngles (lua_State *LuaState)
 
static int SetAngles (lua_State *LuaState)
 
static int GetAxisX (lua_State *LuaState)
 
static int GetAxisY (lua_State *LuaState)
 
static int GetAxisZ (lua_State *LuaState)
 
static int LookAt (lua_State *LuaState)
 
static int toString (lua_State *LuaState)
 
- Static Protected Member Functions inherited from cf::GameSys::ComponentBaseT
static int Get (lua_State *LuaState)
 
static int Set (lua_State *LuaState)
 
static int GetExtraMessage (lua_State *LuaState)
 
static int Interpolate (lua_State *LuaState)
 
static int GetEntity (lua_State *LuaState)
 
static int InitClientApprox (lua_State *LuaState)
 
static int toString (lua_State *LuaState)
 

Static Protected Attributes

static const luaL_Reg MethodsList []
 The list of Lua methods for this class. More...
 
static const char * DocClass
 
static const cf::TypeSys::MethsDocT DocMethods []
 
static const cf::TypeSys::VarsDocT DocVars []
 
- Static Protected Attributes inherited from cf::GameSys::ComponentBaseT
static const luaL_Reg MethodsList []
 The list of Lua methods for this class. More...
 
static const char * DocClass
 
static const cf::TypeSys::MethsDocT DocMethods []
 
static const cf::TypeSys::MethsDocT DocCallbacks []
 

Additional Inherited Members

- Protected Member Functions inherited from RefCountedT
 RefCountedT (const RefCountedT &)
 
RefCountedToperator= (const RefCountedT &)
 

Detailed Description

This component adds information about the position and orientation of its entity.

Positions and orientations can be measured relative to several distinct spaces:

world-space : The global and "absolute" coordinate space that also exists when nothing else does.

entity-space : The local coordinate system of the entity. It is defined by the entity's transform component relative to the entity's parent-space. The term "model-space" can be used synonymously with "entity-space".

parent-space : The entity-space of an entity's parent. If an entity has no parent entity, this is the same as world-space.

Although transform components can theoretically and technically exist without being attached to an entity, in practice this distinction is not made. Every entity has exactly one built-in transform component, and terms like "the origin of the transform" and "the origin of the entity" are used synonymously.

Constructor & Destructor Documentation

ComponentTransformT::ComponentTransformT ( )

The constructor.

ComponentTransformT::ComponentTransformT ( const ComponentTransformT Comp)

The copy constructor.

Parameters
CompThe component to create a copy of.

Member Function Documentation

ComponentTransformT * ComponentTransformT::Clone ( ) const
virtual

The virtual copy constructor.

Callers can use this method to create a copy of this component without knowing its concrete type. Overrides in derived classes use a covariant return type to facilitate use when the concrete type is known. The newly cloned component is initially not a part of any entity, even if the source component was.

Reimplemented from cf::GameSys::ComponentBaseT.

MatrixT ComponentTransformT::GetEntityToWorld ( ) const

Returns the transformation matrix from local entity-space to world-space.

const char* cf::GameSys::ComponentTransformT::GetName ( ) const
inlinevirtual

Returns the name of this component.

Reimplemented from cf::GameSys::ComponentBaseT.

const Vector3fT& cf::GameSys::ComponentTransformT::GetOriginPS ( ) const
inline

Returns the origin of the transform (in "parent-space").

Vector3fT ComponentTransformT::GetOriginWS ( ) const

Returns the origin of the transform (in world-space).

const cf::math::QuaternionfT cf::GameSys::ComponentTransformT::GetQuatPS ( ) const
inline

Returns the orientation of the transform (in "parent-space").

const cf::math::QuaternionfT ComponentTransformT::GetQuatWS ( ) const

Returns the orientation of the transform (in world-space).

bool cf::GameSys::ComponentTransformT::IsIdentity ( ) const
inline

Returns whether the transformation described by this component is the identity ("no") transform.

void ComponentTransformT::LookAt ( const Vector3fT Pos,
unsigned int  AxisNr = 0,
bool  NoPitch = false 
)

Sets the orientation of the transform so that it "looks at" the given position.

The new orientation is chosen such that the bank angle is always 0 relative to the xy-plane.

Parameters
PosThe target position to look at.
AxisNrThe "look axis", i.e. the number of the axis to orient towards Pos: 0 for the x-axis, 1 for the y-axis.
NoPitchIf true, the pitch angle is kept at 0, and the given axis points towards Pos only in the XY-Plane and the z-axis points straight up (0, 0, 1).
void cf::GameSys::ComponentTransformT::SetOriginPS ( const Vector3fT Origin)
inline

Sets the origin of the transform (in "parent-space").

void ComponentTransformT::SetOriginWS ( const Vector3fT OriginWS)

Sets the origin of the transform (in world-space).

void cf::GameSys::ComponentTransformT::SetQuatPS ( const cf::math::QuaternionfT Quat)
inline

Sets the orientation of the transform (in "parent-space").

void ComponentTransformT::SetQuatWS ( const cf::math::QuaternionfT QuatWS)

Sets the orientation of the transform (in world-space).

Member Data Documentation

const char * ComponentTransformT::DocClass
staticprotected
Initial value:
=
"This component adds information about the position and orientation of its entity.\n"
"Positions and orientations can be measured relative to several distinct spaces:\n"
"\n"
"world-space\n"
" : The global and \"absolute\" coordinate space that also exists when nothing else does.\n"
"\n"
"entity-space\n"
" : The local coordinate system of the entity. It is defined by the entity's transform component relative\n"
" to the entity's parent-space. The term \"model-space\" can be used synonymously with \"entity-space\".\n"
"\n"
"parent-space\n"
" : The entity-space of an entity's parent.\n"
" If an entity has no parent entity, this is the same as world-space.\n"
"\n"
"Although transform components can theoretically and technically exist without being attached to an entity,\n"
"in practice this distinction is not made. Every entity has exactly one built-in transform component, and\n"
"terms like \"the origin of the transform\" and \"the origin of the entity\" are used synonymously."
const cf::TypeSys::MethsDocT ComponentTransformT::DocMethods
staticprotected
Initial value:
=
{
META_GetOriginWS,
META_SetOriginWS,
META_GetAngles,
META_SetAngles,
META_GetAxisX,
META_GetAxisY,
META_GetAxisZ,
META_LookAt,
META_toString,
{ NULL, NULL, NULL, NULL }
}
const cf::TypeSys::VarsDocT ComponentTransformT::DocVars
staticprotected
Initial value:
=
{
{ "Origin", "The origin of the entity (in the coordinate system of its parent)." },
{ "Orientation", "The orientation of the entity (in the coordinate system of its parent)." },
{ NULL, NULL }
}
const luaL_Reg ComponentTransformT::MethodsList
staticprotected
Initial value:
=
{
{ "GetOriginWS", GetOriginWS },
{ "SetOriginWS", SetOriginWS },
{ "GetAngles", GetAngles },
{ "SetAngles", SetAngles },
{ "GetAxisX", GetAxisX },
{ "GetAxisY", GetAxisY },
{ "GetAxisZ", GetAxisZ },
{ "LookAt", LookAt },
{ "__tostring", toString },
{ NULL, NULL }
}

The list of Lua methods for this class.


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