My Project
Public Member Functions | Protected Attributes | List of all members
ParaEngine::XRefObject Class Reference

base class for all xref objects More...

#include <XRefObject.h>

Inheritance diagram for ParaEngine::XRefObject:
ParaEngine::XRefAnimInstance ParaEngine::XRefMeshObject

Public Member Functions

 XRefObject (CMeshObject *pParent, AssetEntity *pModel, const Vector3 &vOrigin, const Matrix4 &mxLocalTransform)
 
CMeshObjectGetParent ()
 Get the parent object associated with this object.
 
AssetEntityGetModelAsset ()
 return the model asset associated with this object
 
virtual bool SetParamsFromAsset ()
 return true if asset effect type is known. More...
 
virtual void Animate (double dTimeDelta, int nRenderNumber=0)
 animate the model
 
virtual HRESULT Draw (SceneState *sceneState)
 draw the model
 
virtual HRESULT DrawInner (SceneState *sceneState, const Matrix4 *pMxWorld=0, float fCameraToObjectDist=0.f)
 
virtual bool SetReplaceableTexture (int ReplaceableTextureID, TextureEntity *pTextureEntity)
 set the replaceable texture at the given index with a new texture. More...
 
Matrix4GetRenderMatrix (Matrix4 &mxWorld, const Matrix4 *pMxParent=NULL, int nRenderNumber=0)
 get matrix for rendering More...
 
virtual Matrix4GetAttachmentMatrix (Matrix4 &pOut, int nAttachmentID=0, int nRenderNumber=0)
 Get the specified attachment matrix of the current model. More...
 
virtual void SetAnimation (int nAnimID)
 Set the current animation id. More...
 
virtual int GetAnimation ()
 get the scaling. More...
 
virtual void SetAnimFrame (int nFrame)
 set the current animation frame number relative to the beginning of current animation. More...
 
virtual int GetAnimFrame ()
 get the current animation frame number relative to the beginning of current animation. More...
 
virtual void SetUseGlobalTime (bool bUseGlobalTime)
 whether to use global time to sync animation. More...
 
virtual bool IsUseGlobalTime ()
 whether to use global time to sync animation. More...
 
Matrix4GetLocalMatrix ()
 get local matrix
 
Matrix4GetMatrix (Matrix4 &mxWorld, const Matrix4 *pMatParent)
 get matrix relative to a parent matrix
 
virtual int GetPrimaryTechniqueHandle ()
 when batch-rendering a group of objects, objects are usually sorted by their render techniques and then by their primary asset. More...
 
virtual void SetPrimaryTechniqueHandle (int nHandle)
 Set a new render technique handle. More...
 

Protected Attributes

asset_ptr< AssetEntitym_pModelEntity
 
Vector3 m_vOrigin
 the xrefed model's origin relative to its parent model. More...
 
Matrix4 m_mxLocalTransform
 animated local transform: this is usually a const read from the model file
 
int m_nTechniqueHandle
 the primary technique handle
 
CMeshObjectm_pParent
 parent object
 

Detailed Description

base class for all xref objects

Member Function Documentation

§ GetAnimation()

virtual int ParaEngine::XRefObject::GetAnimation ( )
inlinevirtual

get the scaling.

Reimplemented in ParaEngine::XRefAnimInstance.

§ GetAnimFrame()

virtual int ParaEngine::XRefObject::GetAnimFrame ( )
inlinevirtual

get the current animation frame number relative to the beginning of current animation.

Reimplemented in ParaEngine::XRefAnimInstance.

§ GetAttachmentMatrix()

virtual Matrix4* ParaEngine::XRefObject::GetAttachmentMatrix ( Matrix4 pOut,
int  nAttachmentID = 0,
int  nRenderNumber = 0 
)
inlinevirtual

Get the specified attachment matrix of the current model.

this is usually for getting the mount point on a certain model, such as horses. It also works for static mesh with xrefed mountable objects.

Parameters
pOutoutput result
nAttachmentIDsee ATTACHMENT_ID. default to 0, which is general mount point. ATT_ID_MOUNT1-9(20-28) is another mount points
nRenderNumberif it is bigger than current calculated render number, the value will be recalculated. If 0, it will not recalculate
Returns
: NULL if not attachment found, otherwise it is pOut.

Reimplemented in ParaEngine::XRefAnimInstance.

§ GetPrimaryTechniqueHandle()

virtual int ParaEngine::XRefObject::GetPrimaryTechniqueHandle ( )
inlinevirtual

