Drag[en]gine Game Engine  1.0
deComponent Class Reference

Component Resource. A component resource is the most important element after the world itself. This object ties together various other objects to form a renderable object. A world component requires at least a model object and a skin object to be set. The textures in the model are then mapped to the skin textures used for rendering. In addition a rig and an animation object can be set. If the rig is set the bones of the rig are considere the component bones. The bones of the model are mapped to the rig bones for vertex weighting. If an animation object is set too the bones of the animation object are mapped to the rig bones too for retrieving the correct bone states. The following mapping table shows those relations. More...

#include <deComponent.h>

Inheritance diagram for deComponent:
deResource deObject

Public Member Functions

Management
const decDVectorGetPosition () const
 
void SetPosition (const decDVector &pos)
 
const decQuaternionGetOrientation () const
 
void SetOrientation (const decQuaternion &orientation)
 
const decVectorGetScaling () const
 
void SetScaling (const decVector &scale)
 
deModelGetModel () const
 
void SetModel (deModel *model)
 Set model or NULL if not set. More...
 
void SetModelKeepTextures (deModel *model)
 Set model or null if not set while keeping textures. More...
 
deSkinGetSkin () const
 
void SetSkin (deSkin *skin)
 
deRigGetRig () const
 
void SetRig (deRig *rig)
 
void SetModelAndSkin (deModel *model, deSkin *skin)
 
deOcclusionMeshGetOcclusionMesh () const
 
void SetOcclusionMesh (deOcclusionMesh *occmesh)
 
bool GetVisible () const
 
void SetVisible (bool visible)
 
bool GetCastShadows () const
 
void SetCastShadows (bool castShadows)
 
bool GetStatic () const
 
void SetStatic (bool bStatic)
 
int GetImportance () const
 
void SetImportance (int importance)
 
const decDVectorGetMinimumExtend ()
 
const decDVectorGetMaximumExtend ()
 
const decDMatrixGetMatrix ()
 
const decDMatrixGetInverseMatrix ()
 
void SetClosestExtends ()
 
int GetWeightsCount () const
 
int GetBoneCount () const
 
int GetVertexCount () const
 
int GetNormalCount () const
 
int GetFaceCount () const
 
deComponentBoneGetBone (int index) const
 
void UpdateBoneAt (int index)
 
const decMatrixGetWeights (int index) const
 
const decVectorGetVertex (int index) const
 
const decVectorGetNormal (int index) const
 
const decVectorGetFaceNormal (int index) const
 
decVector GetFaceCenter (int index) const
 
void InvalidateBones ()
 
void ValidateBones ()
 
void InvalidateMesh ()
 
void InvalidateExtends ()
 
void CopyBonesToComponent (deComponent &component)
 Copy bone states to matching bones states of another component. More...
 
deDynamicSkinGetDynamicSkin () const
 
void SetDynamicSkin (deDynamicSkin *dynamicSkin)
 
deAnimatorGetAnimator () const
 
void SetAnimator (deAnimator *animator)
 
decLayerMaskGetLayerMask ()
 
const decLayerMaskGetLayerMask () const
 
void NotifyLayerMaskChanged ()
 
const decStringGetGroupEnvMap () const
 
void SetGroupEnvMap (const char *name)
 
bool MatchesModelSkin () const
 
int GetModelRigMappingCount () const
 
int GetModelRigMapping (int boneIndex) const
 
bool MatchesModelRig () const
 
void PrepareExtends ()
 
void PrepareMatrix ()
 
void PrepareBones ()
 
void PrepareBoneWeights ()
 
void PrepareWeights ()
 
void PrepareMesh ()
 
Animator Tasks
deParallelTaskGetAnimatorTask () const
 Animator task or NULL if none is pending affecting this component. More...
 
void SetAnimatorTask (deParallelTask *task)
 Set animator task or NULL if none is pending affecting this component. More...
 
Textures
int GetTextureCount () const
 
deComponentTextureGetTextureAt (int index) const
 
