OpenBarnyard
 
Loading...
Searching...
No Matches
TSkeleton Class Reference

#include <TSkeleton.h>

Public Types

enum  QUATINTERP_ { QUATINTERP_Default , QUATINTERP_Slerp , QUATINTERP_Nlerp }
 
using t_fnQuatLerp = void ( * )( TQuaternion& a_rOut, const TQuaternion& a_rStart, const TQuaternion& a_rEnd, TFLOAT a_fProgress )
 
using QUATINTERP = TUINT32
 

Public Member Functions

 TSkeleton ()
 
 ~TSkeleton ()
 
TSkeletonInstanceCreateInstance (TBOOL a_bSetBasePose)
 
t_fnQuatLerp GetQInterpFn () const
 
void SetQInterpFn (QUATINTERP a_eQuatInterp)
 
TSkeletonBoneGetBone (const TCHAR *a_cBoneName, TUINT32 a_iLength=0)
 
TINT GetBoneID (const TCHAR *a_cBoneName, TUINT32 a_iLength=0)
 
TKeyframeLibraryInstanceGetKeyLibraryInstance ()
 
TINT GetAnimationMaxCount ()
 
TSkeletonBoneGetBone (TINT a_iBone)
 
TSkeletonBoneGetBones ()
 
TINT GetInstanceCount () const
 
TINT GetBoneCount () const
 
TINT GetAutoBoneCount () const
 
TINT GetSequenceID (const TCHAR *a_sSequenceName, TUINT32 a_iLength=0)
 
TSkeletonSequenceGetSequences ()
 
TSkeletonSequenceGetSequence (TINT a_iSequence)
 
TSkeletonSequenceGetSequence (const TCHAR *a_sSequenceName, TUINT32 a_iLength=0)
 
TINT16 GetSequenceCount ()
 
TSkeletonoperator= (const TSkeleton &a_rSkeleton)
 

Public Attributes

friend TSkeletonInstance
 
TINT16 m_iBoneCount
 
TINT16 m_iManualBoneCount
 
TINT16 m_iSequenceCount
 
TINT16 m_iAnimationMaxCount
 
TINT16 m_iInstanceCount
 
TKeyframeLibraryInstance m_KeyLibraryInstance
 
TSkeletonBonem_pBones
 
TSkeletonSequencem_SkeletonSequences
 
union { 
 
   t_fnQuatLerp   m_fnQuatLerp 
 
   QUATINTERP   m_eQuatLerpType 
 
};  
 

Detailed Description

Definition at line 117 of file TSkeleton.h.

Member Typedef Documentation

◆ QUATINTERP

Definition at line 122 of file TSkeleton.h.

◆ t_fnQuatLerp

using TSkeleton::t_fnQuatLerp = void ( * )( TQuaternion& a_rOut, const TQuaternion& a_rStart, const TQuaternion& a_rEnd, TFLOAT a_fProgress )

Definition at line 120 of file TSkeleton.h.

Member Enumeration Documentation

◆ QUATINTERP_

Enumerator
QUATINTERP_Default 
QUATINTERP_Slerp 
QUATINTERP_Nlerp 

Definition at line 123 of file TSkeleton.h.

124 {
128 };
@ QUATINTERP_Nlerp
Definition TSkeleton.h:127
@ QUATINTERP_Default
Definition TSkeleton.h:125
@ QUATINTERP_Slerp
Definition TSkeleton.h:126

Constructor & Destructor Documentation

◆ TSkeleton()

TSkeleton::TSkeleton ( )

Definition at line 12 of file TSkeleton.cpp.

13{
14 m_iBoneCount = 0;
21}
#define TNULL
Definition Typedefs.h:23
TINT16 m_iBoneCount
Definition TSkeleton.h:162
TSkeletonSequence * m_SkeletonSequences
Definition TSkeleton.h:169
TINT16 m_iManualBoneCount
Definition TSkeleton.h:163
TINT16 m_iAnimationMaxCount
Definition TSkeleton.h:165
TINT16 m_iInstanceCount
Definition TSkeleton.h:166
TINT16 m_iSequenceCount
Definition TSkeleton.h:164
TSkeletonBone * m_pBones
Definition TSkeleton.h:168

