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

#include <ANamedAnimation.h>

Classes

struct  AAnimationBreakpointSortResult
 

Public Types

enum  FLAGS_ : FLAGS {
  FLAGS_NONE = 0 , FLAGS_FINISH_MANUAL = ( 1U << ( 0 ) ) , FLAGS_FINISH_ON_ANIM_END = ( 1U << ( 1 ) ) , FLAGS_OVERLAY = ( 1U << ( 2 ) ) ,
  FLAGS_STATIC = ( 1U << ( 3 ) ) , FLAGS_NO_ANIM_REF = ( 1U << ( 4 ) ) , FLAGS_LOOP = ( 1U << ( 5 ) ) , FLAGS_REVERSE = ( 1U << ( 6 ) )
}
 
enum  FINISHTYPE_ : FINISHTYPE { FINISHTYPE_MANUAL , FINISHTYPE_AUTO }
 
using FLAGS = TUINT16
 
using FINISHTYPE = TINT
 
using BreakpointList = Toshi::T2DynamicVector<AAnimationBreakpoint*>
 
using SortedBreakpointList = Toshi::T2SortedVector<AAnimationBreakpoint*, BreakpointList, AAnimationBreakpointSortResult>
 

Public Member Functions

 ANamedAnimation (Toshi::T2Allocator *a_pAllocator)
 
 ~ANamedAnimation ()
 
TBOOL Create (const PBProperties *a_pProperties, Toshi::TSkeleton *a_pSkeleton)
 
void Reset ()
 
void AttachBreakpoint (AAnimationBreakpoint *a_pBreakpoint)
 
ANamedAnimationTransitionSetGetTransitionSet ()
 
TINT16 GetSequenceId () const
 
TBOOL IsFinishManual () const
 
TBOOL IsOverlay () const
 
TBOOL IsReversed () const
 
TBOOL IsLooped () const
 
TBOOL IsStatic () const
 
FLAGS GetFlags () const
 
TFLOAT GetDefaultBlendOutTime () const
 
TFLOAT GetDefaultBlendInTime () const
 
TFLOAT GetDefaultWeight () const
 
TFLOAT GetSpeed () const
 
TFLOAT GetDuration () const
 
const Toshi::TPString8 & GetName () const
 
const Toshi::TPString8 & GetExportedName () const
 
SortedBreakpointListGetBreakpoints ()
 

Static Public Member Functions

static FINISHTYPE GetFinishType (const Toshi::TPString8 &a_rcFinishType)
 

Detailed Description

Definition at line 77 of file ANamedAnimation.h.

Member Typedef Documentation

◆ BreakpointList

using ANamedAnimation::BreakpointList = Toshi::T2DynamicVector<AAnimationBreakpoint*>

Definition at line 118 of file ANamedAnimation.h.

◆ FINISHTYPE

Definition at line 93 of file ANamedAnimation.h.

◆ FLAGS

Definition at line 80 of file ANamedAnimation.h.

◆ SortedBreakpointList

Member Enumeration Documentation

◆ FINISHTYPE_

Enumerator
FINISHTYPE_MANUAL 
FINISHTYPE_AUTO 

Definition at line 94 of file ANamedAnimation.h.

◆ FLAGS_

Enumerator
FLAGS_NONE 
FLAGS_FINISH_MANUAL 
FLAGS_FINISH_ON_ANIM_END 
FLAGS_OVERLAY 
FLAGS_STATIC 
FLAGS_NO_ANIM_REF 
FLAGS_LOOP 
FLAGS_REVERSE 

Definition at line 81 of file ANamedAnimation.h.

Constructor & Destructor Documentation

◆ ANamedAnimation()

ANamedAnimation::ANamedAnimation ( Toshi::T2Allocator * a_pAllocator)

Definition at line 136 of file ANamedAnimation.cpp.

