Pyrogenesis  trunk
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
CCmpPosition Class Reference

Basic ICmpPosition implementation. More...

Inheritance diagram for CCmpPosition:
Inheritance graph
[legend]
Collaboration diagram for CCmpPosition:
Collaboration graph
[legend]

Public Types

enum  { UPRIGHT = 0, PITCH = 1, PITCH_ROLL = 2, ROLL = 3 }
 

Public Member Functions

virtual int GetComponentTypeId () const
 
virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
virtual void Serialize (ISerializer &serialize)
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)
 
void Deserialized ()
 
virtual void UpdateTurretPosition ()
 Has to be called to update the simulation position of the turret. More...
 
virtual std::set< entity_id_t > * GetTurrets ()
 Get the list of turrets to read or edit. More...
 
virtual void SetTurretParent (entity_id_t id, const CFixedVector3D &offset)
 Set this as a turret of an other entity. More...
 
virtual entity_id_t GetTurretParent () const
 Get the turret parent of this entity. More...
 
virtual bool IsInWorld () const
 Returns true if the entity currently exists at a defined position in the world. More...
 
virtual void MoveOutOfWorld ()
 Causes IsInWorld to return false. More...
 
virtual void MoveTo (entity_pos_t x, entity_pos_t z)
 Move smoothly to the given location. More...
 
virtual void MoveAndTurnTo (entity_pos_t x, entity_pos_t z, entity_angle_t ry)
 Combines MoveTo and TurnTo to avoid an uncessary "AdvertisePositionChange". More...
 
virtual void JumpTo (entity_pos_t x, entity_pos_t z)
 Move immediately to the given location, with no interpolation. More...
 
virtual void SetHeightOffset (entity_pos_t dy)
 Set the vertical offset above the terrain/water surface. More...
 
virtual entity_pos_t GetHeightOffset () const
 Returns the current vertical offset above the terrain/water surface. More...
 
virtual void SetHeightFixed (entity_pos_t y)
 Set the vertical position above the map zero point. More...
 
virtual entity_pos_t GetHeightFixed () const
 Returns the vertical offset above the map zero point. More...
 
virtual bool IsHeightRelative () const
 Returns true iff the entity will follow the terrain height (possibly with an offset) More...
 
virtual void SetHeightRelative (bool relative)
 When set to true, the entity will follow the terrain height (possibly with an offset) When set to false, it's height won't change automatically. More...
 
virtual bool IsFloating () const
 Returns whether the entity floats on water. More...
 
virtual void SetFloating (bool flag)
 Set the entity to float on water. More...
 
virtual void SetActorFloating (bool flag)
 Set the entity to float on water, in a non-network-synchronised visual-only way. More...
 
virtual void SetConstructionProgress (fixed progress)
 Set construction progress of the model, this affects the rendered position of the model. More...
 
virtual CFixedVector3D GetPosition () const
 Returns the current x,y,z position (no interpolation). More...
 
virtual CFixedVector2D GetPosition2D () const
 Returns the current x,z position (no interpolation). More...
 
virtual CFixedVector3D GetPreviousPosition () const
 Returns the previous turn's x,y,z position (no interpolation). More...
 
virtual CFixedVector2D GetPreviousPosition2D () const
 Returns the previous turn's x,z position (no interpolation). More...
 
virtual void TurnTo (entity_angle_t y)
 Rotate smoothly to the given angle around the upwards axis. More...
 
virtual void SetYRotation (entity_angle_t y)
 Rotate immediately to the given angle around the upwards axis. More...
 
virtual void SetXZRotation (entity_angle_t x, entity_angle_t z)
 Rotate immediately to the given angles around the X (pitch) and Z (roll) axes. More...
 
virtual CFixedVector3D GetRotation () const
 Returns the current rotation (relative to the upwards axis), as Euler angles with X=pitch, Y=yaw, Z=roll. More...
 
virtual fixed GetDistanceTravelled () const
 Returns the distance that the unit will be interpolated over, i.e. More...
 
float GetConstructionProgressOffset (const CVector3D &pos) const
 