◆ ~TSkeleton()

TSkeleton::~TSkeleton ( )

Definition at line 23 of file TSkeleton.cpp.

24{
25}

Member Function Documentation

◆ CreateInstance()

TSkeletonInstance * TSkeleton::CreateInstance ( TBOOL a_bSetBasePose)

Definition at line 28 of file TSkeleton.cpp.

29{
30 // Set quaternion interpolation method if it's not already set
33
34 auto iAutoBoneCount = GetAutoBoneCount();
35 TSIZE iAnimationSize = TAlignNumUp( iAutoBoneCount * sizeof( TAnimationBone ) + sizeof( TAnimation ) );
36 TSIZE iInstanceSize = sizeof( TSkeletonInstance ) + sizeof( TSkeletonInstanceBone ) * iAutoBoneCount + iAnimationSize * GetAnimationMaxCount();
37 TSkeletonInstance* pInstance;
38
39 pInstance = TSTATICCAST( TSkeletonInstance, TMalloc( iInstanceSize ) );
40
41 new ( pInstance ) TSkeletonInstance();
42 pInstance->m_pSkeleton = this;
43 pInstance->m_iSize = iInstanceSize;
44 pInstance->m_iBaseAnimationCount = 0;
45 pInstance->m_iOverlayAnimationCount = 0;
46 pInstance->m_eFlags = 0;
47 pInstance->m_pBones = TREINTERPRETCAST( TSkeletonInstanceBone*, pInstance + 1 );
48 pInstance->m_pAnimations = TREINTERPRETCAST( TAnimation*, pInstance->m_pBones + iAutoBoneCount );
49 pInstance->m_fTotalWeight = 0.0f;
50 pInstance->m_iLastUpdateStateFrame = 0;
51 pInstance->m_iLastUpdateTimeFrame = 0;
52
53 for ( TINT i = 0; i < GetAnimationMaxCount(); i++ )
54 {
55 TAnimation* pAnimation = TREINTERPRETCAST(
56 TAnimation*,
57 TREINTERPRETCAST( TUINTPTR, pInstance->m_pAnimations ) + i * iAnimationSize
58 );
59
60 new ( pAnimation ) TAnimation();
61 pInstance->m_FreeAnimations.PushFront( pAnimation );
62 }
63
64 if ( a_bSetBasePose )
65 pInstance->SetStateFromBasePose();
66
68 return pInstance;
69}
void * TMalloc(TSIZE a_uiSize, Toshi::TMemory::MemBlock *a_pMemBlock, const TCHAR *a_szFileName, TINT a_iLineNum)
Allocates memory from a specific memory block.
Definition TMemory.cpp:973
unsigned short TAnimationBone
Definition TAnimation.h:18
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define TREINTERPRETCAST(TYPE, VALUE)
Definition Defines.h:68
TFORCEINLINE constexpr T TAlignNumUp(T a_iValue, TSIZE a_uiAlignment=4)
Definition Helpers.h:66
uintptr_t TUINTPTR
Definition Typedefs.h:18
size_t TSIZE
Definition Typedefs.h:9
int TINT
Definition Typedefs.h:7
friend TSkeletonInstance
Definition TSkeleton.h:130
void SetQInterpFn(QUATINTERP a_eQuatInterp)
Definition TSkeleton.cpp:71
QUATINTERP m_eQuatLerpType
Definition TSkeleton.h:174
TINT GetAnimationMaxCount()
Definition TSkeleton.h:145
TINT GetAutoBoneCount() const
Definition TSkeleton.h:150
void SetStateFromBasePose()
void PushFront(T *a_pNode)
Definition TQList.h:84

