OpenBarnyard
 
Loading...
Searching...
No Matches
AToshiAnimationInterface.h
Go to the documentation of this file.
1#pragma once
3
4#include <Toshi/T2DList.h>
5#include <Render/TSkeleton.h>
6
8
10 : public Toshi::T2DList<AToshiAnimationRef>::Node
11{
12public:
14
15public:
18
19 void SetWeight( TFLOAT a_fWeight ) { m_fWeight = a_fWeight; }
20
21 TUINT16 GetSequenceId() const { return m_pNamedAnimation->GetSequenceId(); }
22 ANamedAnimation* GetNamedAnimation() const { return m_pNamedAnimation; }
23 ANamedAnimationTransition* GetTransition() const { return m_pTransition; }
24
25private:
26 ANamedAnimation* m_pNamedAnimation;
27 TFLOAT m_fWeight;
28 TFLOAT m_fTime;
29 ANamedAnimationTransition* m_pTransition;
30 TBOOL m_bWasEverUpdated;
31 TINT m_iBreakpointIndex;
32};
33
35{
36public:
37 static constexpr TSIZE MAX_NUM_ANIMATIONS = 20;
38
46
47 struct AnimEvent
48 {
51 Toshi::TPString8 strAnimationName;
54
55 void SetSimpleEvent( ANIMEVENT_TYPE a_eType, TBOOL a_bIsOverlay, const Toshi::TPString8& a_strAnimationName, TFLOAT a_fTimeToBreakpoint );
56 void SetBreakpointEvent( AAnimationBreakpoint* a_pBreakpoint, TBOOL a_bIsOverlay, const Toshi::TPString8& a_strAnimationName, TFLOAT a_fTimeToBreakpoint );
57 };
58
60 {
63
64 AnimEvent& Head() { return aEvents[ 0 ]; }
65 AnimEvent& Tail() { return aEvents[ iNumEvents ]; }
67
69 {
70 TASSERT( IsFull() == TFALSE );
71 return aEvents[ iNumEvents++ ];
72 }
73 };
74
75public:
78
79 void Update( TFLOAT a_fDeltaTime, AnimEventList& a_rEventList );
80
81 // Plays animation by it's name. Returns pointer to the animation ref object if created new one
82 AToshiAnimationRef* PlayAnim( const Toshi::TPString8& a_strName, TFLOAT a_fWeight, TBOOL a_bCreateNewRef );
83
84 // Stops an animation with blending settings applied. Returns TTRUE if succeeded
85 TBOOL StopAnim( const AToshiAnimationRef& a_rAnimationRef );
86
87 // Stops an animation with blending settings applied, allows custom transition settings. Returns TTRUE if succeeded
88 TBOOL StopAnim( const AToshiAnimationRef& a_rAnimationRef, ANamedAnimationTransition* a_pTransition );
89
90 // Destroys all related animations
91 void KillAllAnimations();
92
93 // Attaches transition to the animation
95
96 void SetSkeletonInstance( Toshi::TSkeletonInstance* a_pInstance ) { m_pSkeletonInstance = a_pInstance; }
97 void SetAnimationSet( const ANamedAnimationSetRef& a_rcAnimationSet ) { m_pAnimationSet = a_rcAnimationSet; }
98
99 // Creates new animation ref, adds it to the list, plays it and returns it
100 AToshiAnimationRef* CreateAnimationRef( Toshi::T2DList<AToshiAnimationRef>& a_rList, ANamedAnimation* a_pAnimation, TFLOAT a_fWeight, ANamedAnimationTransition* a_pTransition );
101
102 // Creates new overlay animation ref, adds it to the list, plays it and returns it
104
105 Toshi::TAnimation* GetAnimation( const AToshiAnimationRef& a_rAnimRef );
107
108 AToshiAnimationRef* FindAnimationRef( const Toshi::TPString8& a_strName );
109
110private:
111 // Plays animation in the specified animation ref. Returns pointer to the created TAnimation object.
112 Toshi::TAnimation* PlayAnimImpl( ANamedAnimation* a_pNamedAnimation, TFLOAT a_fWeight, ANamedAnimationTransition* a_pTransition, AToshiAnimationRef& a_rAnimationRef );
113
114 // Updates all animations and adds info about anims that just started playing into a_rEventList
115 void UpdateAnimations( Toshi::T2DList<AToshiAnimationRef>& a_rList, TFLOAT a_fDeltaTime, AnimEventList& a_rEventList );
116
117 void UpdateAnimation( TFLOAT a_fDeltaTime, AToshiAnimationRef& a_rAnimRef, Toshi::TAnimation* a_pAnimation, AnimEventList& a_rEventList );
118 void UpdateAnimationBreakpoints( AToshiAnimationRef& a_rAnimRef, Toshi::TAnimation* a_pAnimation, AnimEventList& a_rEventList );
119 void UpdateAnimationBreakpointsReverse( AToshiAnimationRef& a_rAnimRef, Toshi::TAnimation* a_pAnimation, AnimEventList& a_rEventList );
120
121 TBOOL IsAllStatic();
122
123 void DestroyAnimReferences();
124
125private:
126 Toshi::T2DList<AToshiAnimationRef> m_llAnimRefs;
127 Toshi::T2DList<AToshiAnimationRef> m_llOverlayAnimRefs;
128 ANamedAnimationSetRef m_pAnimationSet;
129 Toshi::TSkeletonInstance* m_pSkeletonInstance;
130 TFLOAT m_fTime;
131 TINT m_Unk2;
132 ANamedAnimationTransition m_oAnimTransition;
133 TUINT8 m_eFlags;
134};
#define TASSERT(X,...)
Definition Defines.h:138
uint16_t TUINT16
Definition Typedefs.h:15
int32_t TINT32
Definition Typedefs.h:12
size_t TSIZE
Definition Typedefs.h:9
uint8_t TUINT8
Definition Typedefs.h:17
float TFLOAT
Definition Typedefs.h:4
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
bool TBOOL
Definition Typedefs.h:6
Toshi::TRef< ANamedAnimationSet > ANamedAnimationSetRef
ANamedAnimationTransition * GetTransition() const
void SetWeight(TFLOAT a_fWeight)
ANamedAnimation * GetNamedAnimation() const
AToshiAnimationRef * FindAnimationRef(const Toshi::TPString8 &a_strName)
Toshi::TAnimation * GetAnimation(const AToshiAnimationRef &a_rAnimRef)
void SetSkeletonInstance(Toshi::TSkeletonInstance *a_pInstance)
void SetAnimationSet(const ANamedAnimationSetRef &a_rcAnimationSet)
TBOOL SetAnimationTransition(AToshiAnimationRef &a_rAnimationRef, ANamedAnimationTransition *a_pTransition)
TBOOL StopAnim(const AToshiAnimationRef &a_rAnimationRef)
static constexpr TSIZE MAX_NUM_ANIMATIONS
AToshiAnimationRef * CreateOverlayAnimationRef(ANamedAnimation *a_pAnimation, TFLOAT a_fWeight)
void Update(TFLOAT a_fDeltaTime, AnimEventList &a_rEventList)
ANamedAnimationSetRef GetAnimationSet()
AToshiAnimationRef * CreateAnimationRef(Toshi::T2DList< AToshiAnimationRef > &a_rList, ANamedAnimation *a_pAnimation, TFLOAT a_fWeight, ANamedAnimationTransition *a_pTransition)
AToshiAnimationRef * PlayAnim(const Toshi::TPString8 &a_strName, TFLOAT a_fWeight, TBOOL a_bCreateNewRef)
void SetBreakpointEvent(AAnimationBreakpoint *a_pBreakpoint, TBOOL a_bIsOverlay, const Toshi::TPString8 &a_strAnimationName, TFLOAT a_fTimeToBreakpoint)
void SetSimpleEvent(ANIMEVENT_TYPE a_eType, TBOOL a_bIsOverlay, const Toshi::TPString8 &a_strAnimationName, TFLOAT a_fTimeToBreakpoint)