virtual void GetInterpolatedPosition2D (float frameOffset, float &x, float &z, float &rotY) const
 Get the current interpolated 2D position and orientation, for rendering. More...
 
virtual CMatrix3D GetInterpolatedTransform (float frameOffset) const
 Get the current interpolated transform matrix, for rendering. More...
 
void GetInterpolatedPositions (CVector3D &pos0, CVector3D &pos1) const
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual bool NewJSObject (ScriptInterface &scriptInterface, JS::MutableHandleObject out) const
 Returns false by default, indicating that a scripted wrapper of this IComponent is not supported. More...
 
virtual JS::Value GetJSInstance () const
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static u8 GetSerializationVersion ()
 

Public Attributes

enum CCmpPosition:: { ... }  m_AnchorType
 
bool m_Floating
 
float m_RotYSpeed
 
bool m_InWorld
 
entity_pos_t m_X
 
entity_pos_t m_Z
 
entity_pos_t m_LastX
 
entity_pos_t m_LastZ
 
entity_pos_t m_PrevX
 
entity_pos_t m_PrevZ
 
entity_pos_t m_Y
 
entity_pos_t m_LastYDifference
 
bool m_RelativeToGround
 
fixed m_ConstructionProgress
 
entity_angle_t m_RotX
 
entity_angle_t m_RotY
 
entity_angle_t m_RotZ
 
player_id_t m_Territory
 
entity_id_t m_TurretParent
 
CFixedVector3D m_TurretPosition
 
std::set< entity_id_tm_Turrets
 
float m_InterpolatedRotX
 
float m_InterpolatedRotY
 
float m_InterpolatedRotZ
 
float m_LastInterpolatedRotX
 
float m_LastInterpolatedRotZ
 
bool m_ActorFloating
 
bool m_EnabledMessageInterpolate
 

Private Member Functions

void UpdateMessageSubscriptions ()
 
void AdvertisePositionChanges () const
 This must be called after changing anything that will affect the return value of GetPosition2D() or GetRotation().Y: More...
 
void AdvertiseInterpolatedPositionChanges () const
 This must be called after changing anything that will affect the return value of GetInterpolatedPositions(): More...
 
void UpdateXZRotation ()
 

Detailed Description

Basic ICmpPosition implementation.

Member Enumeration Documentation

anonymous enum
Enumerator
UPRIGHT 
PITCH 
PITCH_ROLL 
ROLL 

Member Function Documentation

void CCmpPosition::AdvertiseInterpolatedPositionChanges ( ) const
inlineprivate

This must be called after changing anything that will affect the return value of GetInterpolatedPositions():

  • m_InWorld
  • m_X, m_Z
  • m_LastX, m_LastZ
  • m_Y, m_LastYDifference, m_RelativeToGround
  • If m_RelativeToGround, then the ground under this unit
  • If m_RelativeToGround && m_Float, then the water level
void CCmpPosition::AdvertisePositionChanges ( ) const
inlineprivate

This must be called after changing anything that will affect the return value of GetPosition2D() or GetRotation().Y:

  • m_InWorld
  • m_X, m_Z
  • m_RotY
static IComponent* CCmpPosition::Allocate ( ScriptInterface ,
JS::HandleValue   
)
inlinestatic
static void CCmpPosition::ClassInit ( CComponentManager componentManager)
inlinestatic
static void CCmpPosition::Deallocate ( IComponent cmp)
inlinestatic
virtual void CCmpPosition::Deinit ( )
inlinevirtual

Implements IComponent.

virtual void CCmpPosition::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
inlinevirtual

Implements IComponent.

void CCmpPosition::Deserialized ( )
inline
virtual int CCmpPosition::GetComponentTypeId ( ) const
inlinevirtual

Implements IComponent.

float CCmpPosition::GetConstructionProgressOffset ( const CVector3D pos) const
inline
virtual fixed CCmpPosition::GetDistanceTravelled ( ) const
inlinevirtual

Returns the distance that the unit will be interpolated over, i.e.

the distance travelled since the start of the turn.

Implements ICmpPosition.

virtual entity_pos_t CCmpPosition::GetHeightFixed ( ) const
inlinevirtual