◆ GetAnimationMaxCount()

TINT TSkeleton::GetAnimationMaxCount ( )
inline

Definition at line 145 of file TSkeleton.h.

145{ return m_iAnimationMaxCount; }

◆ GetAutoBoneCount()

TINT TSkeleton::GetAutoBoneCount ( ) const
inline

Definition at line 150 of file TSkeleton.h.

◆ GetBone() [1/2]

TSkeletonBone * TSkeleton::GetBone ( const TCHAR * a_cBoneName,
TUINT32 a_iLength = 0 )
inline

Definition at line 141 of file TSkeleton.h.

141{ return GetBone( GetBoneID( a_cBoneName, a_iLength ) ); }
TSkeletonBone * GetBone(const TCHAR *a_cBoneName, TUINT32 a_iLength=0)
Definition TSkeleton.h:141
TINT GetBoneID(const TCHAR *a_cBoneName, TUINT32 a_iLength=0)
Definition TSkeleton.cpp:80

◆ GetBone() [2/2]

TSkeletonBone * TSkeleton::GetBone ( TINT a_iBone)
inline

Definition at line 146 of file TSkeleton.h.

146{ return &m_pBones[ a_iBone ]; }

◆ GetBoneCount()

TINT TSkeleton::GetBoneCount ( ) const
inline

Definition at line 149 of file TSkeleton.h.

149{ return m_iBoneCount; }

◆ GetBoneID()

TINT TSkeleton::GetBoneID ( const TCHAR * a_cBoneName,
TUINT32 a_iLength = 0 )

Definition at line 80 of file TSkeleton.cpp.

81{
82 if ( a_iLength == 0 )
83 a_iLength = TStringManager::String8Length( a_szBoneName );
84
85 for ( short i = 0; i < m_iBoneCount; i++ )
86 {
87 if ( m_pBones[ i ].GetNameLength() == a_iLength &&
88 TStringManager::String8CompareNoCase( m_pBones[ i ].GetName(), a_szBoneName, a_iLength ) == 0 )
89 {
90 return i;
91 }
92 }
93
94 return TBONE_INVALID;
95}
#define TBONE_INVALID
Definition TSkeleton.h:9
static TSIZE String8Length(const TCHAR *str)
static TINT String8CompareNoCase(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)

◆ GetBones()

TSkeletonBone * TSkeleton::GetBones ( )
inline

Definition at line 147 of file TSkeleton.h.

147{ return m_pBones; }

◆ GetInstanceCount()

TINT TSkeleton::GetInstanceCount ( ) const
inline

Definition at line 148 of file TSkeleton.h.

148{ return m_iInstanceCount; }

◆ GetKeyLibraryInstance()

TKeyframeLibraryInstance & TSkeleton::GetKeyLibraryInstance ( )
inline

Definition at line 144 of file TSkeleton.h.

144{ return m_KeyLibraryInstance; }
TKeyframeLibraryInstance m_KeyLibraryInstance
Definition TSkeleton.h:167

◆ GetQInterpFn()

t_fnQuatLerp TSkeleton::GetQInterpFn ( ) const
inline

Definition at line 138 of file TSkeleton.h.

138{ return m_fnQuatLerp; }
t_fnQuatLerp m_fnQuatLerp
Definition TSkeleton.h:173

◆ GetSequence() [1/2]

TSkeletonSequence * TSkeleton::GetSequence ( const TCHAR * a_sSequenceName,
TUINT32 a_iLength = 0 )
inline

Definition at line 155 of file TSkeleton.h.

155{ return GetSequence( GetSequenceID( a_sSequenceName, a_iLength ) ); }
TINT GetSequenceID(const TCHAR *a_sSequenceName, TUINT32 a_iLength=0)
Definition TSkeleton.cpp:98
TSkeletonSequence * GetSequence(TINT a_iSequence)
Definition TSkeleton.h:154

◆ GetSequence() [2/2]

