My Project
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
ParaEngine::Bone Class Reference

a single animated bone, it contains both the bone instance data and all animation data of the bone. More...

#include <ParaXBone.h>

Inheritance diagram for ParaEngine::Bone:
ParaEngine::IAttributeFields ParaEngine::IObject ParaEngine::CRefCounted

Public Types

enum  BONE_FLAGS {
  BONE_USE_PIVOT = 0, BONE_BILLBOARDED = (0x1 << 3), BONE_OFFSET_MATRIX = (0x1 << 4), BONE_STATIC_TRANSFORM = (0x1 << 5),
  BONE_TRANSFORMATION_NODE = (0x1 << 6)
}
 
- Public Types inherited from ParaEngine::IAttributeFields
typedef ParaEngine::weak_ptr< IObject, IAttributeFieldsWeakPtr_type
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 

Public Member Functions

 ATTRIBUTE_DEFINE_CLASS (Bone)
 
virtual int InstallFields (CAttributeClass *pClass, bool bOverride)
 this class should be implemented if one wants to add new attribute. More...
 
 ATTRIBUTE_METHOD1 (Bone, GetRotName_s, const char **)
 
 ATTRIBUTE_METHOD1 (Bone, GetTransName_s, const char **)
 
 ATTRIBUTE_METHOD1 (Bone, GetScaleName_s, const char **)
 
 ATTRIBUTE_METHOD1 (Bone, IsBillBoarded_s, bool *)
 
 ATTRIBUTE_METHOD1 (Bone, IsPivotBone_s, bool *)
 
 ATTRIBUTE_METHOD1 (Bone, IsOffsetMatrixBone_s, bool *)
 
 ATTRIBUTE_METHOD1 (Bone, IsTransformationNode_s, bool *)
 
 ATTRIBUTE_METHOD1 (Bone, IsStaticTransform_s, bool *)
 
 ATTRIBUTE_METHOD1 (Bone, IsAnimated_s, bool *)
 
 ATTRIBUTE_METHOD1 (Bone, SetOffsetMatrix_s, const Matrix4 &)
 
 ATTRIBUTE_METHOD1 (Bone, SetStaticTransform_s, const Matrix4 &)
 
 ATTRIBUTE_METHOD (Bone, RemoveRedundentKeys_s)
 
 ATTRIBUTE_METHOD1 (Bone, GetFinalMatrix_s, Matrix4 *)
 
 ATTRIBUTE_METHOD1 (Bone, GetFinalRotMatrix_s, Matrix4 *)
 
 ATTRIBUTE_METHOD1 (Bone, GetPivotRotMatrix_s, Matrix4 *)
 
 ATTRIBUTE_METHOD1 (Bone, GetPivotPoint_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (Bone, GetAnimatedPivotPoint_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (Bone, SetFinalRot_s, Quaternion)
 
 ATTRIBUTE_METHOD1 (Bone, GetFinalRot_s, Quaternion *)
 
 ATTRIBUTE_METHOD1 (Bone, SetFinalTrans_s, Vector3)
 
 ATTRIBUTE_METHOD1 (Bone, GetFinalTrans_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (Bone, SetFinalScaling_s, Vector3)
 
 ATTRIBUTE_METHOD1 (Bone, GetFinalScaling_s, Vector3 *)
 
 ATTRIBUTE_METHOD1 (Bone, GetParentIndex_s, int *)
 
 ATTRIBUTE_METHOD1 (Bone, GetBoneIndex_s, int *)
 
 ATTRIBUTE_METHOD1 (Bone, GetBoneID_s, int *)
 
 ATTRIBUTE_METHOD1 (Bone, SetBoneID_s, int)
 
virtual const std::string & GetIdentifier ()
 get the name or identifier. More...
 
virtual void SetIdentifier (const std::string &sID)
 
bool IsBillBoarded () const
 whether the bone is billboarded
 
bool IsPivotBone () const
 whether calculate bone matrix using each bone's pivot point and SRT transforms relative to the current bone. More...
 
bool IsOffsetMatrixBone () const
 whether calculate bone matrix using offset matrix (which transform from mesh to local bone space) and SRT transforms relative to the parent bone
 
bool IsStaticTransform () const
 whether the bone has no animation and a static transform is used to transform from current bone space to its parent bone space. More...
 
bool IsTransformationNode () const
 whether the bone is transformation node
 
void SetOffsetMatrix (const Matrix4 &mat)
 calling this function means that you want to use BONE_OFFSET_MATRIX for final bone matrix calculation. More...
 
void SetStaticTransform (const Matrix4 &mat)
 calling this function means that you want to use BONE_STATIC_TRANSFORM for final bone matrix calculation. More...
 
bool CheckHasAnimation ()
 whether the bone contains animation data. More...
 
const std::string & GetName () const
 
void SetName (const std::string &val)
 
void AutoSetBoneInfoFromName ()
 automatically set bone id from bone name. More...
 
bool IsAnimated ()
 whether bone is animated. More...
 
bool calcMatrix (Bone *allbones, const AnimIndex &CurrentAnim, const AnimIndex &BlendingAnim, float blendingFactor, IAttributeFields *pAnimInstance=NULL)
 calc bone matrix and all of its parent bones. More...
 
void calcMatrix (Bone *allbones)
 for static bones
 
bool GetExternalRot (IAttributeFields *pAnimInstance, Quaternion &outQuat)
 get external rot quaternion from animation instance. More...
 
bool GetExternalTranslation (IAttributeFields *pAnimInstance, Vector3 &outTrans)
 
bool GetExternalScaling (IAttributeFields *pAnimInstance, Vector3 &outScaling)
 
void RemoveRedundentKeys ()
 Always call this function after loading data from files. More...
 
void PostCalculateBoneMatrix ()
 
const ParaEngine::Matrix4GetFinalMatrix ()
 
const Vector3GetPivotPoint ()
 return the pivot point in binding space
 
Vector3 GetAnimatedPivotPoint ()
 return the current pivot point
 
int GetParentIndex () const
 
int GetBoneIndex () const
 
int GetBoneID () const
 
int IsAttachment () const
 
int GetAttachmentId () const
 return -1 if it is not attachment id. More...
 
void SetBoneID (int val)
 
const ParaEngine::QuaternionGetFinalRot () const
 
void SetFinalRot (const ParaEngine::Quaternion &val)
 
const Vector3GetFinalTrans () const
 
void SetFinalTrans (const Vector3 &val)
 
const Vector3GetFinalScaling () const
 
void SetFinalScaling (const Vector3 &val)
 
const ParaEngine::Matrix4GetFinalRotMatrix () const
 
Matrix4 GetPivotRotMatrix ()
 similar to GetFinalRotMatrix(), except that it will remove rotation in its offset matrix. More...
 
void MakeDirty (bool bForce=false)
 mark this bone as un-calculated bone. More...
 
const std::string & GetRotName ()
 
const std::string & GetTransName ()
 
const std::string & GetScaleName ()
 
- Public Member Functions inherited from ParaEngine::IAttributeFields
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 GetChildAttributeColumnCount ()
 we support multi-dimensional child object. More...
 
virtual int GetChildAttributeObjectCount (int nColumnIndex=0)
 get the number of child objects (row count) in the given column. More...
 
virtual IAttributeFieldsGetChildAttributeObject (int nRowIndex, int nColumnIndex=0)
 
virtual IAttributeFieldsGetChildAttributeObject (const std::string &sName)
 get attribute by child object. More...
 
 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 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 CDynamicAttributeFieldGetDynamicField (const std::string &sName)
 Get a dynamic field with a given name. More...
 
virtual CDynamicAttributeFieldGetDynamicField (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...
 
CAttributeClassGetAttributeClass ()
 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...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () 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 ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
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 ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Public Attributes

std::string m_sIdentifer
 
std::string m_sRotName
 
std::string m_sTransName
 
std::string m_sScaleName
 
Animated< Vector3trans
 
Animated< Quaternionrot
 
Animated< Vector3scale
 
Vector3 pivot
 
Matrix4 matOffset
 
Matrix4 matTransform
 
int parent
 
int nBoneID
 
int nIndex
 
DWORD flags
 
Matrix4 mat
 
Matrix4 mrot
 
Quaternion m_finalRot
 
Vector3 m_finalTrans
 
Vector3 m_finalScaling
 
bool calc
 
bool bUsePivot
 

Static Public Attributes

static const int s_MaxBonesPerVertex = 4
 max number of bones per vertex, currently this is 4. More...
 

Friends

class CBVHSerializer
 

Additional Inherited Members

- Static Public Member Functions inherited from ParaEngine::IAttributeFields
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...
 
- Protected Member Functions inherited from ParaEngine::IAttributeFields
virtual CAttributeClassCreateAttributeClass ()
 initialize fields
 
virtual CDynamicAttributesSetGetDynamicAttributes (bool bCreateIfNotExist=false)
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 

Detailed Description

a single animated bone, it contains both the bone instance data and all animation data of the bone.

There are three ways to calculate final bone matrix.

  1. using each bone's pivot point and SRT transforms relative to the current bone
  2. using offset matrix (which transform from mesh to local bone space) and SRT transforms relative to the parent bone
  3. the bone has no animation and a static transform is used to transform from current bone space to its parent bone space.

Member Enumeration Documentation

§ BONE_FLAGS

Enumerator
BONE_USE_PIVOT 

calculate bone matrix using each bone's pivot point and SRT transforms relative to the current bone.

offset matrix is not used.

BONE_BILLBOARDED 

whether the bone is billboarded

BONE_OFFSET_MATRIX 

calculate bone matrix using offset matrix (which transform from mesh to local bone space) and SRT transforms relative to the parent bone pivot point is not used.

BONE_STATIC_TRANSFORM 

the bone has no animation and a static transform is used to transform from current bone space to its parent bone space.

Member Function Documentation

§ AutoSetBoneInfoFromName()

void ParaEngine::Bone::AutoSetBoneInfoFromName ( )

automatically set bone id from bone name.

§ calcMatrix()

bool Bone::calcMatrix ( Bone allbones,
const AnimIndex CurrentAnim,
const AnimIndex BlendingAnim,
float  blendingFactor,
IAttributeFields pAnimInstance = NULL 
)

calc bone matrix and all of its parent bones.

for shared animations to take effect,bones must be named properly in 3dsmax (the default biped naming of character studio in 3dsmax 7,8,9 is compatible with us).

Parameters
nCurrentAnimcurrent animation sequence ID
currentFramean 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.
nBlendingAnimthe animation sequence with which the current animation should be blended.
blendingFramean 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.
blendingFactorby 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
pAnimInstanceif specified, we will use rotation variable in the animation instance if any.

Here is the list of known bone names (case insensitive, maybe prefixed with any characters like biped01,but not suffixed): Root(any name which is parent of pelvis), Pelvis,Spine, L Thigh,L Calf, L Foot, R Thigh,R Calf, R Foot, L Clavicle, L UpperArm, L Forearm, L Hand, R Clavicle, R UpperArm, R Forearm,R Hand,Head,Neck, L Toe0, R Toe0, R Finger0, L Finger0, Spine1, Spine2, Spine3, The parent of the pelvis bone is always regarded as the root bone (Root). All predefined bones must have pivot points,otherwise external animation will not be applied. only the Bone_Root and facial bone's translation animation (which is also scaled automatically according to the local model) will be applied to the local model, for all other predefined bones, only rotation is applied. This conforms to the BVH file format, where only the root node has translation and rotation animation, where all other nodes contains only rotation animation. This allows the same animation data to be applied to different models with different bone lengths, but the same topology.

§ CheckHasAnimation()

bool ParaEngine::Bone::CheckHasAnimation ( )

whether the bone contains animation data.

§ GetAttachmentId()

int ParaEngine::Bone::GetAttachmentId ( ) const

return -1 if it is not attachment id.

of it is non-negative attachment id

§ GetExternalRot()

bool ParaEngine::Bone::GetExternalRot ( IAttributeFields pAnimInstance,
Quaternion outQuat 
)

get external rot quaternion from animation instance.

Returns
true, if rotation is found, otherwise the one in the bone should be used.

§ GetIdentifier()

const std::string & ParaEngine::Bone::GetIdentifier ( )
virtual

get the name or identifier.

Reimplemented from ParaEngine::IAttributeFields.

§ GetPivotRotMatrix()

ParaEngine::Matrix4 ParaEngine::Bone::GetPivotRotMatrix ( )

similar to GetFinalRotMatrix(), except that it will remove rotation in its offset matrix.

§ InstallFields()

int ParaEngine::Bone::InstallFields ( CAttributeClass pClass,
bool  bOverride 
)
virtual

this class should be implemented if one wants to add new attribute.

This function is always called internally.

Reimplemented from ParaEngine::IAttributeFields.

§ IsAnimated()

bool ParaEngine::Bone::IsAnimated ( )

whether bone is animated.

§ IsPivotBone()

bool ParaEngine::Bone::IsPivotBone ( ) const
inline

whether calculate bone matrix using each bone's pivot point and SRT transforms relative to the current bone.

§ IsStaticTransform()

bool ParaEngine::Bone::IsStaticTransform ( ) const
inline

whether the bone has no animation and a static transform is used to transform from current bone space to its parent bone space.

§ MakeDirty()

void ParaEngine::Bone::MakeDirty ( bool  bForce = false)

mark this bone as un-calculated bone.

Parameters
bForceif false(default), Static and transformation node are never dirty.

§ RemoveRedundentKeys()

void Bone::RemoveRedundentKeys ( )

Always call this function after loading data from files.

§ SetOffsetMatrix()

void ParaEngine::Bone::SetOffsetMatrix ( const Matrix4 mat)

calling this function means that you want to use BONE_OFFSET_MATRIX for final bone matrix calculation.

§ SetStaticTransform()

void ParaEngine::Bone::SetStaticTransform ( const Matrix4 mat)

calling this function means that you want to use BONE_STATIC_TRANSFORM for final bone matrix calculation.

Member Data Documentation

§ s_MaxBonesPerVertex

const int ParaEngine::Bone::s_MaxBonesPerVertex = 4
static

max number of bones per vertex, currently this is 4.


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