int IndexOfTextureClosestTo (const decVector &position, float radius) const
 Retrieve index of the texture of the face closest to a position or -1 if not found. More...
 
void NotifyTextureChanged (int index) const
 
Decals Management
int GetDecalCount () const
 
deDecalGetDecalAt (int index) const
 
int IndexOfDecal (deDecal *decal) const
 
void AddDecal (deDecal *decal)
 
void RemoveDecal (deDecal *decal)
 
void RemoveAllDecals ()
 
Collision Detection
void FindDecalsAt (const decVector &point, deDecalList *list) const
 
void FindDecalsTouching (decShape *shape, deDecalList *list) const
 
System Peers
deBaseGraphicComponentGetGraphicComponent () const
 
void SetGraphicComponent (deBaseGraphicComponent *comp)
 
deBasePhysicsComponentGetPhysicsComponent () const
 
void SetPhysicsComponent (deBasePhysicsComponent *comp)
 
deBaseAudioComponentGetAudioComponent () const
 
void SetAudioComponent (deBaseAudioComponent *audComp)
 
deBaseAnimatorComponentGetPeerAnimator () const
 Animator peer or NULL if not set. More...
 
void SetPeerAnimator (deBaseAnimatorComponent *peer)
 Set animator peer or NULL if not set. More...
 
Linked List
deWorldGetParentWorld () const
 Parent world or NULL. More...
 
void SetParentWorld (deWorld *world)
 Set parent world or NULL. More...
 
deComponentGetLLWorldPrev () const
 Previous component in the parent world linked list. More...
 
void SetLLWorldPrev (deComponent *component)
 Set next component in the parent world linked list. More...
 
deComponentGetLLWorldNext () const
 Next component in the parent world linked list. More...
 
void SetLLWorldNext (deComponent *component)
 Set next component in the parent world linked list. More...
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
 
deEngineGetEngine () const
 Game engine object from resource manager. More...
 
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
 
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
 
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
void MarkLeaking ()
 Marks the resource leaking. More...
 
 deResource (deResourceManager *resourceManager)
 Create resource. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 

Constructors and Destructors

 deComponent (deComponentManager *manager, deModel *model, deSkin *skin)
 
virtual ~deComponent ()
 Clean up component. More...
 

Additional Inherited Members

- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

Detailed Description

Component Resource. A component resource is the most important element after the world itself. This object ties together various other objects to form a renderable object. A world component requires at least a model object and a skin object to be set. The textures in the model are then mapped to the skin textures used for rendering. In addition a rig and an animation object can be set. If the rig is set the bones of the rig are considere the component bones. The bones of the model are mapped to the rig bones for vertex weighting. If an animation object is set too the bones of the animation object are mapped to the rig bones too for retrieving the correct bone states. The following mapping table shows those relations.

  • Model Textures mapped to Skin Textures
  • Model Bones mapped to Rig Bones
  • Animation Bones mapped to Rig Bones

The rig bones are the component bones. All bone indices are range checked against rig bones.

Peering
The world component has the most peers of all resource objects due to its importance. The graphic, physics and scripting system do have all their peer objects attached to the world component. It is mandatory for modules of those system to provide such a peer for the system to work.
Optimizations
As the world component is a rather large object and links together a lot of data care has to be taken to not slow down the engine. For this purpose most calculations are of a lazy nature. Those calculations are only carried out if a state changed that invalidates the state in question. This way states should be only calcuated once per frame update in the worst case. Care has to be taken not to cause multiple updates per frame update due to interleaving retrieve functions with state changing functions. The state stored in this component is geared towards easy usability not fast speed. It is hence encouraged for the modules of the peering systems to do the calculations needed on their own to gain the best speed. Notifications are provided to informa peering systems about important state changes.
Important Notice
This class is currently in a heavy change which is why documenting it is posponed until the changes are done.
Hints
Various hints help the modules in the engine to handle this component in the best way. The static property defines if a component does not alter geometry (position, orientation, scaling, model, rig or bones) after it has been put into the correct place before the containing world is rendered the next time. Typically components representing geological formations or architectural structures supposed to be static throughout the game. The static hint can be changed while during the game for example if a wall that has been once static is supposed to crumble down. The static hint should though not be changed often if required. By default all components are not static.
Todo:
  • Remove weighting system as it goes into graphic module
  • Remove face normals as the graphic module already calculates them separatly and physics uses anyways their collision models
  • Do doxy-documentation
