Pyrogenesis  trunk
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CCmpVisualActor Class Referencefinal
Inheritance diagram for CCmpVisualActor:
Inheritance graph
[legend]
Collaboration diagram for CCmpVisualActor:
Collaboration graph
[legend]

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
template<typename S >
void SerializeCommon (S &serialize)
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
CBoundingBoxAligned GetBounds () const override
 Get the world-space bounding box of the object's visual representation. More...
 
CUnitGetUnit () override
 Returns the underlying unit of this visual actor. More...
 
CBoundingBoxOriented GetSelectionBox () const override
 Get the oriented world-space bounding box of the object's visual representation, clipped at the Y=0 plane in object space to prevent it from extending into the terrain. More...
 
CVector3D GetPosition () const override
 Get the world-space position of the base point of the object's visual representation. More...
 
std::wstring GetProjectileActor () const override
 Return the filename of the actor to be used for projectiles from this unit, or the empty string if none. More...
 
CFixedVector3D GetProjectileLaunchPoint () const override
 Return the exact position where a projectile should be launched from (based on the actor's ammo prop points). More...
 
void SetVariant (const CStr &key, const CStr &selection) override
 Set the variant selection of the actor for a certain key. More...
 
std::string GetAnimationName () const override
 Returns the name of the currently played animation. More...
 
void SelectAnimation (const std::string &name, bool once=false, fixed speed=fixed::FromInt(1)) override
 Start playing the given animation. More...
 
void SelectMovementAnimation (const std::string &name, fixed speed) override
 Start playing the given movement animation unless we are currently playing a non-movement animation. More...
 
void SetAnimationSyncRepeat (fixed repeattime) override
 Adjust the speed of the current animation, so it can match simulation events. More...
 
void SetAnimationSyncOffset (fixed actiontime) override
 Adjust the offset of the current animation, so it can match simulation events. More...
 
void SetShadingColor (fixed r, fixed g, fixed b, fixed a) override
 Set the shading color that will be modulated with the model's textures. More...
 
void SetVariable (const std::string &name, float value) override
 Set an arbitrarily-named variable that the model may use to alter its appearance (e.g. More...
 
u32 GetActorSeed () const override
 Get actor seed used for random variations. More...
 
void SetActorSeed (u32 seed) override
 Set actor seed for random variations and reload model. More...
 
void RecomputeActorName () override
 Recalculate the actor name, applying modifiers. More...
 
bool HasConstructionPreview () const override
 Returns true if this entity should have a construction preview. More...
 
void Hotload (const VfsPath &name) override
 Called when an actor file has been modified and reloaded dynamically. More...
 
- 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 (const 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 (const ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static void RegisterComponentType (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static void RegisterComponentTypeScriptWrapper (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static u8 GetSerializationVersion ()
 

Private Member Functions

void ParseActorName (std::wstring base)
 
void InitModel ()
 Helper function shared by component init and actor reloading. More...
 
void InitSelectionShapeDescriptor (const CParamNode &paramNode)
 Helper method; initializes the model selection shape descriptor from XML. Factored out for readability of Init. More...
 
void ReloadActor ()
 
void ReloadUnitAnimation ()
 

Private Attributes

std::wstring m_BaseActorName
 
std::wstring m_ActorName
 
bool m_IsFoundationActor
 
CUnitm_Unit
 
CModelAbstract::CustomSelectionShapem_ShapeDescriptor = nullptr
 
fixed m_R
 
fixed m_G
 
fixed m_B
 
std::string m_AnimName
 
bool m_AnimOnce
 
fixed m_AnimSpeed
 
std::wstring m_SoundGroup
 
fixed m_AnimDesync
 
fixed m_AnimSyncRepeatTime
 
fixed m_AnimSyncOffsetTime
 
std::map< CStr, CStr > m_VariantSelections
 
u32 m_Seed
 
bool m_ConstructionPreview
 
bool m_VisibleInAtlasOnly
 
bool m_IsActorOnly
 
bool m_SilhouetteDisplay
 
bool m_SilhouetteOccluder
 
bool m_DisableShadows
 
ICmpUnitRenderer::tag_t m_ModelTag
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Member Function Documentation

◆ Allocate()

static IComponent* CCmpVisualActor::Allocate ( const ScriptInterface ,
JS::HandleValue   
)
inlinestatic

◆ ClassInit()

static void CCmpVisualActor::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ Deallocate()

static void CCmpVisualActor::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpVisualActor::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpVisualActor::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
inlineoverridevirtual

Implements IComponent.

◆ GetActorSeed()

u32 CCmpVisualActor::GetActorSeed ( ) const
inlineoverridevirtual

Get actor seed used for random variations.

Implements ICmpVisual.

◆ GetAnimationName()

std::string CCmpVisualActor::GetAnimationName ( ) const
inlineoverridevirtual

Returns the name of the currently played animation.

Implements ICmpVisual.

◆ GetBounds()

CBoundingBoxAligned CCmpVisualActor::GetBounds ( ) const
inlineoverridevirtual

Get the world-space bounding box of the object's visual representation.

(Not safe for use in simulation code.)

Implements ICmpVisual.

◆ GetComponentTypeId()

int CCmpVisualActor::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetPosition()

CVector3D CCmpVisualActor::GetPosition ( ) const
inlineoverridevirtual

Get the world-space position of the base point of the object's visual representation.

(Not safe for use in simulation code.)

Implements ICmpVisual.

◆ GetProjectileActor()

std::wstring CCmpVisualActor::GetProjectileActor ( ) const
inlineoverridevirtual

Return the filename of the actor to be used for projectiles from this unit, or the empty string if none.

(Not safe for use in simulation code.)

Implements ICmpVisual.

◆ GetProjectileLaunchPoint()

CFixedVector3D CCmpVisualActor::GetProjectileLaunchPoint ( ) const
inlineoverridevirtual

Return the exact position where a projectile should be launched from (based on the actor's ammo prop points).

Return type is CFixedVector3D because it is exposed to the JS interface. Returns (0,0,0) if no point can be found.

Implements ICmpVisual.

◆ GetSchema()

static std::string CCmpVisualActor::GetSchema ( )
inlinestatic

◆ GetSelectionBox()

CBoundingBoxOriented CCmpVisualActor::GetSelectionBox ( ) const
inlineoverridevirtual

Get the oriented world-space bounding box of the object's visual representation, clipped at the Y=0 plane in object space to prevent it from extending into the terrain.

The primary difference with GetBounds is that this bounding box is not aligned to the world axes, but arbitrarily rotated according to the model transform.

Implements ICmpVisual.

◆ GetUnit()

CUnit* CCmpVisualActor::GetUnit ( )
inlineoverridevirtual

Returns the underlying unit of this visual actor.

May return NULL to indicate that no unit exists (e.g. may happen if the game is started without graphics rendering). Originally intended for introspection purposes in Atlas; for other purposes, consider using a specialized getter first.

Implements ICmpVisual.

◆ HandleMessage()

void CCmpVisualActor::HandleMessage ( const CMessage msg,
bool  global 
)
inlineoverridevirtual

Reimplemented from IComponent.

◆ HasConstructionPreview()

bool CCmpVisualActor::HasConstructionPreview ( ) const
inlineoverridevirtual

Returns true if this entity should have a construction preview.

Implements ICmpVisual.

◆ Hotload()

void CCmpVisualActor::Hotload ( const VfsPath name)
inlineoverridevirtual

Called when an actor file has been modified and reloaded dynamically.

If this component uses the named actor file, it should regenerate its actor to pick up the new definitions. If name is empty, this reloads all the time. This is used when global quality settings change.

Implements ICmpVisual.

◆ Init()

void CCmpVisualActor::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ InitModel()

void CCmpVisualActor::InitModel ( )
private

Helper function shared by component init and actor reloading.

◆ InitSelectionShapeDescriptor()

void CCmpVisualActor::InitSelectionShapeDescriptor ( const CParamNode paramNode)
private

Helper method; initializes the model selection shape descriptor from XML. Factored out for readability of Init.

◆ ParseActorName()

void CCmpVisualActor::ParseActorName ( std::wstring  base)
private

◆ RecomputeActorName()

void CCmpVisualActor::RecomputeActorName ( )
inlineoverridevirtual

Recalculate the actor name, applying modifiers.

Implements ICmpVisual.

◆ ReloadActor()

void CCmpVisualActor::ReloadActor ( )
private

◆ ReloadUnitAnimation()

void CCmpVisualActor::ReloadUnitAnimation ( )
private

◆ SelectAnimation()

void CCmpVisualActor::SelectAnimation ( const std::string &  name,
bool  once = false,
fixed  speed = fixed::FromInt(1) 
)
inlineoverridevirtual

Start playing the given animation.

If there are multiple possible animations then it will pick one at random (not network-synchronised).

Parameters
nameanimation name (e.g. "idle", "walk", "melee"; the names are determined by actor XML files)
onceif true then the animation will play once and freeze at the final frame, else it will loop
speedanimation speed multiplier (typically 1.0 for the default speed)

Implements ICmpVisual.

◆ SelectMovementAnimation()

void CCmpVisualActor::SelectMovementAnimation ( const std::string &  name,
fixed  speed 
)
inlineoverridevirtual

Start playing the given movement animation unless we are currently playing a non-movement animation.

This is necessary so UnitMotion can set the movement animations without overwriting specific animations that might have been set by other components. TODO: Non-movement animations should probably be made into variants, defining "idle" (really "default"), "walk" and "run" as appropriate, and this would no longer be necessary.

Parameters
nameanimation name (i.e. one of "idle", "walk", "run").
speedanimation speed multiplier (typically 1.0 for the default speed)

Implements ICmpVisual.

◆ Serialize()

void CCmpVisualActor::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ SerializeCommon()

template<typename S >
void CCmpVisualActor::SerializeCommon ( S &  serialize)
inline

◆ SetActorSeed()

void CCmpVisualActor::SetActorSeed ( u32  seed)
inlineoverridevirtual

Set actor seed for random variations and reload model.

Implements ICmpVisual.

◆ SetAnimationSyncOffset()

void CCmpVisualActor::SetAnimationSyncOffset ( fixed  actiontime)
inlineoverridevirtual

Adjust the offset of the current animation, so it can match simulation events.

Parameters
actiontimetime between now and when the 'action' event should occur, in msec

Implements ICmpVisual.

◆ SetAnimationSyncRepeat()

void CCmpVisualActor::SetAnimationSyncRepeat ( fixed  repeattime)
inlineoverridevirtual

Adjust the speed of the current animation, so it can match simulation events.

Parameters
repeattimetime for complete loop of animation, in msec

Implements ICmpVisual.

◆ SetShadingColor()

void CCmpVisualActor::SetShadingColor ( fixed  r,
fixed  g,
fixed  b,
fixed  a 
)
inlineoverridevirtual

Set the shading color that will be modulated with the model's textures.

Default shading is (1, 1, 1, 1). Alpha should probably be 1 else it's unlikely to work properly.

Parameters
rred component, expected range [0, 1]
ggreen component, expected range [0, 1]
bblue component, expected range [0, 1]
aalpha component, expected range [0, 1]

Implements ICmpVisual.

◆ SetVariable()

void CCmpVisualActor::SetVariable ( const std::string &  name,
float  value 
)
inlineoverridevirtual

Set an arbitrarily-named variable that the model may use to alter its appearance (e.g.

in particle emitter parameter computations).

Implements ICmpVisual.

◆ SetVariant()

void CCmpVisualActor::SetVariant ( const CStr &  key,
const CStr &  selection 
)
inlineoverridevirtual

Set the variant selection of the actor for a certain key.

This overrides a previous selection on that key, so every component should use unique keys.

Implements ICmpVisual.

Member Data Documentation

◆ m_ActorName

std::wstring CCmpVisualActor::m_ActorName
private

◆ m_AnimDesync

fixed CCmpVisualActor::m_AnimDesync
private

◆ m_AnimName

std::string CCmpVisualActor::m_AnimName
private

◆ m_AnimOnce

bool CCmpVisualActor::m_AnimOnce
private

◆ m_AnimSpeed

fixed CCmpVisualActor::m_AnimSpeed
private

◆ m_AnimSyncOffsetTime

fixed CCmpVisualActor::m_AnimSyncOffsetTime
private

◆ m_AnimSyncRepeatTime

fixed CCmpVisualActor::m_AnimSyncRepeatTime
private

◆ m_B

fixed CCmpVisualActor::m_B
private

◆ m_BaseActorName

std::wstring CCmpVisualActor::m_BaseActorName
private

◆ m_ConstructionPreview

bool CCmpVisualActor::m_ConstructionPreview
private

◆ m_DisableShadows

bool CCmpVisualActor::m_DisableShadows
private

◆ m_G

fixed CCmpVisualActor::m_G
private

◆ m_IsActorOnly

bool CCmpVisualActor::m_IsActorOnly
private

◆ m_IsFoundationActor

bool CCmpVisualActor::m_IsFoundationActor
private

◆ m_ModelTag

ICmpUnitRenderer::tag_t CCmpVisualActor::m_ModelTag
private

◆ m_R

fixed CCmpVisualActor::m_R
private

◆ m_Seed

u32 CCmpVisualActor::m_Seed
private

◆ m_ShapeDescriptor

CModelAbstract::CustomSelectionShape* CCmpVisualActor::m_ShapeDescriptor = nullptr
private

◆ m_SilhouetteDisplay

bool CCmpVisualActor::m_SilhouetteDisplay
private

◆ m_SilhouetteOccluder

bool CCmpVisualActor::m_SilhouetteOccluder
private

◆ m_SoundGroup

std::wstring CCmpVisualActor::m_SoundGroup
private

◆ m_Unit

CUnit* CCmpVisualActor::m_Unit
private

◆ m_VariantSelections

std::map<CStr, CStr> CCmpVisualActor::m_VariantSelections
private

◆ m_VisibleInAtlasOnly

bool CCmpVisualActor::m_VisibleInAtlasOnly
private

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