137 : m_vecBreakpoints( a_pAllocator, 0, 0 )
138 , m_oTransitionSet( this, a_pAllocator )
139{
140 m_iSequenceId = -1;
141 m_eFlags = FLAGS_NONE;
142 m_fDefaultBlendOutTime = 0.3f;
143 m_fDefaultBlendInTime = 0.3f;
144 m_fDefaultWeight = 1.0f;
145 m_fSpeed = 1.0f;
146 m_pAllocator = a_pAllocator;
147
148 m_eFlags = FLAGS_NONE;
149 m_eFlags = m_eFlags | FLAGS_LOOP;
150}

◆ ~ANamedAnimation()

ANamedAnimation::~ANamedAnimation ( )

Definition at line 153 of file ANamedAnimation.cpp.

154{
155 // Delete breakpoints
156 T2_FOREACH( m_vecBreakpoints, it )
157 {
158 delete ( *it );
159 }
160
161 m_vecBreakpoints.Clear();
162}
#define T2_FOREACH(vecName, iteratorName)
Definition T2Iterator.h:4

Member Function Documentation

◆ AttachBreakpoint()

void ANamedAnimation::AttachBreakpoint ( AAnimationBreakpoint * a_pBreakpoint)

Definition at line 344 of file ANamedAnimation.cpp.

345{
346 m_vecBreakpoints.Push( a_pBreakpoint );
347}

◆ Create()

TBOOL ANamedAnimation::Create ( const PBProperties * a_pProperties,
Toshi::TSkeleton * a_pSkeleton )

Definition at line 183 of file ANamedAnimation.cpp.

