My Project
|
character animation instance: it includes both the animation and model display information. More...
#include <CustomCharModelInstance.h>
Public Types | |
enum | CharSections { SkinType = 0, FaceType = 1, FacialHairType = 2, HairType = 3, UnderwearType = 4 } |
enum | { CHAR_TEX = 0, HAIR_TEX, FUR_TEX, CAPE_TEX, WING_TEX, CARTOON_FACE_TEX, NUM_TEX } |
model resource entity | |
enum | CharGeosets { CSET_HAIR = 0, CSET_FACIAL_HAIR1 = 1, CSET_FACIAL_HAIR2 = 2, CSET_FACIAL_HAIR3 = 3, CSET_GLOVES = 4, CSET_BOOTS = 5, CSET_EARS = 7, CSET_ARM_SLEEVES = 8, CSET_PANTS = 9, CSET_WINGS = 10, CSET_TABARD = 12, CSET_ROBE = 13, CSET_SKIRT = 14, CSET_CAPE = 15, NUM_CHAR_GEOSETS = 16 } |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
CharModelInstance () | |
ATTRIBUTE_DEFINE_CLASS (CharModelInstance) | |
virtual int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. 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 int | GetChildAttributeColumnCount () |
we support multi-dimensional child object. More... | |
virtual IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
void | SetUpperBodyTurningAngle (float fAngle) |
the model will be rendered with the character's upper body turning m_fUpperBodyFacing rads this is done by rotating (-m_fUpperBodyFacing) of the model origin, than rotate the upper body by m_fUpperBodyFacing rads. More... | |
float | GetCurrrentUpperBodyTurningAngle () |
return the angle which will be used for rendering in the next frame. More... | |
void | SetUpperBodyUpdownAngle (float fAngle) |
float | GetCurrrentUpperBodyUpdownAngle () |
return the angle which will be used for rendering in the next frame. More... | |
void | SetSkin (int nIndex=0) |
set the replaceable skin according to the skin database. More... | |
int | GetSkin () |
return the current skin. More... | |
void | SetSkinColorMask (DWORD dwColor) |
the color mask to be applied to cartoon face and ccs base layer. More... | |
DWORD | GetSkinColorMask () |
the color mask to be applied to cartoon face and ccs base layer. More... | |
bool | IsCustomModel () |
check whether this character is customizable. | |
void | SetCharacterSlot (int nSlotID, int nItemID) |
set the model or geoset ID of a specified character slot. More... | |
int | GetCharacterSlot (int nSlotID) |
return the item id at the given slot_id | |
void | SetBodyParams (int skinColor, int faceType, int hairColor, int hairStyle, int facialHair) |
Set the character body parameters. More... | |
int | GetBodyParams (int type) |
void | SetDisplayOptions (int bShowUnderwear, int bShowEars, int bShowHair) |
Set the display options for the character. | |
bool | GetDisplayOptions (int type) |
Get the display option parameters. | |
bool | MapItemTypeToSlot (int nItemType, int &nSlotIndex) |
given an item type, return the slot index to which it should be attached. More... | |
bool | CanItemInSlot (int nItemType, int nSlotIndex) |
whether an item can be inserted in to a certain slot | |
void | SetModifiedModel () |
refresh model resource entities according to the display information | |
void | SetModifiedEquipment () |
refresh all attached items (equipment) | |
void | SetModified () |
set both model and equipment modified. More... | |
void | UpdateBaseModelByEquipment (int slot, int itemnum, int layer, CharTexture &tex) |
update the base model according to a given equipment. More... | |
void | RefreshItem (int slot) |
refresh an item on the canvas More... | |
bool | AnimateModel (SceneState *sceneState, const AnimIndex &CurrentFrame, const AnimIndex &NextAnim, const AnimIndex &BlendingAnim, float blendingFactor, IAttributeFields *pAnimInstance=NULL) |
Animate ParaX model, so that it is ready to be drawn. More... | |
void | Draw (SceneState *sceneState, CParameterBlock *materialParams=NULL) |
draw the model instance. More... | |
void | BuildShadowVolume (SceneState *sceneState, ShadowVolume *pShadowVolume, LightParams *pLight, Matrix4 *mxWorld) |
build the shadow volume, call AnimateModel() before calling this function. More... | |
void | AdvanceTime (float fDeltaTime) |
advance by a delta time | |
bool | InitBaseModel (ParaXEntity *pModel) |
init base model. More... | |
ParaXEntity * | GetBaseModel () |
get the base model for the current character. More... | |
ParaXEntity * | GetAnimModel () |
get the Anim model for the current character. More... | |
void | reset () |
void | CastEffect (int nEffectID, int nAttachmentID=ATT_ID_HAND_LEFT, int nSlotID=-1) |
cast a magic effect by the effect ID. More... | |
void | AddAttachment (ParaXEntity *pModelEntity, int nAttachmentID=ATT_ID_HAND_LEFT, int nSlotID=-1, float fScaling=1.0, TextureEntity *pReplaceableTexture=NULL) |
void | AddAttachment (MeshEntity *pModelEntity, int nAttachmentID=ATT_ID_HAND_LEFT, int nSlotID=-1, float fScaling=1.0, TextureEntity *pReplaceableTexture=NULL) |
IAttributeFields * | GetAttachmentAttObj (int nAttachmentID) |
get attribute fields of the given attachment ID | |
TextureEntity * | GetReplaceableTexture (int ReplaceableTextureID) |
get the current replaceable texture by its ID. More... | |
bool | SetReplaceableTexture (int ReplaceableTextureID, TextureEntity *pTextureEntity) |
set the replaceable texture at the given index with a new texture. More... | |
CartoonFace * | GetCartoonFace (bool bCreateIfNotExist=true) |
get the cartoon face associated with this object. More... | |
bool | IsSupportCartoonFace () |
check whether the associated cartoon model supports cartoon face. More... | |
![]() | |
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 | |
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... | |
Static Public Member Functions | |
static void | ProcessPendingTextures (int nMaxNumber=20) |
Compose pending cartoon faces in a batch. More... | |
static void | AddPendingCartoonFace (CharModelInstance *pendingInstance) |
add an instance to the global list | |
static bool | HasPendingCartoonFace (CharModelInstance *pendingInstance) |
static bool | RemovePendingCartoonFace (CharModelInstance *pendingInstance) |
static void | AddPendingBodyTexture (CharModelInstance *pendingInstance) |
add an instance to the global list | |
static bool | HasPendingBodyTexture (CharModelInstance *pendingInstance) |
static bool | RemovePendingBodyTexture (CharModelInstance *pendingInstance) |
static bool | IsStaticMeshAsset (const std::string &filename) |
return true if filename ends with *.anim.x | |
![]() | |
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... | |
Public Attributes | |
asset_ptr< TextureEntity > | m_textures [NUM_TEX] |
int | geosets [NUM_CHAR_GEOSETS] |
ref_ptr< ParaXModelCanvas > | m_pModelCanvas |
a base model and its attachments. More... | |
int | nSetID |
int | skinColor |
-1 stands for non-standard set | |
int | m_skinIndex |
int | faceType |
int | hairColor |
int | hairStyle |
int | facialHair |
int | race |
int | gender |
bool | m_bIsCustomModel: 1 |
whether this is a customizable model. More... | |
bool | m_bHasCustomGeosets: 1 |
whether the model has geosets that can be toggled. More... | |
bool | showUnderwear |
bool | showEars |
bool | showHair |
bool | showFacialHair:1 |
bool | hadRobe: 1 |
bool | showAriesPantByItem |
bool | showAriesHandByItem |
bool | showAriesFootByItem |
bool | showAriesGlassByItem:1 |
bool | autoHair: 1 |
int | equipment [NUM_CHAR_SLOTS] |
DWORD | m_dwSkinColorMask |
the color mask to be applied to cartoon face and ccs base layer. More... | |
CartoonFace * | m_cartoonFace |
data structure for the cartoon face | |
CharTexture * | m_bodyTexture |
data structure for the body textures | |
std::string | m_sSkinTextureName |
std::string | m_sFaceTextureName |
float | m_fUpperBodyTurningAngle |
load the global characters.db database if it has not been loaded. More... | |
float | m_fUpperBodyUpDownAngle |
Static Public Attributes | |
static std::list< CharModelInstance * > | g_listPendingCartoonFaces |
the cartoon faces that needs to recomposed as soon as possible. More... | |
static std::list< CharModelInstance * > | g_listPendingBodyTextures |
the body textures that needs to recomposed as soon as possible. More... | |
static const size_t | NumItems = 8 |
Additional Inherited Members | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
character animation instance: it includes both the animation and model display information.
CharModelInstance::CharModelInstance | ( | ) |
this model is an automatic character model
void CharModelInstance::AddAttachment | ( | ParaXEntity * | pModelEntity, |
int | nAttachmentID = ATT_ID_HAND_LEFT , |
||
int | nSlotID = -1 , |
||
float | fScaling = 1.0 , |
||
TextureEntity * | pReplaceableTexture = NULL |
||
) |
pModelEntity | the model to be attached. if NULL, the old model at the slot will be removed. |
nAttachmentID | to which part of the character, the effect model is attached. 0 ATT_ID_SHIELD, 1 ATT_ID_HAND_RIGHT, 2 ATT_ID_HAND_LEFT, – default value 5 ATT_ID_SHOULDER_RIGHT, 6 ATT_ID_SHOULDER_LEFT, 11 ATT_ID_HEAD, |
nSlotID | the slot id of the effect. default value is -1. if there is already an effect with the same ID it will be replaced with this new one. |
bool CharModelInstance::AnimateModel | ( | SceneState * | sceneState, |
const AnimIndex & | CurrentFrame, | ||
const AnimIndex & | NextAnim, | ||
const AnimIndex & | BlendingAnim, | ||
float | blendingFactor, | ||
IAttributeFields * | pAnimInstance = NULL |
||
) |
Animate ParaX model, so that it is ready to be drawn.
The animation time (frame number) is set, the visibilities of geoset is set, the model textures are set, and the bone matrices are calculated.
copy the current instance states to ParaX model
void CharModelInstance::BuildShadowVolume | ( | SceneState * | sceneState, |
ShadowVolume * | pShadowVolume, | ||
LightParams * | pLight, | ||
Matrix4 * | mxWorld | ||
) |
build the shadow volume, call AnimateModel() before calling this function.
void CharModelInstance::CastEffect | ( | int | nEffectID, |
int | nAttachmentID = ATT_ID_HAND_LEFT , |
||
int | nSlotID = -1 |
||
) |
cast a magic effect by the effect ID.
nEffectID | effect ID in the effect database if effect id is negative, the effect will be removed from the object. |
nAttachmentID | to which part of the character, the effect model is attached. 0 ATT_ID_SHIELD, 1 ATT_ID_HAND_RIGHT, 2 ATT_ID_HAND_LEFT, – default value 5 ATT_ID_SHOULDER_RIGHT, 6 ATT_ID_SHOULDER_LEFT, 11 ATT_ID_HEAD, |
nSlotID | the slot id of the effect, if there is already an effect with the same ID it will be replaced with this new one. |
void CharModelInstance::Draw | ( | SceneState * | sceneState, |
CParameterBlock * | materialParams = NULL |
||
) |
draw the model instance.
Note: call AnimateModel() before calling this function.
ParaXEntity * CharModelInstance::GetAnimModel | ( | ) |
get the Anim model for the current character.
ParaXEntity * CharModelInstance::GetBaseModel | ( | ) |
get the base model for the current character.
CartoonFace * CharModelInstance::GetCartoonFace | ( | bool | bCreateIfNotExist = true | ) |
get the cartoon face associated with this object.
bCreateIfNotExist | if this is true, a new one will be created if the cartoon is never created before. |
|
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.
float CharModelInstance::GetCurrrentUpperBodyTurningAngle | ( | ) |
return the angle which will be used for rendering in the next frame.
float CharModelInstance::GetCurrrentUpperBodyUpdownAngle | ( | ) |
return the angle which will be used for rendering in the next frame.
TextureEntity * CharModelInstance::GetReplaceableTexture | ( | int | ReplaceableTextureID | ) |
get the current replaceable texture by its ID.
if no replaceable textures is set before, this will return the same result as GetNumReplaceableTextures().
ReplaceableTextureID | usually [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. |
int CharModelInstance::GetSkin | ( | ) |
return the current skin.
DWORD CharModelInstance::GetSkinColorMask | ( | ) |
the color mask to be applied to cartoon face and ccs base layer.
It can be used to fine tune skin color on top of exiting base skin and face textures. Default value is 0xffffffff. setting this to a different value will degrade the performance a little.
bool CharModelInstance::InitBaseModel | ( | ParaXEntity * | pModel | ) |
init base model.
The race and gender are determined by the model name
this is a character model.
Set race and gender of the model.
it is a custom model if and only if the asset file path meets the following criterion [any directory]/[RaceName]/[GenderName]/[RaceName][GenderName].x
get gender
get race
this is not a fully customizable character model.
a custom model is definitely not an automatic character model.
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool CharModelInstance::IsSupportCartoonFace | ( | ) |
check whether the associated cartoon model supports cartoon face.
bool ParaEngine::CharModelInstance::MapItemTypeToSlot | ( | int | nItemType, |
int & | nSlotIndex | ||
) |
given an item type, return the slot index to which it should be attached.
nItemType | the item type |
nSlotIndex | [out] the slot index which will be filled with the slot index upon returning. |
|
static |
Compose pending cartoon faces in a batch.
Possibly after rendering all other objects. It uses the same effect file as the GUI. when this function returns the all pending cartoon faces are cleared from the list even if some are not updated.
nMaxNumber | max number of cartoon faces to be processed in this frame. |
void CharModelInstance::RefreshItem | ( | int | slot | ) |
refresh an item on the canvas
get item's model type and model id by its item id
get the model information from the model display database by the model id
adjust hair visibility
if there is no head attachments, enable hair
void CharModelInstance::SetBodyParams | ( | int | skinColor, |
int | faceType, | ||
int | hairColor, | ||
int | hairStyle, | ||
int | facialHair | ||
) |
Set the character body parameters.
Need to call RefreshModel() after finished with the settings. All body parameters are integer ranging from 0 to maxType, where maxType is the maximum number of types of of a certain body parameter. For each body parameter, one can specify -1 to retain its current value. This is useful, when the caller only wants to change one or several of the body parameters. The default body parameters is (0,0,0,0,0).
void CharModelInstance::SetCharacterSlot | ( | int | nSlotID, |
int | nItemID | ||
) |
set the model or geoset ID of a specified character slot.
nSlotID | |
nItemID | the ID of the item to be put into the character slot. The default value for all slots is 0. One may empty a certain slots by setting its nItemID to 0. |
void CharModelInstance::SetModified | ( | ) |
set both model and equipment modified.
bool CharModelInstance::SetReplaceableTexture | ( | int | ReplaceableTextureID, |
TextureEntity * | pTextureEntity | ||
) |
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.
ReplaceableTextureID | usually [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. |
pTextureEntity | The reference account of the texture entity will be automatically increased by one. |
void CharModelInstance::SetSkin | ( | int | nIndex = 0 | ) |
set the replaceable skin according to the skin database.
this only applies to non-customizable characters.if the index exceeds, it will use the default one. the default skin is at index 0.
nIndex | the skin index. |
void CharModelInstance::SetSkinColorMask | ( | DWORD | dwColor | ) |
the color mask to be applied to cartoon face and ccs base layer.
It can be used to fine tune skin color on top of exiting base skin and face textures. Default value is 0xffffffff. setting this to a different value will degrade the performance a little.
void CharModelInstance::SetUpperBodyTurningAngle | ( | float | fAngle | ) |
the model will be rendered with the character's upper body turning m_fUpperBodyFacing rads this is done by rotating (-m_fUpperBodyFacing) of the model origin, than rotate the upper body by m_fUpperBodyFacing rads.
This will allow the rendered character to be always facing forwards. Note: this is only valid for FULL character with predefined bone structures. TODO: in future version, bone information for body turning will be read from the ParaX file format.
void CharModelInstance::UpdateBaseModelByEquipment | ( | int | slot, |
int | itemnum, | ||
int | layer, | ||
CharTexture & | tex | ||
) |
update the base model according to a given equipment.
equipments on the base model is displayed as textures and visibility of some meshes.
get item's model type and model id by its item id
get the model information from the model display database by the model id
|
static |
the body textures that needs to recomposed as soon as possible.
possibly in a batch.
|
static |
the cartoon faces that needs to recomposed as soon as possible.
possibly in a batch.
bool ParaEngine::CharModelInstance::m_bHasCustomGeosets |
whether the model has geosets that can be toggled.
bool ParaEngine::CharModelInstance::m_bIsCustomModel |
whether this is a customizable model.
As a rule, a customizable model's asset file is stored in a directory called "Character".
DWORD ParaEngine::CharModelInstance::m_dwSkinColorMask |
the color mask to be applied to cartoon face and ccs base layer.
It can be used to fine tune skin color on top of exiting base skin and face textures. Default value is 0xffffffff. setting this to a different value will degrade the performance a little.
float ParaEngine::CharModelInstance::m_fUpperBodyTurningAngle |
load the global characters.db database if it has not been loaded.
return the character database entity
ref_ptr<ParaXModelCanvas> ParaEngine::CharModelInstance::m_pModelCanvas |
a base model and its attachments.