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

#include <AAnimatableObject.h>

Inheritance diagram for AAnimatableObject:

Classes

struct  AttachmentInfo
 

Public Types

enum  FLAGS_ : FLAGS { FLAGS_NONE = 0 , FLAGS_CREATED = ( 1U << ( 0 ) ) , FLAGS_NO_ANIMATION = ( 1U << ( 1 ) ) }
 
enum  CREATE_FLAGS_ : CREATE_FLAGS { CREATE_FLAGS_NONE = 0 , CREATE_FLAGS_NO_ANIM_CONTROLLER = ( 1U << ( 0 ) ) }
 
using ThisClass = AAnimatableObject
 
using BaseClass = Toshi::TObject
 
using FLAGS = TUINT8
 
using CREATE_FLAGS = TUINT
 

Public Member Functions

virtual Toshi::TClass * GetClass () override
 
 AAnimatableObject ()
 
 ~AAnimatableObject ()
 
TBOOL Create (AAnimatableObjectType *a_pObjectType, void *a_Unk1, CREATE_FLAGS a_eFlags=CREATE_FLAGS_NONE)
 
TBOOL Update (TFLOAT a_fDeltaTime)
 
void UpdateAnimControllers (TFLOAT a_fDeltaTime)
 
TBOOL PlayAnimation (const Toshi::TPString8 &a_strName)
 
void KillAllAnimations ()
 
void SetVisible (TBOOL a_bVisible)
 
void SetSkeletonUpdating (TBOOL a_bUpdating, TBOOL a_bRecursive)
 
const Toshi::T2Vector< Toshi::TPString8, 2 > & GetQueuedAnimations () const
 
AModelInstanceRef GetModelInstance ()
 
TBOOL IsAnimated () const
 

Static Public Member Functions

static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static __forceinline Toshi::TClass * GetClassStatic ()
 

Static Public Attributes

static constexpr Toshi::TClass * PARENTCLASS = & Toshi::TObject::ms_oClass
 
static Toshi::TClass ms_oClass = Toshi::TClass( "AAnimatableObject", AAnimatableObject::PARENTCLASS, AAnimatableObject::CreateTObject, AAnimatableObject::CreateTObjectInPlace, AAnimatableObject::InitialiseClass, AAnimatableObject::DeinitialiseClass, 0, 1, sizeof( AAnimatableObject ), alignof( AAnimatableObject ) )
 

Friends

class AAnimatableObjectManager
 

Detailed Description

Definition at line 15 of file AAnimatableObject.h.

Member Typedef Documentation

◆ BaseClass

using AAnimatableObject::BaseClass = Toshi::TObject

Definition at line 21 of file AAnimatableObject.h.

◆ CREATE_FLAGS

Definition at line 41 of file AAnimatableObject.h.

◆ FLAGS

Definition at line 33 of file AAnimatableObject.h.

◆ ThisClass

Member Enumeration Documentation

◆ CREATE_FLAGS_

Enumerator
CREATE_FLAGS_NONE 
CREATE_FLAGS_NO_ANIM_CONTROLLER 

Definition at line 42 of file AAnimatableObject.h.

43 {
46 };
#define BITFLAG(x)
Definition Defines.h:10

◆ FLAGS_

Enumerator
FLAGS_NONE 
FLAGS_CREATED 
FLAGS_NO_ANIMATION 

Definition at line 34 of file AAnimatableObject.h.

Constructor & Destructor Documentation

◆ AAnimatableObject()

AAnimatableObject::AAnimatableObject ( )

Definition at line 16 of file AAnimatableObject.cpp.

17 : m_pUnk1( TNULL )
18 , m_pObjectType( TNULL )
19 , m_pModelInstance( TNULL )
20 , m_eFlags( FLAGS_NONE )
21{
22}
#define TNULL
Definition Typedefs.h:23

◆ ~AAnimatableObject()

AAnimatableObject::~AAnimatableObject ( )

Definition at line 26 of file AAnimatableObject.cpp.

27{
28 m_llAnimControllers.DeleteAll();
29
30 if ( m_pModelInstance )
31 {
32 AModelInstance* pModelInstance = m_pModelInstance;
33 m_pModelInstance = TNULL;
34
35 AModelRepos::GetSingleton()->DestroyModelInstance( pModelInstance );
36 }
37
38 m_llAttachedObjects.Clear();
39}

