Cafu Engine
cf::GameSys::ComponentModelT Class Reference

This component adds a 3D model to its entity. More...

#include "CompModel.hpp"

Inheritance diagram for cf::GameSys::ComponentModelT:

Public Member Functions

 ComponentModelT ()
 The constructor. More...
 
 ComponentModelT (const ComponentModelT &Comp)
 The copy constructor. More...
 
 ~ComponentModelT ()
 The destructor. More...
 
AnimPoseTGetPose () const
 Returns the current pose of this model (or NULL if there is no pose (yet)). More...
 
IntrusivePtrT
< cf::GuiSys::GuiImplT
GetGui () const
 Returns the GUI instance of this model, if it has one (or NULL otherwise). More...
 
ComponentModelTClone () const
 The virtual copy constructor. More...
 
const char * GetName () const
 Returns the name of this component. More...
 
void UpdateDependencies (EntityT *Entity)
 This method is called whenever something "external" to this component has changed: More...
 
unsigned int GetEditorColor () const
 Returns a color that the Map Editor can use to render the representation of this component's entity. More...
 
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...
 
BoundingBox3fT GetCullingBB () const
 This method returns a bounding-box that encloses the visual representation of this component. More...
 
bool Render (bool FirstPersonView, float LodDist) const
 This method implements the graphical output of this component. More...
 
void DoServerFrame (float t)
 Derived classes override this method in order to implement the real work proposed by OnServerFrame(), which explicitly calls this method for this purpose. More...
 
void DoClientFrame (float t)
 Derived classes override this method in order to implement the real work proposed by OnClientFrame(), which explicitly calls this method for this purpose. 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 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 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 GetNumAnims (lua_State *LuaState)
 
static int GetNumSkins (lua_State *LuaState)
 