TSkeletonSequence * TSkeleton::GetSequence ( TINT a_iSequence)
inline

Definition at line 154 of file TSkeleton.h.

154{ return &m_SkeletonSequences[ a_iSequence ]; }

◆ GetSequenceCount()

TINT16 TSkeleton::GetSequenceCount ( )
inline

Definition at line 157 of file TSkeleton.h.

157{ return m_iSequenceCount; }

◆ GetSequenceID()

TINT TSkeleton::GetSequenceID ( const TCHAR * a_sSequenceName,
TUINT32 a_iLength = 0 )

Definition at line 98 of file TSkeleton.cpp.

99{
100 if ( a_iLength == 0 )
101 a_iLength = TStringManager::String8Length( a_szSequenceName );
102
103 for ( short i = 0; i < m_iSequenceCount; i++ )
104 {
105 if ( m_SkeletonSequences[ i ].GetNameLength() == a_iLength &&
106 TStringManager::String8CompareNoCase( m_SkeletonSequences[ i ].GetName(), a_szSequenceName, a_iLength ) == 0 )
107 {
108 return i;
109 }
110 }
111
112 return TSEQ_INVALID;
113}
#define TSEQ_INVALID
Definition TSkeleton.h:10

◆ GetSequences()

TSkeletonSequence * TSkeleton::GetSequences ( )
inline

Definition at line 153 of file TSkeleton.h.

153{ return m_SkeletonSequences; }

◆ operator=()

TSkeleton & TSkeleton::operator= ( const TSkeleton & a_rSkeleton)
inline

Definition at line 159 of file TSkeleton.h.

159{ TIMPLEMENT(); }
#define TIMPLEMENT()
Definition Defines.h:136

◆ SetQInterpFn()

void TSkeleton::SetQInterpFn ( QUATINTERP a_eQuatInterp)

Definition at line 71 of file TSkeleton.cpp.

72{
73 if ( a_eQuatInterp == QUATINTERP_Slerp )
75 else
77}
static void Nlerp(TQuaternion &a_rOut, const TQuaternion &a_rStart, const TQuaternion &a_rEnd, float a_fProgress)
static void Slerp(TQuaternion &a_rOut, const TQuaternion &a_rStart, const TQuaternion &a_rEnd, float a_fProgress)

Member Data Documentation

◆ [union]

union { ... } TSkeleton

◆ m_eQuatLerpType

QUATINTERP TSkeleton::m_eQuatLerpType

Definition at line 174 of file TSkeleton.h.

◆ m_fnQuatLerp

t_fnQuatLerp TSkeleton::m_fnQuatLerp

Definition at line 173 of file TSkeleton.h.

◆ m_iAnimationMaxCount

TINT16 TSkeleton::m_iAnimationMaxCount

Definition at line 165 of file TSkeleton.h.

◆ m_iBoneCount

TINT16 TSkeleton::m_iBoneCount

Definition at line 162 of file TSkeleton.h.

◆ m_iInstanceCount

TINT16 TSkeleton::m_iInstanceCount

Definition at line 166 of file TSkeleton.h.

◆ m_iManualBoneCount

TINT16 TSkeleton::m_iManualBoneCount

Definition at line 163 of file TSkeleton.h.

◆ m_iSequenceCount

TINT16 TSkeleton::m_iSequenceCount

Definition at line 164 of file TSkeleton.h.

◆ m_KeyLibraryInstance

TKeyframeLibraryInstance TSkeleton::m_KeyLibraryInstance

Definition at line 167 of file TSkeleton.h.

◆ m_pBones

TSkeletonBone* TSkeleton::m_pBones

Definition at line 168 of file TSkeleton.h.

◆ m_SkeletonSequences

TSkeletonSequence* TSkeleton::m_SkeletonSequences

Definition at line 169 of file TSkeleton.h.

◆ TSkeletonInstance

friend TSkeleton::TSkeletonInstance

Definition at line 130 of file TSkeleton.h.


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