My Project
|
a single animated bone, it contains both the bone instance data and all animation data of the bone. More...
#include <ParaXBone.h>
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) } |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_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::Matrix4 & | GetFinalMatrix () |
const Vector3 & | GetPivotPoint () |
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::Quaternion & | GetFinalRot () const |
void | SetFinalRot (const ParaEngine::Quaternion &val) |
const Vector3 & | GetFinalTrans () const |
void | SetFinalTrans (const Vector3 &val) |
const Vector3 & | GetFinalScaling () const |
void | SetFinalScaling (const Vector3 &val) |
const ParaEngine::Matrix4 & | GetFinalRotMatrix () 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 () |
![]() | |
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 IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
virtual IAttributeFields * | GetChildAttributeObject (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 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 | |
std::string | m_sIdentifer |
std::string | m_sRotName |
std::string | m_sTransName |
std::string | m_sScaleName |
Animated< Vector3 > | trans |
Animated< Quaternion > | rot |
Animated< Vector3 > | scale |
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 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 |
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.
void ParaEngine::Bone::AutoSetBoneInfoFromName | ( | ) |
automatically set bone id from bone name.
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).
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 |
pAnimInstance | if 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.
bool ParaEngine::Bone::CheckHasAnimation | ( | ) |
whether the bone contains animation data.
int ParaEngine::Bone::GetAttachmentId | ( | ) | const |
return -1 if it is not attachment id.
of it is non-negative attachment id
bool ParaEngine::Bone::GetExternalRot | ( | IAttributeFields * | pAnimInstance, |
Quaternion & | outQuat | ||
) |
get external rot quaternion from animation instance.
|
virtual |
get the name or identifier.
Reimplemented from ParaEngine::IAttributeFields.
ParaEngine::Matrix4 ParaEngine::Bone::GetPivotRotMatrix | ( | ) |
similar to GetFinalRotMatrix(), except that it will remove rotation in its offset matrix.
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool ParaEngine::Bone::IsAnimated | ( | ) |
whether bone is animated.
|
inline |
whether calculate bone matrix using each bone's pivot point and SRT transforms relative to the current bone.
|
inline |
whether the bone has no animation and a static transform is used to transform from current bone space to its parent bone space.
void ParaEngine::Bone::MakeDirty | ( | bool | bForce = false | ) |
mark this bone as un-calculated bone.
bForce | if false(default), Static and transformation node are never dirty. |
void Bone::RemoveRedundentKeys | ( | ) |
Always call this function after loading data from files.
void ParaEngine::Bone::SetOffsetMatrix | ( | const Matrix4 & | mat | ) |
calling this function means that you want to use BONE_OFFSET_MATRIX for final bone matrix calculation.
void ParaEngine::Bone::SetStaticTransform | ( | const Matrix4 & | mat | ) |
calling this function means that you want to use BONE_STATIC_TRANSFORM for final bone matrix calculation.
|
static |
max number of bones per vertex, currently this is 4.