OpenBarnyard
 
Loading...
Searching...
No Matches
AMaterialLibraryManager::List Class Reference

#include <AMaterialLibraryManager.h>

Inheritance diagram for AMaterialLibraryManager::List:

Public Member Functions

AMaterialLibraryCreateLibraryFromTRB (Toshi::TTRB *a_pTRB, const TCHAR *a_szFilePath)
 
AMaterialLibraryCreateLibraryFromAsset (const TCHAR *a_szFilePath, Toshi::TTRB *a_pTRB)
 
void DestroyLibrary (AMaterialLibrary *a_pLibrary)
 
ATextureFindTexture (const TCHAR *a_szTextureName, AMaterialLibrary **a_ppMaterialLibrary, TINT *a_pTextureIndex)
 

Detailed Description

Definition at line 18 of file AMaterialLibraryManager.h.

Member Function Documentation

◆ CreateLibraryFromAsset()

AMaterialLibrary * AMaterialLibraryManager::List::CreateLibraryFromAsset ( const TCHAR * a_szFilePath,
Toshi::TTRB * a_pTRB )

Definition at line 282 of file AMaterialLibraryManager.cpp.

283{
285
286 auto pLibrary = new AMaterialLibrary;
287 pLibrary->SetPath( a_szFilePath );
288
289 TBOOL bSuccess;
290
291 if ( a_pTRB )
292 {
293 auto iFilePathLength = TStringManager::String8Length( a_szFilePath );
294 auto iFileNamePos = iFilePathLength - 1;
295
296 while ( a_szFilePath[ iFileNamePos ] != '\\' && a_szFilePath[ iFileNamePos ] != '/' )
297 iFileNamePos--;
298
299 iFileNamePos++;
300
301 TCHAR symbolName[ 132 ];
302 auto iLen = iFilePathLength - iFileNamePos - 4;
303 TStringManager::String8Copy( symbolName, a_szFilePath + iFileNamePos, iFilePathLength - iFileNamePos - 4 );
304
305 symbolName[ iLen ] = '_';
306 symbolName[ iLen + 1 ] = '\0';
308 TStringManager::String8Copy( symbolName + iLen + 1, "TTL" );
309
310 auto pTTLData = a_pTRB->GetSymbolAddress( symbolName );
311
312 if ( pTTLData )
313 {
314 bSuccess = pLibrary->LoadTTLData( pTTLData );
315 }
316 else
317 {
318 bSuccess = pLibrary->LoadTTLFile( a_szFilePath );
319 }
320 }
321 else
322 {
323 bSuccess = pLibrary->LoadTTLFile( a_szFilePath );
324 }
325
326 if ( !bSuccess )
327 {
328 if ( pLibrary )
329 {
330 delete pLibrary;
331 pLibrary = TNULL;
332 }
333 }
334 else
335 {
336 m_Libraries.PushBack( pLibrary );
337 }
338
339 return pLibrary;
340}
#define TPROFILER_SCOPE()
Definition Profiler.h:17
char TCHAR
Definition Typedefs.h:20
#define TNULL
Definition Typedefs.h:23
bool TBOOL
Definition Typedefs.h:6
static void String8ToLowerCase(TCHAR *str)
static TSIZE String8Length(const TCHAR *str)
static TCHAR * String8Copy(TCHAR *dst, const TCHAR *src, TSIZE size=-1)

◆ CreateLibraryFromTRB()

AMaterialLibrary * AMaterialLibraryManager::List::CreateLibraryFromTRB ( Toshi::TTRB * a_pTRB,
const TCHAR * a_szFilePath )

Definition at line 265 of file AMaterialLibraryManager.cpp.

266{
268
269 auto pLibrary = new AMaterialLibrary;
270 pLibrary->SetPath( a_szFilePath );
271
272 if ( !pLibrary->LoadTRBFile( a_pTRB ) )
273 {
274 delete pLibrary;
275 return TNULL;
276 }
277
278 m_Libraries.PushBack( pLibrary );
279 return pLibrary;
280}

◆ DestroyLibrary()

void AMaterialLibraryManager::List::DestroyLibrary ( AMaterialLibrary * a_pLibrary)

Definition at line 343 of file AMaterialLibraryManager.cpp.

344{
345 TVALIDPTR( a_pLibrary );
346 a_pLibrary->Destroy();
347}
#define TVALIDPTR(PTR)
Definition Defines.h:139

◆ FindTexture()

ATexture * AMaterialLibraryManager::List::FindTexture ( const TCHAR * a_szTextureName,
AMaterialLibrary ** a_ppMaterialLibrary,
TINT * a_pTextureIndex )

Definition at line 349 of file AMaterialLibraryManager.cpp.

350{
351 TINT iIndex = -1;
352 auto it = m_Libraries.Begin();
353
354 while ( true )
355 {
356 if ( it == m_Libraries.End() )
357 {
358 return TNULL;
359 }
360
361 iIndex = it->FindTextureIndex( a_szTextureName );
362 if ( iIndex != -1 ) break;
363
364 it++;
365 }
366
367 if ( a_ppMaterialLibrary )
368 {
369 *a_ppMaterialLibrary = it;
370 }
371
372 if ( a_pTextureIndex )
373 {
374 *a_pTextureIndex = iIndex;
375 }
376
377 return it->GetTexture( iIndex );
378}
int TINT
Definition Typedefs.h:7

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