Author
Pl├╝ss Roland
Version
1.0
Date
2008

Constructor & Destructor Documentation

◆ deComponent()

deComponent::deComponent ( deComponentManager manager,
deModel model,
deSkin skin 
)

Creates a new component.

◆ ~deComponent()

virtual deComponent::~deComponent ( )
protectedvirtual

Clean up component.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ AddDecal()

void deComponent::AddDecal ( deDecal decal)

Adds a decal to the world.

Referenced by GetDecalCount().

◆ CopyBonesToComponent()

void deComponent::CopyBonesToComponent ( deComponent component)

Copy bone states to matching bones states of another component.

Referenced by GetFaceCount().

◆ FindDecalsAt()

void deComponent::FindDecalsAt ( const decVector point,
deDecalList list 
) const

Stores all decals in contact with the given surface point into the provided list. The point is best taken from an earlier collision test and is in world coordinates. The point is considered to be in the same sector as the component.

Parameters
pointPoint on the surface to test.
listList of decals to fill in. Not emptied before filling.

Referenced by GetDecalCount().

◆ FindDecalsTouching()

void deComponent::FindDecalsTouching ( decShape shape,
deDecalList list 
) const

Stores all decals in contact with the given shape into the provided list. The shape is considered to be in the same sector as the component.

Parameters
shapeShape to test.
listList of decals to fill in. Not emptied before filling.

Referenced by GetDecalCount().

◆ GetAnimator()

deAnimator* deComponent::GetAnimator ( ) const
inline

Retrieves the render only animator or NULL to use none.

References SetAnimator().

◆ GetAnimatorTask()

deParallelTask* deComponent::GetAnimatorTask ( ) const
inline

Animator task or NULL if none is pending affecting this component.

Animator tasks can be created by Animator Modules to calculate bone states in parallel. Multiple animator tasks can affect a component but only the last one is stored in the component itself. If a task exists and PrepareBones() is called (or a function using it) the animator task is waited on to finish before continueing. Only Animator Modules use this function.

References SetAnimatorTask().

◆ GetAudioComponent()

deBaseAudioComponent* deComponent::GetAudioComponent ( ) const
inline

References SetAudioComponent().

◆ GetBone()

deComponentBone* deComponent::GetBone ( int  index) const

Referenced by GetFaceCount().

◆ GetBoneCount()

int deComponent::GetBoneCount ( ) const
inline

◆ GetCastShadows()

bool deComponent::GetCastShadows ( ) const
inline

Determines if the component casts shadows.

References SetCastShadows().

◆ GetDecalAt()

deDecal* deComponent::GetDecalAt ( int  index) const

Retrieves the decal at the given index.

Referenced by GetDecalCount().

◆ GetDecalCount()

int deComponent::GetDecalCount ( ) const
inline

◆ GetDynamicSkin()

deDynamicSkin* deComponent::GetDynamicSkin ( ) const
inline

Retrieves the dynamic skin or null if not used.

References SetDynamicSkin().

◆ GetFaceCenter()

decVector deComponent::GetFaceCenter ( int  index) const

Referenced by GetFaceCount().

◆ GetFaceCount()

◆ GetFaceNormal()

const decVector& deComponent::GetFaceNormal ( int  index) const

Referenced by GetFaceCount().

◆ GetGraphicComponent()

deBaseGraphicComponent* deComponent::GetGraphicComponent ( ) const
inline

References SetGraphicComponent().

◆ GetGroupEnvMap()

const decString& deComponent::GetGroupEnvMap ( ) const
inline

Retrieves the environment map group name or an empty string if not set.

