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

#include <AAnimatableObjectType.h>

Inheritance diagram for AAnimatableObjectType:
AAnimatableObjectTypeBunch

Public Member Functions

 AAnimatableObjectType ()
 
virtual ~AAnimatableObjectType ()
 
virtual TBOOL CreateFromProperties (const PBProperties *a_pProperties, const Toshi::TPString8 &a_rcName)
 
virtual TBOOL Create (const Toshi::TPString8 &a_rcName)
 
virtual void OnAnimatableObjectCreated (AAnimatableObject *a_pAnimatableObject)
 
void Destroy ()
 
ANamedAnimationSetRef FindAnimationSet (const Toshi::TPString8 &a_rcName) const
 
ANamedAnimationSetRef GetAnimationSet (TINT a_iIndex) const
 
ANamedAnimationSetRef GetDefaultAnimationSet () const
 
TINT GetNumAnimationSets () const
 
AModelInstanceInstantiate ()
 
const Toshi::TPString8 & GetName () const
 
AModelGetModel () const
 
Toshi::T2DList< AAnimControllerType > & GetAnimControllerTypes ()
 

Static Public Attributes

static constexpr TSIZE MAX_ANIMATION_SETS = 6
 

Detailed Description

Definition at line 15 of file AAnimatableObjectType.h.

Constructor & Destructor Documentation

◆ AAnimatableObjectType()

AAnimatableObjectType::AAnimatableObjectType ( )

Definition at line 14 of file AAnimatableObjectType.cpp.

15{
16 m_pAModel = TNULL;
17 m_pUnk = TNULL;
18}
#define TNULL
Definition Typedefs.h:23

◆ ~AAnimatableObjectType()

AAnimatableObjectType::~AAnimatableObjectType ( )
virtual

Definition at line 22 of file AAnimatableObjectType.cpp.

Member Function Documentation

◆ Create()

TBOOL AAnimatableObjectType::Create ( const Toshi::TPString8 & a_rcName)
virtual

Definition at line 86 of file AAnimatableObjectType.cpp.

87{
88 m_strName = a_rcName;
89
90 // Get full path to the model
91 TString8 strModelPath;
92 strModelPath.Format( "%s%s", "data\\models\\", m_strName.GetString() );
93
94 TPString8 strPooledModelPath = TPString8( strModelPath.GetString() );
95
96 // Load model
97 AModelRepos* pModelRepos = AModelRepos::GetSingleton();
98 pModelRepos->LoadModel( strPooledModelPath, TNULL );
99
100 m_pAModel = pModelRepos->GetModel( strPooledModelPath );
101 TVALIDPTR( m_pAModel );
102
103 LoadAnimationSet( TNULL );
104
105 return TTRUE;
106}
#define TVALIDPTR(PTR)
Definition Defines.h:139
#define TTRUE
Definition Typedefs.h:25
TString8 & Format(const TCHAR *a_pcFormat,...)
Definition TString8.cpp:176
const TCHAR * GetString(TINT a_iIndex=0) const
Definition TString8.cpp:286
void LoadModel(const Toshi::TPString8 &a_rcName, Toshi::TTRB *a_pTRB)
AModel * GetModel(const Toshi::TPString8 &a_rcName)

◆ CreateFromProperties()

TBOOL AAnimatableObjectType::CreateFromProperties ( const PBProperties * a_pProperties,
const Toshi::TPString8 & a_rcName )
virtual

Reimplemented in AAnimatableObjectTypeBunch.

Definition at line 31 of file AAnimatableObjectType.cpp.

