Cafu Engine
ComponentTransformT Class Reference

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

Inheritance diagram for ComponentTransformT:

Public Member Functions

tuple GetOriginWS ()
 Returns the origin of the transform (in world-space). More...
 
 SetOriginWS (number x, number y, number z)
 Sets the origin of the transform (in world-space). More...
 
tuple GetAngles ()
 Returns the orientation of this entity as a tuple of three angles, measured in degrees: More...
 
 SetAngles (number heading, number pitch=0.0, number bank=0.0)
 Sets the orientation of this entity from a set of three angles, measured in degrees: More...
 
tuple GetAxisX ()
 Returns the x-axis of the local coordinate system of this entity. More...
 
tuple GetAxisY ()
 Returns the y-axis of the local coordinate system of this entity. More...
 
tuple GetAxisZ ()
 Returns the z-axis of the local coordinate system of this entity. More...
 
 LookAt (number PosX, number PosY, number PosZ, integer AxisNr=0, boolean NoPitch=false)
 Sets the orientation of the transform so that it "looks at" the given position. More...
 
- Public Member Functions inherited from ComponentBaseT
any get (string var_name)
 Returns the value of an attribute (a member variable) of this class. More...
 
 set (string var_name, any new_value)
 Sets an attribute (a member variable) of this class to a new value. More...
 
string GetExtraMessage (string var_name)
 Returns the result of VarBaseT::GetExtraMessage() for the given member variable. More...
 
 interpolate (string var_name, number start_value, number end_value, number time)
 Schedules a value for interpolation between a start and end value over a given period of time. More...
 
EntityT GetEntity ()
 Returns the entity that this component is a part of (or nil if the component is currently "stand-alone", not a part of any entity). More...
 
 InitClientApprox (string VarName)
 Registers the given attribute (a member variable) of this class for interpolation over client frames in order to bridge the larger intervals between server frames. More...
 
 OnInit ()
 This method is called for each component of each entity as the last step of initializing a newly loaded map. More...
 
 OnClientFrame (number t)
 This method is called for each component of each entity before the client renders the next frame. More...
 

Public Attributes

tuple Origin
 The origin of the entity (in the coordinate system of its parent). More...
 
tuple Orientation
 The orientation of the entity (in the coordinate system of its parent). More...
 

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.

Note that the variables of this class (also referred to as "Public Attributes" or "Member Data") must be used with the get() and set() methods at this time – see get() and set() for details.

If you would like to create a new component of this type explicitly (those defined in the CaWE Map Editor are instantiated automatically), use WorldT::new():

local comp = world:new("ComponentTransformT")
Implementing C++ Class:
cf::GameSys::ComponentTransformT

Member Function Documentation

tuple GetAngles ( )

Returns the orientation of this entity as a tuple of three angles, measured in degrees:

  • heading (yaw),
  • pitch,
  • bank (roll). The angles are relative to the coordinate system of the parent entity.
tuple GetAxisX ( )

Returns the x-axis of the local coordinate system of this entity.

The local coordinate system expresses the orientation of the entity. It is relative to the entity's parent.

tuple GetAxisY ( )

Returns the y-axis of the local coordinate system of this entity.

The local coordinate system expresses the orientation of the entity. It is relative to the entity's parent.

tuple GetAxisZ ( )

Returns the z-axis of the local coordinate system of this entity.

The local coordinate system expresses the orientation of the entity. It is relative to the entity's parent.

tuple GetOriginWS ( )

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

LookAt ( number  PosX,
number  PosY,
number  PosZ,
integer  AxisNr = 0,
boolean  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
PosXThe target position to look at (x-component).
PosYThe target position to look at (y-component).
PosZThe target position to look at (z-component).
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).
SetAngles ( number  heading,
number  pitch = 0.0,
number  bank = 0.0 
)

Sets the orientation of this entity from a set of three angles, measured in degrees:

  • heading (yaw),
  • pitch,
  • bank (roll). The angles are relative to the coordinate system of the parent entity.
SetOriginWS ( number  x,
number  y,
number  z 
)

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

Member Data Documentation

tuple Orientation

The orientation of the entity (in the coordinate system of its parent).

Related C++ type:
Vector3fT
tuple Origin

The origin of the entity (in the coordinate system of its parent).

Related C++ type:
Vector3fT