References MatchesModelSkin(), and SetGroupEnvMap().

◆ GetImportance()

int deComponent::GetImportance ( ) const
inline

◆ GetInverseMatrix()

const decDMatrix& deComponent::GetInverseMatrix ( )

Referenced by GetImportance().

◆ GetLayerMask() [1/2]

decLayerMask& deComponent::GetLayerMask ( )
inline

Retrieves the layer mask. Call NotifyLayerMaskChanged afterwards.

◆ GetLayerMask() [2/2]

const decLayerMask& deComponent::GetLayerMask ( ) const
inline

◆ GetLLWorldNext()

deComponent* deComponent::GetLLWorldNext ( ) const
inline

Next component in the parent world linked list.

References SetLLWorldNext().

◆ GetLLWorldPrev()

deComponent* deComponent::GetLLWorldPrev ( ) const
inline

Previous component in the parent world linked list.

References SetLLWorldPrev().

◆ GetMatrix()

const decDMatrix& deComponent::GetMatrix ( )

Referenced by GetImportance().

◆ GetMaximumExtend()

const decDVector& deComponent::GetMaximumExtend ( )

Referenced by GetImportance().

◆ GetMinimumExtend()

const decDVector& deComponent::GetMinimumExtend ( )

Referenced by GetImportance().

◆ GetModel()

deModel* deComponent::GetModel ( ) const
inline

Retrieves the model or NULL if not assigned.

References SetModel(), and SetModelKeepTextures().

◆ GetModelRigMapping()

int deComponent::GetModelRigMapping ( int  boneIndex) const

Referenced by GetModelRigMappingCount().

◆ GetModelRigMappingCount()

int deComponent::GetModelRigMappingCount ( ) const
inline

◆ GetNormal()

const decVector& deComponent::GetNormal ( int  index) const

Referenced by GetFaceCount().

◆ GetNormalCount()

int deComponent::GetNormalCount ( ) const
inline

◆ GetOcclusionMesh()

deOcclusionMesh* deComponent::GetOcclusionMesh ( ) const
inline

Retrieves the occlusion mesh or NULL if not assigned.

References SetOcclusionMesh().

◆ GetOrientation()

const decQuaternion& deComponent::GetOrientation ( ) const
inline

Retrieves the orientation.

References SetOrientation().

◆ GetParentWorld()

deWorld* deComponent::GetParentWorld ( ) const
inline

Parent world or NULL.

References SetParentWorld().

◆ GetPeerAnimator()

deBaseAnimatorComponent* deComponent::GetPeerAnimator ( ) const
inline

Animator peer or NULL if not set.

References SetPeerAnimator().

◆ GetPhysicsComponent()

deBasePhysicsComponent* deComponent::GetPhysicsComponent ( ) const
inline

References SetPhysicsComponent().

◆ GetPosition()

const decDVector& deComponent::GetPosition ( ) const
inline

Retrieves the position.

References SetPosition().

◆ GetRig()

deRig* deComponent::GetRig ( ) const
inline

Retrieves the rig or NULL if not assigned.

References SetModelAndSkin(), and SetRig().

◆ GetScaling()

const decVector& deComponent::GetScaling ( ) const
inline

Retrieves the scaling.

References SetScaling().

◆ GetSkin()

deSkin* deComponent::GetSkin ( ) const
inline

Retrieves the skin or NULL if not assigned.

References SetSkin().

◆ GetStatic()

bool deComponent::GetStatic ( ) const
inline

Determines if the component is static.

References SetStatic().

◆ GetTextureAt()

deComponentTexture& deComponent::GetTextureAt ( int  index) const

Retrieves the texture with the given index.

Referenced by GetTextureCount().

◆ GetTextureCount()

int deComponent::GetTextureCount ( ) const
inline

Retrieves the number of textures.

References GetTextureAt(), IndexOfTextureClosestTo(), and NotifyTextureChanged().

◆ GetVertex()

const decVector& deComponent::GetVertex ( int  index) const

Referenced by GetFaceCount().