184{
185 m_eFlags &= ~FLAGS_LOOP;
186 m_fDefaultBlendInTime = 0.3f;
187 m_fDefaultBlendOutTime = 0.3f;
188 m_fDefaultWeight = 1.0f;
189
190 TINT iNumBreakpoints = 0;
191 TPString8 strDefaultFinishType;
192
193 T2_FOREACH( ( *a_pProperties ), it )
194 {
195 const TCHAR* pchPropertyName = it->GetName().GetString();
196
197 switch ( *pchPropertyName )
198 {
199 case 'B':
200 // Breakpoint
201 iNumBreakpoints += 1;
202 break;
203 case 'D':
204 if ( !T2String8::Compare( pchPropertyName, "DefaultBlendInTime" ) )
205 {
206 m_fDefaultBlendInTime = it->GetValue()->GetFloat();
207 }
208 else if ( !T2String8::Compare( pchPropertyName, "DefaultBlendOutTime" ) )
209 {
210 m_fDefaultBlendOutTime = it->GetValue()->GetFloat();
211 }
212 else if ( !T2String8::Compare( pchPropertyName, "DefaultFinishType" ) )
213 {
214 strDefaultFinishType = it->GetValue()->GetTPString8();
215 }
216 else if ( !T2String8::Compare( pchPropertyName, "DefaultWeight" ) )
217 {
218 m_fDefaultWeight = it->GetValue()->GetFloat();
219 }
220 else if ( !T2String8::Compare( pchPropertyName, "DefaultSpeed" ) )
221 {
222 m_fSpeed = it->GetValue()->GetFloat();
223 }
224
225 break;
226 case 'E':
227 // ExportedName
228 m_strExportedName = it->GetValue()->GetTPString8();
229 break;
230 case 'L':
231 // Loop
232
233 if ( it->GetValue()->GetBoolean() )
234 m_eFlags |= FLAGS_LOOP;
235 else
236 m_eFlags &= ~FLAGS_LOOP;
237
238 break;
239 case 'N':
240 // Name
241 m_strName = it->GetValue()->GetTPString8();
242 break;
243 case 'R':
244 // Reverse
245
246 if ( it->GetValue()->GetBoolean() )
247 m_eFlags |= FLAGS_REVERSE;
248 else
249 m_eFlags &= ~FLAGS_REVERSE;
250
251 break;
252 case 'S':
253 if ( !T2String8::Compare( pchPropertyName, "Static" ) )
254 {
255 if ( it->GetValue()->GetBoolean() )
256 m_eFlags |= FLAGS_STATIC;
257 else
258 m_eFlags &= ~FLAGS_STATIC;
259 }
260 else if ( !T2String8::Compare( pchPropertyName, "Speed" ) )
261 {
262 m_fSpeed = it->GetValue()->GetFloat();
263 }
264
265 break;
266 }
267 }
268
269 TASSERT( !m_strName.IsEmpty() );
270 TASSERT( !m_strExportedName.IsEmpty() );
271
272 m_iSequenceId = a_pSkeleton->GetSequenceID( m_strExportedName, 0 );
273 TASSERT( m_iSequenceId != -1 );
274
275 if ( m_iSequenceId != -1 )
276 {
277 TSkeletonSequence* pSequence = a_pSkeleton->GetSequence( m_iSequenceId );
278
279 if ( pSequence->IsOverlay() )
280 m_eFlags |= FLAGS_OVERLAY;
281 else
282 m_eFlags &= ~FLAGS_OVERLAY;
283
284 m_fDuration = pSequence->GetDuration();
285
287 m_eFlags |= ( GetFinishType( strDefaultFinishType ) == FINISHTYPE_AUTO ) ? FLAGS_FINISH_ON_ANIM_END : FLAGS_FINISH_MANUAL;
288
289 TPString8 strModelName;
290 a_pProperties->GetParentProperties()->GetParentProperties()->GetOptionalPropertyValue( strModelName, TPS8( Model ) );
291
292 // Allocate space to store breakpoints
293 TINT iNumSoundBreakpoints = AAnimatableObjectManager::GetSingleton()->FindNumAnimationSoundBreakpoints( strModelName, this );
294 m_vecBreakpoints.AccessContainer()->Reserve( iNumBreakpoints + iNumSoundBreakpoints + 4 );
295
296 // Read breakpoints stored in the properties
297
298 T2_FOREACH( ( *a_pProperties ), it )
299 {
300 const TCHAR* pchPropertyName = it->GetName().GetString();
301
302 if ( *pchPropertyName == 'B' )
303 {
304 // Breakpoint
305 AAnimationBreakpoint* pBreakpoint = CreateBreakpointRuntime( it->GetValue()->GetProperties(), TTRUE );
306
307 if ( pBreakpoint )
308 {
309 m_vecBreakpoints.Push( pBreakpoint );
310 }
311 }
312 }
313
314 return TTRUE;
315 }
316 else
317 {
318 TERROR( "Couldn't get '%s' (Exported Name: '%s') animation from an animation set!", m_strName.GetString(), m_strExportedName.GetString() );
319 return TFALSE;
320 }
321}
#define TASSERT(X,...)
Definition Defines.h:138
#define TERROR(...)
Definition Defines.h:153
#define TPS8(STR)
Definition TPString8.h:16
char TCHAR
Definition Typedefs.h:20
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
const PBProperties * GetParentProperties() const
TBOOL GetOptionalPropertyValue(T &a_rOutValue, const TCHAR *a_szName) const
TFLOAT GetDuration() const
Definition TSkeleton.h:75
TBOOL IsOverlay() const
Definition TSkeleton.h:70
static TINT Compare(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
Definition T2String8.cpp:52
static FINISHTYPE GetFinishType(const Toshi::TPString8 &a_rcFinishType)

◆ GetBreakpoints()

SortedBreakpointList & ANamedAnimation::GetBreakpoints ( )
inline

Definition at line 147 of file ANamedAnimation.h.

147{ return m_vecBreakpoints; }

◆ GetDefaultBlendInTime()

TFLOAT ANamedAnimation::GetDefaultBlendInTime ( ) const
inline

Definition at line 141 of file ANamedAnimation.h.

141{ return m_fDefaultBlendInTime; }

◆ GetDefaultBlendOutTime()

TFLOAT ANamedAnimation::GetDefaultBlendOutTime ( ) const
inline

Definition at line 140 of file ANamedAnimation.h.

140{ return m_fDefaultBlendOutTime; }

◆ GetDefaultWeight()

TFLOAT ANamedAnimation::GetDefaultWeight ( ) const
inline

Definition at line 142 of file ANamedAnimation.h.

142{ return m_fDefaultWeight; }

◆ GetDuration()

TFLOAT ANamedAnimation::GetDuration ( ) const
inline

Definition at line 144 of file ANamedAnimation.h.

144{ return m_fDuration; }

◆ GetExportedName()

const Toshi::TPString8 & ANamedAnimation::GetExportedName ( ) const
inline

Definition at line 146 of file ANamedAnimation.h.

146{ return m_strExportedName; }

◆ GetFinishType()

ANamedAnimation::FINISHTYPE ANamedAnimation::GetFinishType ( const Toshi::TPString8 & a_rcFinishType)
static

Definition at line 167 of file ANamedAnimation.cpp.

168{
169 return ( !a_rcFinishType.GetString8().IsEmpty() && a_rcFinishType == TPS8( EndOfAnim ) ) ? FINISHTYPE_AUTO : FINISHTYPE_MANUAL;
170}

◆ GetFlags()

FLAGS ANamedAnimation::GetFlags ( ) const
inline

Definition at line 139 of file ANamedAnimation.h.

139{ return m_eFlags; }

◆ GetName()

const Toshi::TPString8 & ANamedAnimation::GetName ( ) const
inline

Definition at line 145 of file ANamedAnimation.h.

145{ return m_strName; }

◆ GetSequenceId()

TINT16 ANamedAnimation::GetSequenceId ( ) const
inline

Definition at line 133 of file ANamedAnimation.h.

133{ return m_iSequenceId; }

◆ GetSpeed()

TFLOAT ANamedAnimation::GetSpeed ( ) const
inline

Definition at line 143 of file ANamedAnimation.h.

143{ return m_fSpeed; }

◆ GetTransitionSet()

ANamedAnimationTransitionSet & ANamedAnimation::GetTransitionSet ( )
inline

Definition at line 131 of file ANamedAnimation.h.

131{ return m_oTransitionSet; }

◆ IsFinishManual()

TBOOL ANamedAnimation::IsFinishManual ( ) const
inline

Definition at line 134 of file ANamedAnimation.h.

134{ return m_eFlags & FLAGS_FINISH_MANUAL; }

◆ IsLooped()

TBOOL ANamedAnimation::IsLooped ( ) const
inline

Definition at line 137 of file ANamedAnimation.h.

137{ return m_eFlags & FLAGS_LOOP; }

◆ IsOverlay()

TBOOL ANamedAnimation::IsOverlay ( ) const
inline

Definition at line 135 of file ANamedAnimation.h.

135{ return m_eFlags & FLAGS_OVERLAY; }

◆ IsReversed()

TBOOL ANamedAnimation::IsReversed ( ) const
inline

Definition at line 136 of file ANamedAnimation.h.

136{ return m_eFlags & FLAGS_REVERSE; }

◆ IsStatic()

TBOOL ANamedAnimation::IsStatic ( ) const
inline

Definition at line 138 of file ANamedAnimation.h.

138{ return m_eFlags & FLAGS_STATIC; }

◆ Reset()

void ANamedAnimation::Reset ( )

Definition at line 326 of file ANamedAnimation.cpp.

327{
328 m_strName = TPS8( null );
329 m_strExportedName = TPS8( null );
330
331 m_eFlags &= ~FLAGS_LOOP;
332 m_eFlags &= ~FLAGS_NO_ANIM_REF;
333 m_fDefaultBlendOutTime = 0.3f;
334 m_fDefaultBlendInTime = 0.3f;
335 m_fDefaultWeight = 1.0f;
336 m_fSpeed = 1.0f;
337 m_iSequenceId = -1;
338
340 m_eFlags |= FLAGS_FINISH_MANUAL;
341}

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