32{
33 TVALIDPTR( a_pProperties );
34 m_strName = a_rcName;
35
36 // Get anim object name
37 TPString8 strObjName;
38 a_pProperties->GetOptionalPropertyValue( strObjName, TPS8( Name ) );
39
40 // Get anim object model name
41 TPString8 strObjModel = strObjName;
42 a_pProperties->GetOptionalPropertyValue( strObjModel, TPS8( Model ) );
43
44 // Get full path to the model
45 TString8 strModelPath;
46 strModelPath.Format( "%s%s", "data\\models\\", strObjModel.GetString() );
47
48 TPString8 strPooledModelPath = TPString8( strModelPath.GetString() );
49
50 // Load model
51 AModelRepos* pModelRepos = AModelRepos::GetSingleton();
52 pModelRepos->LoadModel( strPooledModelPath, TNULL );
53
54 m_pAModel = pModelRepos->GetModel( strPooledModelPath );
55 TVALIDPTR( m_pAModel );
56
57 TBOOL bLoadedAnimationSet = TFALSE;
58
59 T2_FOREACH( ( *a_pProperties ), it )
60 {
61 if ( it->GetValue()->GetType() == PBPropertyValue::Type::Properties )
62 {
63 if ( !T2String8::Compare( it->GetName().GetString(), "NamedAnimationSet" ) )
64 {
65 LoadAnimationSet( it->GetValue()->GetProperties() );
66 bLoadedAnimationSet = TTRUE;
67 }
68 else if ( !T2String8::Compare( it->GetName().GetString(), "AnimControllerType" ) )
69 {
70 SetAnimController( it->GetValue()->GetProperties() );
71 }
72 else if ( !T2String8::Compare( it->GetName().GetString(), "Skins" ) )
73 {
74 SetSkins( it->GetValue()->GetProperties() );
75 }
76 }
77 }
78
79 if ( !bLoadedAnimationSet )
80 LoadAnimationSet( TNULL );
81
82 return TTRUE;
83}
#define T2_FOREACH(vecName, iteratorName)
Definition T2Iterator.h:4
#define TPS8(STR)
Definition TPString8.h:16
#define TFALSE
Definition Typedefs.h:24
bool TBOOL
Definition Typedefs.h:6
TBOOL GetOptionalPropertyValue(T &a_rOutValue, const TCHAR *a_szName) const
static TINT Compare(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
Definition T2String8.cpp:52
TFORCEINLINE const TCHAR * GetString() const
Definition TPString8.h:167

◆ Destroy()

void AAnimatableObjectType::Destroy ( )

Definition at line 113 of file AAnimatableObjectType.cpp.

114{
115 m_vecAnimationSets.Clear();
116 m_llAnimControllerTypes.DeleteAll();
117
118 if ( m_pAModel )
119 {
120 AModelRepos::GetSingleton()->UnloadModel( m_pAModel->GetName(), TFALSE );
121 m_pAModel = TNULL;
122 }
123
124 if ( m_pUnk )
125 {
126 TASSERT( !"Destroy m_pUnk" );
127 delete m_pUnk;
128 m_pUnk = TNULL;
129 }
130}
#define TASSERT(X,...)
Definition Defines.h:138

◆ FindAnimationSet()

ANamedAnimationSetRef AAnimatableObjectType::FindAnimationSet ( const Toshi::TPString8 & a_rcName) const

Definition at line 133 of file AAnimatableObjectType.cpp.

134{
135 for ( TINT i = 0; i < m_vecAnimationSets.Size(); i++ )
136 {
137 if ( m_vecAnimationSets[ i ]->GetName() == a_rcName )
138 {
139 return m_vecAnimationSets[ i ];
140 }
141 }
142
143 return TNULL;
144}
int TINT
Definition Typedefs.h:7
const Toshi::TPString8 & GetName() const

◆ GetAnimationSet()

ANamedAnimationSetRef AAnimatableObjectType::GetAnimationSet ( TINT a_iIndex) const

Definition at line 147 of file AAnimatableObjectType.cpp.

148{
149 TASSERT( a_iIndex < MAX_ANIMATION_SETS );
150
151 if ( m_vecAnimationSets[ a_iIndex ].Get() )
152 return m_vecAnimationSets[ a_iIndex ];
153
154 return ANamedAnimationSetRef();
155}
Toshi::TRef< ANamedAnimationSet > ANamedAnimationSetRef
static constexpr TSIZE MAX_ANIMATION_SETS

◆ GetAnimControllerTypes()

Toshi::T2DList< AAnimControllerType > & AAnimatableObjectType::GetAnimControllerTypes ( )
inline

Definition at line 42 of file AAnimatableObjectType.h.

42{ return m_llAnimControllerTypes; }

◆ GetDefaultAnimationSet()

ANamedAnimationSetRef AAnimatableObjectType::GetDefaultAnimationSet ( ) const

Definition at line 158 of file AAnimatableObjectType.cpp.

159{
160 return GetAnimationSet( 0 );
161}
ANamedAnimationSetRef GetAnimationSet(TINT a_iIndex) const

◆ GetModel()

AModel * AAnimatableObjectType::GetModel ( ) const
inline

Definition at line 40 of file AAnimatableObjectType.h.

40{ return m_pAModel; }

◆ GetName()

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

Definition at line 39 of file AAnimatableObjectType.h.

39{ return m_strName; }

◆ GetNumAnimationSets()

TINT AAnimatableObjectType::GetNumAnimationSets ( ) const

Definition at line 163 of file AAnimatableObjectType.cpp.

164{
165 return m_vecAnimationSets.Size();
166}

◆ Instantiate()

AModelInstance * AAnimatableObjectType::Instantiate ( )

Definition at line 168 of file AAnimatableObjectType.cpp.

169{
170 return AModelRepos::GetSingleton()->InstantiateModel( GetModel() );
171}

◆ OnAnimatableObjectCreated()

void AAnimatableObjectType::OnAnimatableObjectCreated ( AAnimatableObject * a_pAnimatableObject)
virtual

Reimplemented in AAnimatableObjectTypeBunch.

Definition at line 108 of file AAnimatableObjectType.cpp.

109{
110}

Member Data Documentation

◆ MAX_ANIMATION_SETS

TSIZE AAnimatableObjectType::MAX_ANIMATION_SETS = 6
staticconstexpr

Definition at line 19 of file AAnimatableObjectType.h.


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