My Project
|
ParaX model is the model file for character animation, etc in the game world. More...
#include <ParaXModel.h>
Public Types | |
enum | RENDER_METHOD { SOFT_ANIM = 0, SHADER_ANIM, NO_ANIM, BMAX_MODEL } |
in what method to render the mesh More... | |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
CParaXModel (const ParaXHeaderDef &xheader) | |
virtual int | GetAttributeClassID () |
attribute class ID should be identical, unless one knows how overriding rules work. More... | |
virtual const char * | GetAttributeClassName () |
a static string, describing the attribute class object's name | |
virtual const char * | GetAttributeClassDescription () |
a static string, describing the attribute class object | |
virtual int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. More... | |
virtual int | GetChildAttributeColumnCount () |
we support multi-dimensional child object. More... | |
virtual IAttributeFields * | GetChildAttributeObject (const std::string &sName) |
get attribute by child object. More... | |
virtual int | GetChildAttributeObjectCount (int nColumnIndex=0) |
get the number of child objects (row count) in the given column. More... | |
virtual IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
ATTRIBUTE_METHOD1 (CParaXModel, DumpTextureUsage_s, const char **) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetPolyCount_s, int *) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetPhysicsCount_s, int *) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetGeosetsCount_s, int *) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetRenderPassesCount_s, int *) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetObjectNum_s, void **) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetVertices_s, void **) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetRenderPasses_s, void **) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetGeosets_s, void **) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetIndices_s, void **) | |
ATTRIBUTE_METHOD1 (CParaXModel, GetAnimations_s, void **) | |
ATTRIBUTE_METHOD1 (CParaXModel, SaveToDisk_s, char *) | |
int | GetPolyCount () |
get polycount of this mesh object | |
int | GetPhysicsCount () |
get physics polycount of this mesh object | |
const char * | DumpTextureUsage () |
get texture usage such as the number of textures and their sizes. More... | |
const ParaXModelObjNum & | GetObjectNum () const |
get the number of objects in the model. More... | |
const ParaXHeaderDef & | GetHeader () const |
bool | CheckMinVersion (int v0, int v1=0, int v2=0, int v3=0) |
check the minimum file version. More... | |
void | initVertices (int nVertices, ModelVertex *pVertices) |
file loading for ParaX file type More... | |
void | initIndices (int nIndices, uint16 *pIndices) |
void | initTranslucentFaceGroups () |
call this function only once after the model data is loaded. More... | |
ModelAttachment & | NewAttachment (bool bOverwrite, int nAttachmentID, int nBoneIndex, const Vector3 &pivotPoint) |
create new attachment | |
bool | IsValid () |
whether this is a valid model | |
bool | InitDeviceObjects () |
TODO: currently this is not implemented. | |
bool | DeleteDeviceObjects () |
TODO: currently this is not implemented. | |
bool | SetupTransformByID (int nID) |
set the transform matrix for the specified attachment ID on this model. More... | |
void | drawModel (SceneState *pSceneState, CParameterBlock *pMaterialParam=NULL, int nRenderMethod=-1) |
void | animate (SceneState *pSceneState, CharacterPose *pPose, IAttributeFields *pAnimInstance=NULL) |
animate the entire model according to the current animation and blending settings. More... | |
void | draw (SceneState *pSceneState, CParameterBlock *materialParams=NULL, int nRenderMethod=-1) |
render the model, according to the current animation states. More... | |
void | BuildShadowVolume (ShadowVolume *pShadowVolume, LightParams *pLight, Matrix4 *mxWorld) |
Build Shadow Volume. | |
void | updateEmitters (SceneState *pSceneState, float dt) |
void | drawBones () |
void | drawBoundingVolume () |
void | calcBones (CharacterPose *pPose, const AnimIndex &CurrentAnim, const AnimIndex &BlendingAnim, float blendingFactor, IAttributeFields *pAnimInstance=NULL) |
calc all Bones in the model with motion blending with a specified blending frame. More... | |
void | calcBones () |
for model without animations, but with bones. More... | |
void | PostCalculateBoneMatrix (uint32 nBones) |
Matrix4 * | GetAttachmentMatrix (Matrix4 *pOut, int nAttachmentID, const AnimIndex &CurrentAnim, const AnimIndex &BlendingAnim, float blendingFactor, bool bRecalcBone=true, IAttributeFields *pAnimInstance=NULL) |
calculate only specified bone in the attachment, all parent bones will also be calculated in order to get the matrix for the specified bone. More... | |
bool | HasAttachmentMatrix (int nAttachmentID) |
whether we have attachment matrix. More... | |
Vector3 | GetWeightedVertexByIndex (unsigned short nIndex) |
void | lightsOn (uint32 lbase) |
void | lightsOff (uint32 lbase) |
bool | HasAnimation () |
return true if the model has animation. More... | |
bool | IsBmaxModel () |
whether it is bmax model with vertex color. More... | |
void | SetBmaxModel () |
void | LoadTextures () |
load textures | |
AnimIndex | GetAnimIndexByID (int nAnimID) |
return the animation index by animation ID. More... | |
int | GetAnimIDByIndex (int nAnimIndex) |
return the ID of the animation at the specified index. More... | |
const ModelAnimation * | GetModelAnimByIndex (int nAnimIndex) |
return NULL if not exist | |
float | GetBoundingRadius () |
get the mesh radius | |
bool | canAttach (int id) |
whether the model has a specified attachment point | |
void | RenderNoAnim (SceneState *pSceneState) |
void | RenderSoftAnim (SceneState *pSceneState, CParameterBlock *pMaterialParams=NULL) |
void | RenderSoftNoAnim (SceneState *pSceneState, CParameterBlock *pMaterialParams=NULL) |
void | RenderShaderAnim (SceneState *pSceneState) |
void | RenderBMaxModel (SceneState *pSceneState, CParameterBlock *pMaterialParams=NULL) |
void | DrawPass (ModelRenderPass &p) |
only called inside Render* function | |
void | DrawPass_NoAnim (ModelRenderPass &p) |
void | DrawPass_NoAnim_VB (ModelRenderPass &p, size_t start) |
void | DrawPass_BMax_VB (ModelRenderPass &p, size_t start) |
void | DrawPass_BMax (ModelRenderPass &p) |
void | ClearFaceGroups () |
clear all face groups. More... | |
bool | HasAlphaBlendedObjects () |
int | GetNextPhysicsGroupID (int nPhysicsGroup=-1) |
return the physics group id that is closest to nPhysicsGroup. More... | |
HRESULT | ClonePhysicsMesh (DWORD *pNumVertices, Vector3 **ppVerts, DWORD *pNumTriangles, DWORD **ppIndices, int *pnMeshPhysicsGroup=NULL, int *pnTotalMeshGroupCount=NULL) |
Get the physics mesh in terms of vertices and indices. More... | |
void | SaveToDisk (const char *path) |
void | SetRenderMethod (RENDER_METHOD method) |
void | SetVertexBufferDirty () |
![]() | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *) | |
ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s) | |
ATTRIBUTE_METHOD (IAttributeFields, AddRef_s) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *) | |
ATTRIBUTE_METHOD (IAttributeFields, Release_s) | |
virtual const std::string & | GetIdentifier () |
virtual void | SetIdentifier (const std::string &sID) |
virtual bool | IsModified () |
whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More... | |
virtual void | SetModified (bool bModified) |
set whether any field has been modified. More... | |
virtual bool | ValidateFields () |
validate all fields and return true if validation passed. More... | |
virtual string | GetValidationMessage () |
get the recent validation message due to the most recent call to ValidateFields() | |
virtual bool | ResetField (int nFieldID) |
Reset the field to its initial or default value. More... | |
virtual bool | InvokeEditor (int nFieldID, const std::string &sParameters) |
Invoke an (external) editor for a given field. More... | |
virtual bool | AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0) |
add child object. More... | |
virtual void * | QueryObjectByName (const std::string &sObjectType) |
convert to object of a given type. More... | |
virtual void * | QueryObject (int nObjectType) |
convert to object of a given type. More... | |
virtual int | GetTime () |
get the current local time in case it is animated in milli seconds frames. More... | |
virtual void | SetTime (int nTime) |
virtual CDynamicAttributeField * | GetDynamicField (const std::string &sName) |
Get a dynamic field with a given name. More... | |
virtual CDynamicAttributeField * | GetDynamicField (int nIndex) |
Get a dynamic field with a given index. More... | |
virtual const char * | GetDynamicFieldNameByIndex (int nIndex) |
get field name by index | |
virtual int | GetDynamicFieldCount () |
how many dynamic field this object currently have. More... | |
virtual int | SetDynamicField (const std::string &sName, const CVariable &value) |
set a dynamic field with a given name. More... | |
virtual int | AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType) |
add dynamic field and return field index | |
virtual void | RemoveAllDynamicFields () |
remove all dynamic fields | |
virtual int | SaveDynamicFieldsToString (std::string &output) |
save only text dynamic fields to fieldname = value text strings. More... | |
virtual int | LoadDynamicFieldsFromString (const std::string &input) |
load only text dynamic fields from string More... | |
CAttributeClass * | GetAttributeClass () |
get the main attribute class object. More... | |
void | PrintObject () |
print the content of this object to a text file at temp/doc/[ClassName].txt. More... | |
![]() | |
virtual void | Clone (IObject *obj) const |
Clone the object's contains to a pointer. More... | |
virtual IObject * | Clone () const |
Clone the object's contains and return a pointer to the newly created object. More... | |
virtual bool | Equals (const IObject *obj) const |
Compare the object with another object. More... | |
virtual const IType * | GetType () const |
virtual std::string | ToString () const |
WeakPtr_type & | GetWeakReference () |
get weak reference object. More... | |
virtual int | ProcessObjectEvent (const ObjectEvent &event) |
this function is only used to backward compatibility of ParaObject:AddEvent() function. More... | |
![]() | |
void | addref () const |
add reference count of the object. More... | |
bool | delref () const |
decrease reference count of the object. More... | |
int | GetRefCount () const |
get the reference count | |
virtual int | Release () |
CRefCounted * | AddToAutoReleasePool () |
addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More... | |
Public Attributes | |
ParaXHeaderDef | m_header |
model header | |
ParaXModelObjNum | m_objNum |
object counts | |
float | m_radius |
bounding radius | |
int | m_nHasAlphaBlendedRenderPass |
-1 uninitialized. More... | |
RENDER_METHOD | m_RenderMethod |
ModelAnimation * | anims |
animation info for the current model | |
ParaVertexBuffer | m_pVertexBuffer |
vertex buffer for skinned vertex | |
ParaIndexBuffer | m_pIndexBuffer |
index buffer | |
size_t | vbufsize |
bool | animated: 1 |
bool | animGeometry: 1 |
bool | animTextures: 1 |
bool | animBones: 1 |
bool | animTexRGB: 1 |
bool | rotatePartice2SpeedVector: 1 |
bool | forceAnim: 1 |
TextureAnim * | texanims |
int * | globalSequences |
ModelColor * | colors |
ModelTransparency * | transparency |
ModelLight * | lights |
ParticleSystem * | particleSystems |
RibbonEmitter * | ribbons |
ModelVertex * | m_origVertices |
int * | m_frame_number_vertices |
this always contains the same number of items as m_origVertices. More... | |
int | m_nCurrentFrameNumber |
Vector3 * | m_vertices |
Vector3 * | m_normals |
Vector2 * | texcoords1 |
uint16 * | m_indices |
Vector3 * | bounds |
uint16 * | boundTris |
ModelCamera | cam |
Bone * | bones |
asset_ptr< TextureEntity > * | textures |
std::vector< ModelRenderPass > | passes |
std::vector< int > | m_TranslucentPassIndice |
it has the same number of element as the passes. More... | |
std::vector< CFaceGroup * > | m_faceGroups |
translucent face groups. More... | |
std::vector< ModelGeoset > | geosets |
bool * | showGeosets |
a list of face group | |
int | specialTextures [MAX_MODEL_TEXTURES] |
TextureEntity * | replaceTextures [MAX_MODEL_TEXTURES] |
bool | useReplaceTextures [MAX_MODEL_TEXTURES] |
AnimIndex | m_CurrentAnim |
current animation index, this is different from sequence ID an absolute ParaX frame number denoting the current animation frame. More... | |
AnimIndex | m_NextAnim |
the next animation index.if it is -1, the next animation will depends on the loop property of the current sequenc; otherwise, the animation specified by the ID will be played next, after the current animation reached the end. More... | |
AnimIndex | m_BlendingAnim |
the animation sequence with which the current animation should be blended. More... | |
float | blendingFactor |
by how much the blending frame should be blended with the current frame. More... | |
float | fBlendingTime |
blending time in seconds | |
bool | m_bIsValid |
bool | hasCamera |
bool | m_bTextureLoaded |
float | m_trans |
std::vector< ModelAttachment > | m_atts |
int | m_attLookup [MAX_MODEL_ATTACHMENTS] |
Vector3 | m_vNeckYawAxis |
default to unitY | |
Vector3 | m_vNeckPitchAxis |
default to unitZ | |
int | m_boneLookup [MAX_KNOWN_BONE_NODE] |
a mapping from known bone id to bone index. More... | |
Static Public Attributes | |
static const int | MAX_MODEL_TEXTURES = 32 |
max number of textures per model | |
static const int | MAX_MODEL_ATTACHMENTS = 40 |
max number of attachment points per model | |
static CEffectFile * | m_pEffectFile = NULL |
The effect file entity used to render the animated model. | |
static VertexDeclarationPtr | m_pVertexDeclaration = NULL |
vertex declaration used in the vertex shader of the effect file | |
Friends | |
struct | ModelRenderPass |
Additional Inherited Members | |
![]() | |
static HRESULT | GetAttributeClassID_s (IAttributeFields *cls, int *p1) |
static HRESULT | GetAttributeClassName_s (IAttributeFields *cls, const char **p1) |
static bool | OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false) |
Open a given file with the default registered editor in the game engine. More... | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
ParaX model is the model file for character animation, etc in the game world.
void CParaXModel::animate | ( | SceneState * | pSceneState, |
CharacterPose * | pPose, | ||
IAttributeFields * | pAnimInstance = NULL |
||
) |
animate the entire model according to the current animation and blending settings.
pPose | it will override the poses defined in the model.: |
void CParaXModel::calcBones | ( | CharacterPose * | pPose, |
const AnimIndex & | CurrentAnim, | ||
const AnimIndex & | BlendingAnim, | ||
float | blendingFactor, | ||
IAttributeFields * | pAnimInstance = NULL |
||
) |
calc all Bones in the model with motion blending with a specified blending frame.
pPose | it will override the poses defined in the model. |
nCurrentAnim | current animation sequence ID |
currentFrame | an absolute ParaX frame number denoting the current animation frame. It is always within the range of the current animation sequence's start and end frame number. |
nBlendingAnim | the animation sequence with which the current animation should be blended. |
blendingFrame | an absolute ParaX frame number denoting the blending animation frame. It is always within the range of the blending animation sequence's start and end frame number. |
blendingFactor | by how much the blending frame should be blended with the current frame. 1.0 will use solely the blending frame, whereas 0.0 will use only the current frame. [0,1), blendingFrame*(blendingFactor)+(1-blendingFactor)*currentFrame |
void CParaXModel::calcBones | ( | ) |
for model without animations, but with bones.
bool CParaXModel::CheckMinVersion | ( | int | v0, |
int | v1 = 0 , |
||
int | v2 = 0 , |
||
int | v3 = 0 |
||
) |
check the minimum file version.
Return true if file version is equal or higher than the given one.
void CParaXModel::ClearFaceGroups | ( | ) |
clear all face groups.
HRESULT CParaXModel::ClonePhysicsMesh | ( | DWORD * | pNumVertices, |
Vector3 ** | ppVerts, | ||
DWORD * | pNumTriangles, | ||
DWORD ** | ppIndices, | ||
int * | pnMeshPhysicsGroup = NULL , |
||
int * | pnTotalMeshGroupCount = NULL |
||
) |
Get the physics mesh in terms of vertices and indices.
pNumVertices | [out] number of vertices |
ppVerts | [out] buffer contains all vertices. The caller needs to release the buffer using delete [] buffer. |
pNumTriangles | [out] number of triangles, each triangle has three indices. Please note that if the mesh contains no physics faces, the pNumTriangles is 0. However pNumVertices might be positive. |
ppIndices | [out] buffer contains all indices. The caller needs to release the buffer using delete [] buffer. |
nMeshPhysicsGroup | [in|out]: the mesh physics group to get. On return it will be assigned with the next mesh group. |
void CParaXModel::draw | ( | SceneState * | pSceneState, |
CParameterBlock * | materialParams = NULL , |
||
int | nRenderMethod = -1 |
||
) |
render the model, according to the current animation states.
make sure to call animate before calling this functions.
assume that the animate() function has already been called to set the bone matrices
void CParaXModel::drawModel | ( | SceneState * | pSceneState, |
CParameterBlock * | pMaterialParam = NULL , |
||
int | nRenderMethod = -1 |
||
) |
apply surface materials
const char * CParaXModel::DumpTextureUsage | ( | ) |
get texture usage such as the number of textures and their sizes.
int CParaXModel::GetAnimIDByIndex | ( | int | nAnimIndex | ) |
return the ID of the animation at the specified index.
if there is no animation at the index, 0 (default animation ID) is returned.
AnimIndex CParaXModel::GetAnimIndexByID | ( | int | nAnimID | ) |
return the animation index by animation ID.
the animation <ID, name> pairs are stored in the AnimDB table. if the animation ID is not found, 0 (usually the stand animation) is returned. a sequential search is used for the specified animation. Below is some common mappings. <0, stand> <1, death> <2, spell> <3, stop> <4, walk> <5, run> : return index of the animation. If the animation is not found, then -1 is returned.
Matrix4 * CParaXModel::GetAttachmentMatrix | ( | Matrix4 * | pOut, |
int | nAttachmentID, | ||
const AnimIndex & | CurrentAnim, | ||
const AnimIndex & | BlendingAnim, | ||
float | blendingFactor, | ||
bool | bRecalcBone = true , |
||
IAttributeFields * | pAnimInstance = NULL |
||
) |
calculate only specified bone in the attachment, all parent bones will also be calculated in order to get the matrix for the specified bone.
pOut | the bone transform matrix. |
nAttachmentID | the bone index. |
bRecalcBone | whether we will recalculate bone chains according to the current animation pose. |
calculate the bone and its parent bones
|
inlinevirtual |
attribute class ID should be identical, unless one knows how overriding rules work.
Reimplemented from ParaEngine::IAttributeFields.
|
virtual |
we support multi-dimensional child object.
by default objects have only one column.
Reimplemented from ParaEngine::IAttributeFields.
|
virtual |
get attribute by child object.
used to iterate across the attribute field hierarchy.
Reimplemented from ParaEngine::IAttributeFields.
|
virtual |
get the number of child objects (row count) in the given column.
please note different columns can have different row count.
Reimplemented from ParaEngine::IAttributeFields.
int CParaXModel::GetNextPhysicsGroupID | ( | int | nPhysicsGroup = -1 | ) |
return the physics group id that is closest to nPhysicsGroup.
or -1 if there is none.
|
inline |
get the number of objects in the model.
|
inline |
nIndex | the index into the global indices. |
bool CParaXModel::HasAnimation | ( | ) |
return true if the model has animation.
bool CParaXModel::HasAttachmentMatrix | ( | int | nAttachmentID | ) |
whether we have attachment matrix.
nAttachmentID | the attachment id. |
void CParaXModel::initTranslucentFaceGroups | ( | ) |
call this function only once after the model data is loaded.
It will search for translucent pass and build face groups to store them for later sorting and rendering.
Set the texture
void CParaXModel::initVertices | ( | int | nVertices, |
ModelVertex * | pVertices | ||
) |
file loading for ParaX file type
read m_origVertices
Create vertex buffer with skinning information
NOT USED: Create vertex buffer with only vertex information
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool CParaXModel::IsBmaxModel | ( | ) |
whether it is bmax model with vertex color.
bool CParaXModel::SetupTransformByID | ( | int | nID | ) |
set the transform matrix for the specified attachment ID on this model.
it is assumed that the transform of this model has already been set in the render device hence it will just multiple over the one in the device. return true, if the nID is a valid attachment point on the model.
float ParaEngine::CParaXModel::blendingFactor |
by how much the blending frame should be blended with the current frame.
1.0 will use solely the blending frame, whereas 0.0 will use only the current frame. [0,1), blendingFrame*(blendingFactor)+(1-blendingFactor)*currentFrame
AnimIndex ParaEngine::CParaXModel::m_BlendingAnim |
the animation sequence with which the current animation should be blended.
an absolute ParaX frame number denoting the blending animation frame. It is always within the range of the blending animation sequence's start and end frame number.
int ParaEngine::CParaXModel::m_boneLookup[MAX_KNOWN_BONE_NODE] |
a mapping from known bone id to bone index.
AnimIndex ParaEngine::CParaXModel::m_CurrentAnim |
current animation index, this is different from sequence ID an absolute ParaX frame number denoting the current animation frame.
It is always within the range of the current animation sequence's start and end frame number.
std::vector<CFaceGroup*> ParaEngine::CParaXModel::m_faceGroups |
translucent face groups.
int* ParaEngine::CParaXModel::m_frame_number_vertices |
this always contains the same number of items as m_origVertices.
it stores the frame number that a certain vertices are used. This avoids the same vertex to be calculated multiple times in a single animation pose.
AnimIndex ParaEngine::CParaXModel::m_NextAnim |
the next animation index.if it is -1, the next animation will depends on the loop property of the current sequenc; otherwise, the animation specified by the ID will be played next, after the current animation reached the end.
int ParaEngine::CParaXModel::m_nHasAlphaBlendedRenderPass |
-1 uninitialized.
0 false, 1 true.
std::vector<int> ParaEngine::CParaXModel::m_TranslucentPassIndice |
it has the same number of element as the passes.
the int value denotes the index into the m_faceGroups