Member Function Documentation

◆ Create()

TBOOL AAnimatableObject::Create ( AAnimatableObjectType * a_pObjectType,
void * a_Unk1,
CREATE_FLAGS a_eFlags = CREATE_FLAGS_NONE )

Definition at line 42 of file AAnimatableObject.cpp.

43{
44 m_pUnk1 = a_Unk1;
45 m_pObjectType = a_pObjectType;
46
47 // Instantiate a model
48 m_pModelInstance = AModelRepos::GetSingleton()->InstantiateModel( a_pObjectType->GetModel() );
49
50 if ( m_pModelInstance )
51 {
52 if ( !T2String8::CompareNoCase( "sunglasses", a_pObjectType->GetName(), 10 ) )
53 {
54 // Instantiating sunglasses model
55 m_pModelInstance->SetReceivesLight( TFALSE );
56 }
57
58 TSceneObject* pSceneObject = m_pModelInstance->GetSceneObject();
59
60 pSceneObject->GetSomeVector2().y = 1.0;
61 pSceneObject->EnableUnknown1();
62 m_eFlags |= FLAGS_CREATED;
63
64 m_oToshiAnimInterface.SetSkeletonInstance( pSceneObject->GetSkeletonInstance() );
65 m_oToshiAnimInterface.SetAnimationSet( a_pObjectType->GetDefaultAnimationSet() );
66
67 if ( !( a_eFlags & CREATE_FLAGS_NO_ANIM_CONTROLLER ) )
68 {
69 // Create animation controllers
70 T2_FOREACH( a_pObjectType->GetAnimControllerTypes(), it )
71 {
72 TClass* pControllerClass = it->GetControllerClass();
73 TVALIDPTR( pControllerClass );
74
75 AAnimController* pAnimController = TSTATICCAST( AAnimController, pControllerClass->CreateObject() );
76 TVALIDPTR( pAnimController );
77
78 TBOOL bCreated = pAnimController->Create( a_Unk1, this, it );
79 TASSERT( TTRUE == bCreated );
80
81 m_llAnimControllers.PushBack( pAnimController );
82 }
83 }
84
85 a_pObjectType->OnAnimatableObjectCreated( this );
86 }
87
88 return m_eFlags & FLAGS_CREATED;
89}
#define TASSERT(X,...)
Definition Defines.h:138
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define TVALIDPTR(PTR)
Definition Defines.h:139
#define T2_FOREACH(vecName, iteratorName)
Definition T2Iterator.h:4
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
TFLOAT y
Definition TVector2.h:139
static TINT CompareNoCase(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
Definition T2String8.cpp:60
class TObject * CreateObject() const
Definition TClass.cpp:116
TVector2 & GetSomeVector2()
void EnableUnknown1()
TSkeletonInstance * GetSkeletonInstance()
const Toshi::TPString8 & GetName() const
ANamedAnimationSetRef GetDefaultAnimationSet() const
Toshi::T2DList< AAnimControllerType > & GetAnimControllerTypes()
virtual void OnAnimatableObjectCreated(AAnimatableObject *a_pAnimatableObject)
TBOOL Create(void *a_pUnk, AAnimatableObject *a_pAnimatableObject, AAnimControllerType *a_pControllerType)

◆ CreateTObject()

Toshi::TObject * AAnimatableObject::CreateTObject ( )
static

Definition at line 13 of file AAnimatableObject.cpp.

◆ CreateTObjectInPlace()

Toshi::TObject * AAnimatableObject::CreateTObjectInPlace ( void * a_pPtr)
static

Definition at line 13 of file AAnimatableObject.cpp.

◆ DeinitialiseClass()

void AAnimatableObject::DeinitialiseClass ( )
static

Definition at line 13 of file AAnimatableObject.cpp.

◆ GetClass()

Toshi::TClass * AAnimatableObject::GetClass ( )
overridevirtual

Definition at line 13 of file AAnimatableObject.cpp.

◆ GetClassStatic()

static __forceinline Toshi::TClass * AAnimatableObject::GetClassStatic ( )
inlinestatic

Definition at line 21 of file AAnimatableObject.h.

◆ GetModelInstance()

AModelInstanceRef AAnimatableObject::GetModelInstance ( )
inline

Definition at line 68 of file AAnimatableObject.h.

68{ return m_pModelInstance; }

◆ GetQueuedAnimations()

const Toshi::T2Vector< Toshi::TPString8, 2 > & AAnimatableObject::GetQueuedAnimations ( ) const
inline

Definition at line 66 of file AAnimatableObject.h.

66{ return m_vecQueuedAnims; }

◆ InitialiseClass()

void AAnimatableObject::InitialiseClass ( )
static

Definition at line 13 of file AAnimatableObject.cpp.

◆ IsAnimated()

TBOOL AAnimatableObject::IsAnimated ( ) const
inline

Definition at line 69 of file AAnimatableObject.h.

69{ return !HASANYFLAG( m_eFlags, FLAGS_NO_ANIMATION ); }
#define HASANYFLAG(STATE, FLAG)
Definition Defines.h:5

◆ KillAllAnimations()

void AAnimatableObject::KillAllAnimations ( )

Definition at line 205 of file AAnimatableObject.cpp.

206{
207 m_vecQueuedAnims.Clear();
208 m_oToshiAnimInterface.KillAllAnimations();
209}

◆ PlayAnimation()

TBOOL AAnimatableObject::PlayAnimation ( const Toshi::TPString8 & a_strName)

Definition at line 126 of file AAnimatableObject.cpp.

127{
128 if ( !StartAnimation( a_strName ) )
129 {
130 // Couldn't play animation right now, play it later
131 TASSERT( m_vecQueuedAnims.Size() != m_vecQueuedAnims.CAPACITY );
132
133 m_vecQueuedAnims.PushBack( a_strName );
134 return TFALSE;
135 }
136
137 return TTRUE;
138}

◆ SetSkeletonUpdating()

void AAnimatableObject::SetSkeletonUpdating ( TBOOL a_bUpdating,
TBOOL a_bRecursive )

Definition at line 188 of file AAnimatableObject.cpp.

189{
190 TVALIDPTR( m_pModelInstance );
191
192 m_pModelInstance->SetSkeletonUpdating( a_bUpdating );
193
194 if ( a_bRecursive )
195 {
196 // Update settings of attached objects
197 T2_FOREACH( m_llAttachedObjects, it )
198 {
199 it->SetSkeletonUpdating( a_bUpdating, TTRUE );
200 }
201 }
202}

◆ SetVisible()

void AAnimatableObject::SetVisible ( TBOOL a_bVisible)

Definition at line 180 of file AAnimatableObject.cpp.

181{
182 TVALIDPTR( m_pModelInstance );
183
184 m_pModelInstance->SetVisible( a_bVisible );
185}

◆ Update()

TBOOL AAnimatableObject::Update ( TFLOAT a_fDeltaTime)

Definition at line 92 of file AAnimatableObject.cpp.

93{
94 if ( !HASANYFLAG( m_eFlags, FLAGS_CREATED ) )
95 return TTRUE;
96
97 AToshiAnimationInterface::AnimEventList animEvents;
98
99 PlayQueuedAnimation();
100 m_oToshiAnimInterface.Update( a_fDeltaTime, animEvents );
101
102 // Update attached animation controllers
103 UpdateAnimControllers( a_fDeltaTime );
104
105 // Handle the animation events
106 for ( TINT i = 0; i < animEvents.iNumEvents; i++ )
107 {
109 TASSERT( !"Call the breakpoint" );
110 }
111
112 return TTRUE;
113}
int TINT
Definition Typedefs.h:7
void UpdateAnimControllers(TFLOAT a_fDeltaTime)

◆ UpdateAnimControllers()

void AAnimatableObject::UpdateAnimControllers ( TFLOAT a_fDeltaTime)

Definition at line 116 of file AAnimatableObject.cpp.

117{
118 T2_FOREACH( m_llAnimControllers, it )
119 {
120 if ( it->IsEnabled() )
121 it->OnUpdate( a_fDeltaTime );
122 }
123}

Friends And Related Symbol Documentation

◆ AAnimatableObjectManager

friend class AAnimatableObjectManager
friend

Definition at line 48 of file AAnimatableObject.h.

Member Data Documentation

◆ ms_oClass

Definition at line 21 of file AAnimatableObject.h.

◆ PARENTCLASS

Toshi::TClass* AAnimatableObject::PARENTCLASS = & Toshi::TObject::ms_oClass
staticconstexpr

Definition at line 21 of file AAnimatableObject.h.


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