Returns the vertical offset above the map zero point.

Implements ICmpPosition.

virtual entity_pos_t CCmpPosition::GetHeightOffset ( ) const
inlinevirtual

Returns the current vertical offset above the terrain/water surface.

Implements ICmpPosition.

virtual void CCmpPosition::GetInterpolatedPosition2D ( float  frameOffset,
float &  x,
float &  z,
float &  rotY 
) const
inlinevirtual

Get the current interpolated 2D position and orientation, for rendering.

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

void CCmpPosition::GetInterpolatedPositions ( CVector3D pos0,
CVector3D pos1 
) const
inline
virtual CMatrix3D CCmpPosition::GetInterpolatedTransform ( float  frameOffset) const
inlinevirtual

Get the current interpolated transform matrix, for rendering.

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

virtual CFixedVector3D CCmpPosition::GetPosition ( ) const
inlinevirtual

Returns the current x,y,z position (no interpolation).

Depends on the current terrain heightmap. Must not be called unless IsInWorld is true.

Implements ICmpPosition.

virtual CFixedVector2D CCmpPosition::GetPosition2D ( ) const
inlinevirtual

Returns the current x,z position (no interpolation).

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

virtual CFixedVector3D CCmpPosition::GetPreviousPosition ( ) const
inlinevirtual

Returns the previous turn's x,y,z position (no interpolation).

Depends on the current terrain heightmap. Must not be called unless IsInWorld is true.

Implements ICmpPosition.

virtual CFixedVector2D CCmpPosition::GetPreviousPosition2D ( ) const
inlinevirtual

Returns the previous turn's x,z position (no interpolation).

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

virtual CFixedVector3D CCmpPosition::GetRotation ( ) const
inlinevirtual

Returns the current rotation (relative to the upwards axis), as Euler angles with X=pitch, Y=yaw, Z=roll.

(TODO: is that the right way round?)

Implements ICmpPosition.

static std::string CCmpPosition::GetSchema ( )
inlinestatic
virtual entity_id_t CCmpPosition::GetTurretParent ( ) const
inlinevirtual

Get the turret parent of this entity.

Implements ICmpPosition.

virtual std::set<entity_id_t>* CCmpPosition::GetTurrets ( )
inlinevirtual

Get the list of turrets to read or edit.

Implements ICmpPosition.

virtual void CCmpPosition::HandleMessage ( const CMessage msg,
bool  global 
)
inlinevirtual

Reimplemented from IComponent.

virtual void CCmpPosition::Init ( const CParamNode paramNode)
inlinevirtual

Implements IComponent.

virtual bool CCmpPosition::IsFloating ( ) const
inlinevirtual

Returns whether the entity floats on water.

Implements ICmpPosition.

virtual bool CCmpPosition::IsHeightRelative ( ) const
inlinevirtual

Returns true iff the entity will follow the terrain height (possibly with an offset)

Implements ICmpPosition.

virtual bool CCmpPosition::IsInWorld ( ) const
inlinevirtual

Returns true if the entity currently exists at a defined position in the world.

Implements ICmpPosition.

virtual void CCmpPosition::JumpTo ( entity_pos_t  x,
entity_pos_t  z 
)
inlinevirtual

Move immediately to the given location, with no interpolation.

Implements ICmpPosition.

virtual void CCmpPosition::MoveAndTurnTo ( entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  ry 
)
inlinevirtual

Combines MoveTo and TurnTo to avoid an uncessary "AdvertisePositionChange".

Implements ICmpPosition.

virtual void CCmpPosition::MoveOutOfWorld ( )
inlinevirtual

Causes IsInWorld to return false.

(Use MoveTo() or JumpTo() to move back into the world.)

Implements ICmpPosition.

virtual void CCmpPosition::MoveTo ( entity_pos_t  x,
entity_pos_t  z 
)
inlinevirtual

Move smoothly to the given location.

Implements ICmpPosition.

virtual void CCmpPosition::Serialize ( ISerializer serialize)
inlinevirtual

Implements IComponent.

virtual void CCmpPosition::SetActorFloating ( bool  flag)
inlinevirtual