when batch-rendering a group of objects, objects are usually sorted by their render techniques and then by their primary asset.

One can access the effect file currently associated with the handle in the asset manager. Please note that, the game engine may change the mapping from technique handle to the effect file, secretly at runtime. Effect files capable to be assigned to the same technique handle must also share the same (vertex) input declaration in order to be swapped secretly at runtime. Note: the Draw() function of object will dynamically retrieve the effect file for each call. If the effect file is not valid, it will try to render using directx 9's fixed programming pipeline.

See also
TechniqueHandle

§ GetRenderMatrix()

Matrix4 * ParaEngine::XRefObject::GetRenderMatrix ( Matrix4 mxWorld,
const Matrix4 pMxParent = NULL,
int  nRenderNumber = 0 
)

get matrix for rendering

Parameters
mxWorldout
pMxParentin, if NULL, parent render world matrix is used.
nRenderNumberif it is bigger than current calculated render number, the value will be recalculated. If 0, it will not recalculate

§ IsUseGlobalTime()

virtual bool ParaEngine::XRefObject::IsUseGlobalTime ( )
inlinevirtual

whether to use global time to sync animation.

Default to false. if true, all characters plays exactly the same frames if they are using the same animation file at all times, if false, each character advances its time frame separately according to their visibility in the scene.

Note
: animation is always looped once use global time

Reimplemented in ParaEngine::XRefAnimInstance.

§ SetAnimation()

virtual void ParaEngine::XRefObject::SetAnimation ( int  nAnimID)
inlinevirtual

Set the current animation id.

Parameters
nAnimID0 is default standing animation. 4 is walking, 5 is running. more information, please see AnimationID

Reimplemented in ParaEngine::XRefAnimInstance.

§ SetAnimFrame()

virtual void ParaEngine::XRefObject::SetAnimFrame ( int  nFrame)
inlinevirtual

set the current animation frame number relative to the beginning of current animation.

Parameters
nFrame0 means beginning. if nFrame is longer than the current animation length, it will wrap (modulate the length).

Reimplemented in ParaEngine::XRefAnimInstance.

§ SetParamsFromAsset()

bool ParaEngine::XRefObject::SetParamsFromAsset ( )
virtual

return true if asset effect type is known.

and false in case the asset is not loaded yet.

Reimplemented in ParaEngine::XRefAnimInstance, and ParaEngine::XRefMeshObject.

§ SetPrimaryTechniqueHandle()

virtual void ParaEngine::XRefObject::SetPrimaryTechniqueHandle ( int  nHandle)
inlinevirtual

Set a new render technique handle.

If the effect file associated with the handle is invalid or do not share the same input declaration as the object at the time of drawing, the object will not be drawn or will be drawn improperly. This function rarely needs to be called by users. Technique handles are usually automatically assigned by the game engine when the asset file is loaded. Of course, users can use special effect files for the rendering of special objects; then this function needs to be called.

Parameters
nHandle
See also
TechniqueHandle

§ SetReplaceableTexture()

virtual bool ParaEngine::XRefObject::SetReplaceableTexture ( int  ReplaceableTextureID,
TextureEntity pTextureEntity 
)
inlinevirtual

set the replaceable texture at the given index with a new texture.

this function will succeed regardless whether the mesh is initialized. Hence it can be used at loading time. because default instance of the mesh may use different replaceable texture set.

Parameters
ReplaceableTextureIDusually [0-32) generally speaking, replaceable ID 0 is used for general purpose replaceable texture, ID 1 is for user defined. ID 2 is for custom skins.
pTextureEntityThe reference account of the texture entity will be automatically increased by one.
Returns
true if succeed. if ReplaceableTextureID exceed the total number of replaceable textures, this function will return false.

Reimplemented in ParaEngine::XRefAnimInstance, and ParaEngine::XRefMeshObject.

§ SetUseGlobalTime()

virtual void ParaEngine::XRefObject::SetUseGlobalTime ( bool  bUseGlobalTime)
inlinevirtual

whether to use global time to sync animation.

Default to false. if true, all characters plays exactly the same frames if they are using the same animation file at all times, if false, each character advances its time frame separately according to their visibility in the scene.

Note
: animation is always looped once use global time

Reimplemented in ParaEngine::XRefAnimInstance.

Member Data Documentation

§ m_vOrigin

Vector3 ParaEngine::XRefObject::m_vOrigin
protected

the xrefed model's origin relative to its parent model.

this is usually a const read from the model file


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