◆ GetVertexCount()

int deComponent::GetVertexCount ( ) const
inline

◆ GetVisible()

bool deComponent::GetVisible ( ) const
inline

Determines if the component is visible.

References SetVisible().

◆ GetWeights()

const decMatrix& deComponent::GetWeights ( int  index) const

Referenced by GetFaceCount().

◆ GetWeightsCount()

int deComponent::GetWeightsCount ( ) const
inline

◆ IndexOfDecal()

int deComponent::IndexOfDecal ( deDecal decal) const

Retrieves the index of the given decal of -1 if not found.

Referenced by GetDecalCount().

◆ IndexOfTextureClosestTo()

int deComponent::IndexOfTextureClosestTo ( const decVector position,
float  radius 
) const

Retrieve index of the texture of the face closest to a position or -1 if not found.

Referenced by GetTextureCount().

◆ InvalidateBones()

void deComponent::InvalidateBones ( )

Marks bones dirty. Mesh, weights and extends are set dirty too and the appropriate notifiers are called if required.

Referenced by GetFaceCount().

◆ InvalidateExtends()

void deComponent::InvalidateExtends ( )

Marks the extends dirty.

Referenced by GetFaceCount().

◆ InvalidateMesh()

void deComponent::InvalidateMesh ( )

Marks the mesh dirty.

Referenced by GetFaceCount().

◆ MatchesModelRig()

bool deComponent::MatchesModelRig ( ) const

Referenced by GetModelRigMappingCount().

◆ MatchesModelSkin()

bool deComponent::MatchesModelSkin ( ) const

Referenced by GetGroupEnvMap().

◆ NotifyLayerMaskChanged()

void deComponent::NotifyLayerMaskChanged ( )

Notifies the peers that the layer mask changed.

Referenced by GetLayerMask().

◆ NotifyTextureChanged()

void deComponent::NotifyTextureChanged ( int  index) const

Notifies the peers that a texture changed.

Referenced by GetTextureCount().

◆ PrepareBones()

void deComponent::PrepareBones ( )

Referenced by GetModelRigMappingCount().

◆ PrepareBoneWeights()

void deComponent::PrepareBoneWeights ( )

Referenced by GetModelRigMappingCount().

◆ PrepareExtends()

void deComponent::PrepareExtends ( )

Referenced by GetModelRigMappingCount().

◆ PrepareMatrix()

void deComponent::PrepareMatrix ( )

Referenced by GetModelRigMappingCount().

◆ PrepareMesh()

void deComponent::PrepareMesh ( )

Referenced by GetModelRigMappingCount().

◆ PrepareWeights()

void deComponent::PrepareWeights ( )

Referenced by GetModelRigMappingCount().

◆ RemoveAllDecals()

void deComponent::RemoveAllDecals ( )

Removes all decals from the world.

Referenced by GetDecalCount().

◆ RemoveDecal()

void deComponent::RemoveDecal ( deDecal decal)

Removes the given decal from the world.

Referenced by GetDecalCount().

◆ SetAnimator()

void deComponent::SetAnimator ( deAnimator animator)

Sets the render only animator or NULL to use none.

Referenced by GetAnimator().

◆ SetAnimatorTask()

void deComponent::SetAnimatorTask ( deParallelTask task)

Set animator task or NULL if none is pending affecting this component.

Animator tasks can be created by Animator Modules to calculate bone states in parallel. Multiple animator tasks can affect a component but only the last one is stored in the component itself. If a task exists and PrepareBones() is called (or a function using it) the animator task is waited on to finish before continueing. Only Animator Modules use this function.

Referenced by GetAnimatorTask().

◆ SetAudioComponent()

void deComponent::SetAudioComponent ( deBaseAudioComponent audComp)

Referenced by GetAudioComponent().

◆ SetCastShadows()

void deComponent::SetCastShadows ( bool  castShadows)

Sets if the component casts shadows.

Referenced by GetCastShadows().

◆ SetClosestExtends()

void deComponent::SetClosestExtends ( )

