OpenBarnyard
 
Loading...
Searching...
No Matches
ANamedAnimation.h
Go to the documentation of this file.
1#pragma once
3
4#include <Toshi/TPString8.h>
7#include <Toshi/T2Map.h>
8#include <Render/TSkeleton.h>
10
11class ANamedAnimation;
12
13//-----------------------------------------------------------------------------
14// Purpose: Represents a single transition of a named animation
15//-----------------------------------------------------------------------------
17{
18public:
19 friend class ANamedAnimation;
21
22public:
25
26 void SetTransitionName( const Toshi::TPString8& a_strName );
27 void SetAnimationName( const Toshi::TPString8& a_strName );
28 const Toshi::TPString8& GetTransitionName();
29 const Toshi::TPString8& GetAnimationName();
30
31 void SetBlendInTime( TFLOAT a_fTime );
32 void SetBlendOutTime( TFLOAT a_fTime );
33 void SetAutoTransition( TBOOL a_bAutoTransition );
34 void SetManaged( TBOOL a_bManaged );
35
36 TFLOAT GetBlendInTime() const;
37 TFLOAT GetBlendOutTime() const;
38 TBOOL IsAutoTransition() const;
39 TBOOL IsManaged() const;
40
41private:
42 Toshi::TPString8 m_strTransitionName;
43 TFLOAT m_fBlendOutTime;
44 TFLOAT m_fBlendInTime;
45 Toshi::TPString8 m_strAnimationName;
46 TBOOL m_bAutoTransition;
47 TBOOL m_bManaged;
48};
49
50//-----------------------------------------------------------------------------
51// Purpose: Holds map of transitions applied to a named animation
52//-----------------------------------------------------------------------------
54{
55public:
56 friend class ANamedAnimation;
57
58public:
59 ANamedAnimationTransitionSet( ANamedAnimation* a_pNamedAnimation, Toshi::T2Allocator* a_pAllocator );
61
62 void AddTransition( ANamedAnimation* a_pAnimation, const Toshi::TPString8& a_strTransitionName, TFLOAT a_fBlendOutTime, TFLOAT a_fBlendInTime, TBOOL a_bIsAutoTransition, TBOOL a_bManaged );
63 ANamedAnimationTransition* FindTransition( const Toshi::TPString8& a_strName );
65
66private:
67 ANamedAnimation* m_pAnimation;
68
69 using TransitionMap = Toshi::T2Map<Toshi::TPString8, ANamedAnimationTransition, Toshi::TPString8::Comparator>;
70 TransitionMap m_mapTransitions;
71
72 Toshi::TPString8 m_strAnimationName;
73 TBOOL m_bUnk3;
74 Toshi::TPString8 m_strUnk4;
75};
76
78{
79public:
80 using FLAGS = TUINT16;
92
99
101 {
102 // $Barnyard: FUNCTION 0057fcd0
103 // $Barnyard: FUNCTION 006b6930
104 TINT operator()( AAnimationBreakpoint* const& a_rcVal1, AAnimationBreakpoint* const& a_rcVal2 ) const
105 {
106 TFLOAT fDiff = a_rcVal1->GetTime() - a_rcVal2->GetTime();
107
108 if ( 0.0f < fDiff )
109 return 1;
110
111 if ( fDiff < 0.0f )
112 return -1;
113
114 return 0;
115 }
116 };
117
118 using BreakpointList = Toshi::T2DynamicVector<AAnimationBreakpoint*>;
119 using SortedBreakpointList = Toshi::T2SortedVector<AAnimationBreakpoint*, BreakpointList, AAnimationBreakpointSortResult>;
120
121public:
122 // constructors/destructor
123 ANamedAnimation( Toshi::T2Allocator* a_pAllocator );
125
126 TBOOL Create( const PBProperties* a_pProperties, Toshi::TSkeleton* a_pSkeleton );
127 void Reset();
128
129 void AttachBreakpoint( AAnimationBreakpoint* a_pBreakpoint );
130
131 ANamedAnimationTransitionSet& GetTransitionSet() { return m_oTransitionSet; }
132
133 TINT16 GetSequenceId() const { return m_iSequenceId; }
134 TBOOL IsFinishManual() const { return m_eFlags & FLAGS_FINISH_MANUAL; }
135 TBOOL IsOverlay() const { return m_eFlags & FLAGS_OVERLAY; }
136 TBOOL IsReversed() const { return m_eFlags & FLAGS_REVERSE; }
137 TBOOL IsLooped() const { return m_eFlags & FLAGS_LOOP; }
138 TBOOL IsStatic() const { return m_eFlags & FLAGS_STATIC; }
139 FLAGS GetFlags() const { return m_eFlags; }
140 TFLOAT GetDefaultBlendOutTime() const { return m_fDefaultBlendOutTime; }
141 TFLOAT GetDefaultBlendInTime() const { return m_fDefaultBlendInTime; }
142 TFLOAT GetDefaultWeight() const { return m_fDefaultWeight; }
143 TFLOAT GetSpeed() const { return m_fSpeed; }
144 TFLOAT GetDuration() const { return m_fDuration; }
145 const Toshi::TPString8& GetName() const { return m_strName; }
146 const Toshi::TPString8& GetExportedName() const { return m_strExportedName; }
147 SortedBreakpointList& GetBreakpoints() { return m_vecBreakpoints; }
148
149 static FINISHTYPE GetFinishType( const Toshi::TPString8& a_rcFinishType );
150
151private:
152 Toshi::TPString8 m_strExportedName;
153 Toshi::TPString8 m_strName;
154 TINT16 m_iSequenceId;
155 FLAGS m_eFlags;
156 ANamedAnimationTransitionSet m_oTransitionSet;
157 TFLOAT m_fDefaultBlendOutTime;
158 TFLOAT m_fDefaultBlendInTime;
159 TFLOAT m_fDefaultWeight;
160 TFLOAT m_fSpeed;
161 TFLOAT m_fDuration;
162 Toshi::T2Allocator* m_pAllocator;
163 SortedBreakpointList m_vecBreakpoints;
164};
#define BITFLAG(x)
Definition Defines.h:10
uint16_t TUINT16
Definition Typedefs.h:15
int16_t TINT16
Definition Typedefs.h:14
float TFLOAT
Definition Typedefs.h:4
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6
Dynamic vector container for the Toshi engine.
const Toshi::TPString8 & GetAnimationName()
void SetBlendOutTime(TFLOAT a_fTime)
friend class ANamedAnimationTransitionSet
void SetAutoTransition(TBOOL a_bAutoTransition)
void SetManaged(TBOOL a_bManaged)
const Toshi::TPString8 & GetTransitionName()
void SetTransitionName(const Toshi::TPString8 &a_strName)
void SetBlendInTime(TFLOAT a_fTime)
void SetAnimationName(const Toshi::TPString8 &a_strName)
ANamedAnimationTransitionSet(ANamedAnimation *a_pNamedAnimation, Toshi::T2Allocator *a_pAllocator)
ANamedAnimationTransition * GetDestTransition()
ANamedAnimationTransition * FindTransition(const Toshi::TPString8 &a_strName)
void AddTransition(ANamedAnimation *a_pAnimation, const Toshi::TPString8 &a_strTransitionName, TFLOAT a_fBlendOutTime, TFLOAT a_fBlendInTime, TBOOL a_bIsAutoTransition, TBOOL a_bManaged)
TFLOAT GetDefaultBlendOutTime() const
TBOOL IsFinishManual() const
FLAGS GetFlags() const
static FINISHTYPE GetFinishType(const Toshi::TPString8 &a_rcFinishType)
TFLOAT GetSpeed() const
TINT16 GetSequenceId() const
ANamedAnimationTransitionSet & GetTransitionSet()
TBOOL IsLooped() const
const Toshi::TPString8 & GetExportedName() const
TBOOL IsReversed() const
TFLOAT GetDuration() const
SortedBreakpointList & GetBreakpoints()
TFLOAT GetDefaultWeight() const
Toshi::T2SortedVector< AAnimationBreakpoint *, BreakpointList, AAnimationBreakpointSortResult > SortedBreakpointList
Toshi::T2DynamicVector< AAnimationBreakpoint * > BreakpointList
TFLOAT GetDefaultBlendInTime() const
void AttachBreakpoint(AAnimationBreakpoint *a_pBreakpoint)
ANamedAnimation(Toshi::T2Allocator *a_pAllocator)
TBOOL Create(const PBProperties *a_pProperties, Toshi::TSkeleton *a_pSkeleton)
const Toshi::TPString8 & GetName() const
TBOOL IsOverlay() const
TBOOL IsStatic() const
TINT operator()(AAnimationBreakpoint *const &a_rcVal1, AAnimationBreakpoint *const &a_rcVal2) const