static int GetGui (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::MethsDocT DocCallbacks []
 
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 a 3D model to its entity.

Models can be used to add geometric detail to a map. Some models also have ready-made "GUI fixtures" where scripted GUIs can be attached that players can interact with. Use the CaWE Model Editor in order to import mesh and animation data for models, and to prepare them for use in game maps.

Constructor & Destructor Documentation

ComponentModelT::ComponentModelT ( )

The constructor.

ComponentModelT::ComponentModelT ( const ComponentModelT Comp)

The copy constructor.

Parameters
CompThe component to create a copy of.
ComponentModelT::~ComponentModelT ( )

The destructor.

Member Function Documentation

ComponentModelT * ComponentModelT::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.

void ComponentModelT::DoClientFrame ( float  t)
virtual

Derived classes override this method in order to implement the real work proposed by OnClientFrame(), which explicitly calls this method for this purpose.

(This follows the "Non-Virtual Interface Idiom" as described by Scott Meyers in "Effective C++, 3rd Edition", item 35 ("Consider alternatives to virtual functions.").)

Reimplemented from cf::GameSys::ComponentBaseT.

void ComponentModelT::DoServerFrame ( float  t)
virtual

Derived classes override this method in order to implement the real work proposed by OnServerFrame(), which explicitly calls this method for this purpose.

(This follows the "Non-Virtual Interface Idiom" as described by Scott Meyers in "Effective C++, 3rd Edition", item 35 ("Consider alternatives to virtual functions.").)

Reimplemented from cf::GameSys::ComponentBaseT.

BoundingBox3fT ComponentModelT::GetCullingBB ( ) const
virtual

This method returns a bounding-box that encloses the visual representation of this component.

It is used to determine if the entity is in the view-frustum of a camera, how large a region must be updated in the 2D views of a Map Editor, if the entity is in the potentially-visibility-set (PVS) of another entity, and similar purposes.

The returned bounding-box is in local space, i.e. typically centered around the origin (0, 0, 0). If the component doesn't have a visual representation, the returned bounding-box may be uninitialized (!IsInited()). Also see EntityT::GetCullingBB() for additional details.

Reimplemented from cf::GameSys::ComponentBaseT.

BoundingBox3fT ComponentModelT::GetEditorBB ( ) const
virtual

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.

The Map Editor may use the bounding-box of an entity's first component as returned by this method to render the visual representation of the entity.

Note that the returned bounding-box is often smaller than the bounding-box returned by GetCullingBB(), e.g. for light sources (whose radius and thus their indirect effects on other objects it may not cover), for trees (whose trunk it usually covers, but maybe not their crown), or for models (that, when animated, may break the limits of the static bounding-box).

On the other hand, the returned bounding-box may also be larger than the bounding-box returned by GetCullingBB(), e.g. for models that are not initialized. Such models would be "invisible" in the 2D and 3D views of the Map Editor if we didn't return "dummy" bounding-boxes for them so that users can see and work with them.

The returned bounding-box is in local entity space and is always initialized (IsInited() == true).

Reimplemented from cf::GameSys::ComponentBaseT.

unsigned int cf::GameSys::ComponentModelT::GetEditorColor ( ) const
inlinevirtual

Returns a color that the Map Editor can use to render the representation of this component's entity.

The Map Editor may use the color of an entity's first component as returned by this method to render the visual representation of the entity.

Reimplemented from cf::GameSys::ComponentBaseT.

IntrusivePtrT< cf::GuiSys::GuiImplT > ComponentModelT::GetGui ( ) const

Returns the GUI instance of this model, if it has one (or NULL otherwise).

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

Returns the name of this component.

Reimplemented from cf::GameSys::ComponentBaseT.

AnimPoseT * ComponentModelT::GetPose ( ) const

Returns the current pose of this model (or NULL if there is no pose (yet)).

bool ComponentModelT::Render ( bool  FirstPersonView,
float  LodDist 
) const
virtual

This method implements the graphical output of this component.

Parameters
FirstPersonViewIf the world is rendered from the perspective of this component's entity.
LodDistThe distance of the viewer entity to this component's entity.
Returns
true if "something" was rendered, false otherwise (in this case the Map Editor may choose to render another visual representation of this component's entity).

Reimplemented from cf::GameSys::ComponentBaseT.

void ComponentModelT::UpdateDependencies ( EntityT Entity)
virtual

This method is called whenever something "external" to this component has changed:

  • if the parent entity has changed, because this component was added to or removed from it,
  • if other components in the parent entity have changed. The component can use the opportunity to search the entity for "sibling" components that it depends on, and store direct pointers to them. Note however that dependencies among components must not be cyclic, or else the deletion of an entity will leave a memory leak.
    Parameters
    EntityThe parent entity that contains this component, or NULL to indicate that this component is removed from the entity that it used to be a part of.

Reimplemented from cf::GameSys::ComponentBaseT.

Member Data Documentation

const cf::TypeSys::MethsDocT ComponentModelT::DocCallbacks
staticprotected
Initial value:
=
{
{ "OnAnimationChange",
"This method is called when a new animation sequence number is set for this model.",
"tuple", "(int AnimNr)" },
{ "OnSequenceWrap_Sv",
"This method is called when playing the model's current animation sequence \"wraps\".",
"", "" },
{ "OnSequenceWrap",
"This method is called when playing the model's current animation sequence \"wraps\".",
"", "" },
{ NULL, NULL, NULL, NULL }
}
const char * ComponentModelT::DocClass
staticprotected
Initial value:
=
"This component adds a 3D model to its entity.\n"
"Models can be used to add geometric detail to a map. Some models also have ready-made\n"
"\"GUI fixtures\" where scripted GUIs can be attached that players can interact with.\n"
"Use the CaWE Model Editor in order to import mesh and animation data for models, and\n"
"to prepare them for use in game maps.\n"
const cf::TypeSys::MethsDocT ComponentModelT::DocMethods
staticprotected
Initial value:
=
{
META_GetNumAnims,
META_GetNumSkins,
META_GetGui,
META_toString,
{ NULL, NULL, NULL, NULL }
}
const cf::TypeSys::VarsDocT ComponentModelT::DocVars
staticprotected
Initial value:
=
{
{ "Show", "Whether the model is currently shown (useful with scripts)." },
{ "Name", "The file name of the model." },
{ "Animation", "The animation sequence number of the model." },
{ "Skin", "The skin used for rendering the model." },
{ "Scale", "The scale factor applied to the model coordinates when converted to world space." },
{ "Gui", "The file name of the GUI to be used with the models GUI fixtures (if there are any)." },
{ "IsSubmodel", "Is this model a submodel of another model? If set, the pose of this model is aligned with the first \"non-submodel\" in the entity." },
{ "Is1stPerson", "Is this a 1st-person view model? If `true`, the model is rendered if the world is rendered from *this* entity's perspective. If `false`, the model is rendered when seen from the outside, i.e. in everybody else's view. The default is `false`, because `true` is normally only used with the human player's 1st-person carried weapon models." },
{ NULL, NULL }
}
const luaL_Reg ComponentModelT::MethodsList
staticprotected
Initial value:
=
{
{ "GetNumAnims", GetNumAnims },
{ "GetNumSkins", GetNumSkins },
{ "GetGui", GetGui },
{ "__tostring", toString },
{ NULL, NULL }
}

The list of Lua methods for this class.


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