Set the entity to float on water, in a non-network-synchronised visual-only way.

(This is to support the 'floating' flag in actor XMLs.)

Implements ICmpPosition.

virtual void CCmpPosition::SetConstructionProgress ( fixed  progress)
inlinevirtual

Set construction progress of the model, this affects the rendered position of the model.

0.0 will be fully underground, 1.0 will be fully visible, 0.5 will be half underground.

Implements ICmpPosition.

virtual void CCmpPosition::SetFloating ( bool  flag)
inlinevirtual

Set the entity to float on water.

Implements ICmpPosition.

virtual void CCmpPosition::SetHeightFixed ( entity_pos_t  y)
inlinevirtual

Set the vertical position above the map zero point.

Implements ICmpPosition.

virtual void CCmpPosition::SetHeightOffset ( entity_pos_t  dy)
inlinevirtual

Set the vertical offset above the terrain/water surface.

Implements ICmpPosition.

virtual void CCmpPosition::SetHeightRelative ( bool  flag)
inlinevirtual

When set to true, the entity will follow the terrain height (possibly with an offset) When set to false, it's height won't change automatically.

Implements ICmpPosition.

virtual void CCmpPosition::SetTurretParent ( entity_id_t  parent,
const CFixedVector3D offset 
)
inlinevirtual

Set this as a turret of an other entity.

Implements ICmpPosition.

virtual void CCmpPosition::SetXZRotation ( entity_angle_t  x,
entity_angle_t  z 
)
inlinevirtual

Rotate immediately to the given angles around the X (pitch) and Z (roll) axes.

Parameters
xradians around the X axis. (TODO: in which direction?)
zradians around the Z axis.
Note
if either x or z is non-zero, it will override terrain conformance mode

Implements ICmpPosition.

virtual void CCmpPosition::SetYRotation ( entity_angle_t  y)
inlinevirtual

Rotate immediately to the given angle around the upwards axis.

Parameters
yclockwise radians from the +Z axis.

Implements ICmpPosition.

virtual void CCmpPosition::TurnTo ( entity_angle_t  y)
inlinevirtual

Rotate smoothly to the given angle around the upwards axis.

Parameters
yclockwise radians from the +Z axis.

Implements ICmpPosition.

void CCmpPosition::UpdateMessageSubscriptions ( )
inlineprivate
virtual void CCmpPosition::UpdateTurretPosition ( )
inlinevirtual

Has to be called to update the simulation position of the turret.

Implements ICmpPosition.

void CCmpPosition::UpdateXZRotation ( )
inlineprivate

Member Data Documentation

bool CCmpPosition::m_ActorFloating
enum { ... } CCmpPosition::m_AnchorType
fixed CCmpPosition::m_ConstructionProgress
bool CCmpPosition::m_EnabledMessageInterpolate
bool CCmpPosition::m_Floating
float CCmpPosition::m_InterpolatedRotX
float CCmpPosition::m_InterpolatedRotY
float CCmpPosition::m_InterpolatedRotZ
bool CCmpPosition::m_InWorld
float CCmpPosition::m_LastInterpolatedRotX
float CCmpPosition::m_LastInterpolatedRotZ
entity_pos_t CCmpPosition::m_LastX
entity_pos_t CCmpPosition::m_LastYDifference
entity_pos_t CCmpPosition::m_LastZ
entity_pos_t CCmpPosition::m_PrevX
entity_pos_t CCmpPosition::m_PrevZ
bool CCmpPosition::m_RelativeToGround
entity_angle_t CCmpPosition::m_RotX
entity_angle_t CCmpPosition::m_RotY
float CCmpPosition::m_RotYSpeed
entity_angle_t CCmpPosition::m_RotZ
player_id_t CCmpPosition::m_Territory
entity_id_t CCmpPosition::m_TurretParent
CFixedVector3D CCmpPosition::m_TurretPosition
std::set<entity_id_t> CCmpPosition::m_Turrets
entity_pos_t CCmpPosition::m_X
entity_pos_t CCmpPosition::m_Y
entity_pos_t CCmpPosition::m_Z

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