Referenced by GetImportance().

◆ SetDynamicSkin()

void deComponent::SetDynamicSkin ( deDynamicSkin dynamicSkin)

Sets the dynamic skin or null if not used.

Referenced by GetDynamicSkin().

◆ SetGraphicComponent()

void deComponent::SetGraphicComponent ( deBaseGraphicComponent comp)

Referenced by GetGraphicComponent().

◆ SetGroupEnvMap()

void deComponent::SetGroupEnvMap ( const char *  name)

Sets the environment map group name or an empty string if not set.

Referenced by GetGroupEnvMap().

◆ SetImportance()

void deComponent::SetImportance ( int  importance)

Referenced by GetImportance().

◆ SetLLWorldNext()

void deComponent::SetLLWorldNext ( deComponent component)

Set next component in the parent world linked list.

Referenced by GetLLWorldNext().

◆ SetLLWorldPrev()

void deComponent::SetLLWorldPrev ( deComponent component)

Set next component in the parent world linked list.

Referenced by GetLLWorldPrev().

◆ SetModel()

void deComponent::SetModel ( deModel model)

Set model or NULL if not set.

Textures are reset. To keep textures use setModelKeepTextures.

Referenced by GetModel().

◆ SetModelAndSkin()

void deComponent::SetModelAndSkin ( deModel model,
deSkin skin 
)

Sets the model and skin at the same time. Either one can be NULL.

Referenced by GetRig().

◆ SetModelKeepTextures()

void deComponent::SetModelKeepTextures ( deModel model)

Set model or null if not set while keeping textures.

Restores current state of textures after switching model if possible. Use this method instead of setModel if you set textures on the component and the new model is similar enough to match. Textures not existing anymore are not restored.

Referenced by GetModel().

◆ SetOcclusionMesh()

void deComponent::SetOcclusionMesh ( deOcclusionMesh occmesh)

Sets the occlusion mesh or NULL if not assigned.

Referenced by GetOcclusionMesh().

◆ SetOrientation()

void deComponent::SetOrientation ( const decQuaternion orientation)

Sets the orientation.

Referenced by GetOrientation().

◆ SetParentWorld()

void deComponent::SetParentWorld ( deWorld world)

Set parent world or NULL.

Referenced by GetParentWorld().

◆ SetPeerAnimator()

void deComponent::SetPeerAnimator ( deBaseAnimatorComponent peer)

Set animator peer or NULL if not set.

Referenced by GetPeerAnimator().

◆ SetPhysicsComponent()

void deComponent::SetPhysicsComponent ( deBasePhysicsComponent comp)

Referenced by GetPhysicsComponent().

◆ SetPosition()

void deComponent::SetPosition ( const decDVector pos)

Sets the position.

Referenced by GetPosition().

◆ SetRig()

void deComponent::SetRig ( deRig rig)

Sets the rig or NULL if not assigned.

Referenced by GetRig().

◆ SetScaling()

void deComponent::SetScaling ( const decVector scale)

Sets the scaling.

Referenced by GetScaling().

◆ SetSkin()

void deComponent::SetSkin ( deSkin skin)

Sets the skin or NULL if not assigned.

Referenced by GetSkin().

◆ SetStatic()

void deComponent::SetStatic ( bool  bStatic)

Sets if the component is static.

Referenced by GetStatic().

◆ SetVisible()

void deComponent::SetVisible ( bool  visible)

Sets if the component is visible.

Referenced by GetVisible().

◆ UpdateBoneAt()

void deComponent::UpdateBoneAt ( int  index)

Updates the given bone.

Referenced by GetFaceCount().

◆ ValidateBones()

void deComponent::ValidateBones ( )

Marks bones no more dirty. No other action is carried out except setting the dirty flag for bones. Use this function if you updated all bones on your own ( typically physics modules during simulation ). The mesh, weight and extends dirty flag keep their values. You have to call the InvalidateMesh function after validating bones to ensure they are updated correctly during the next update step.

Referenced by GetFaceCount().


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