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

#include <TMaterial.h>

Inheritance diagram for TMaterial:
TObject

Public Types

enum  Flags_ : Flags {
  FLAGS_NONE = 0 , FLAGS_NO_CULL = BITFLAG( 0 ) , FLAGS_BLENDING = BITFLAG( 1 ) , FLAGS_UNK3 = BITFLAG( 2 ) ,
  FLAGS_GLOW = BITFLAG( 3 ) , FLAGS_CREATED = BITFLAG( 4 ) , FLAGS_NO_DEPTH_TEST = BITFLAG( 27 ) , FLAGS_ALPHAUPDATE = BITFLAG( 28 ) ,
  FLAGS_ALPHATEXTURE = BITFLAG( 31 )
}
 
typedef TUINT32 Flags
 
- Public Types inherited from TObject
enum  { IsTObject = TTRUE }
 

Public Member Functions

 TDECLARE_CLASS (TMaterial, TObject)
 
 TMaterial ()
 
 ~TMaterial ()
 
void Destroy ()
 
TShaderGetShader () const
 
void SetShader (TShader *a_pShader)
 
TTextureGetTexture (TUINT32 a_iStage=0) const
 
void SetTexture (TUINT32 a_iStage, TTexture *a_pTexture)
 
TUINT32 GetTextureNum () const
 
void SetTextureNum (TUINT32 a_iNumTextures)
 
void SetName (const TCHAR *a_szName)
 
void SetFlags (Flags a_eFlag, TBOOL a_bEnable)
 
TRegMaterialGetRegMaterial () const
 
void SetRegMaterial (TRegMaterial *a_pRegMaterial)
 
const TCHARGetName () const
 
TBOOL IsCreated () const
 
TRenderPacketAddRenderPacket (TMesh *a_pMesh)
 
- Public Member Functions inherited from TObject
virtual Toshi::TClass * GetClass ()
 
virtual void Delete ()
 
virtual ~TObject ()
 
TBOOL IsExactly (TClass *a_pClass)
 
TBOOL IsA (TClass *a_pClass)
 

Public Attributes

friend TRegMaterial
 

Static Public Attributes

static constexpr TUINT MAXTEXTURES = 6
 
static constexpr TUINT NAMESIZELIMIT = 31
 
- Static Public Attributes inherited from TObject
static constexpr Toshi::TClass * PARENTCLASS = TNULL
 
static constinit Toshi::TClass ms_oClass = Toshi::TClass( "TObject", TObject::CreateTObject, TObject::CreateTObjectInPlace, TObject::InitialiseClass, TObject::DeinitialiseClass, 0, 2, sizeof( TObject ), alignof( TObject ) )
 

Protected Member Functions

virtual void OnDestroy ()
 
virtual TBOOL Create ()
 
virtual void PreRender ()
 
virtual void PostRender ()
 

Protected Attributes

Flags m_Flags
 
TShaderm_pShader
 
TRegMaterialm_pRegMaterial
 
TUINT32 m_iNumTex
 
TTexturem_pTextures [MAXTEXTURES]
 
TCHAR m_szName [NAMESIZELIMIT+1]
 

Additional Inherited Members

- Static Public Member Functions inherited from TObject
static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE TClassGetClassStatic ()
 

Detailed Description

Definition at line 11 of file TMaterial.h.

Member Typedef Documentation

◆ Flags

Definition at line 20 of file TMaterial.h.

Member Enumeration Documentation

◆ Flags_

Enumerator
FLAGS_NONE 
FLAGS_NO_CULL 
FLAGS_BLENDING 
FLAGS_UNK3 
FLAGS_GLOW 
FLAGS_CREATED 
FLAGS_NO_DEPTH_TEST 
FLAGS_ALPHAUPDATE 
FLAGS_ALPHATEXTURE 

Definition at line 21 of file TMaterial.h.

22 {
23 FLAGS_NONE = 0,
26 FLAGS_UNK3 = BITFLAG( 2 ),
27 FLAGS_GLOW = BITFLAG( 3 ),
32 };
#define BITFLAG(x)
Definition Defines.h:10
@ FLAGS_CREATED
Definition TMaterial.h:28
@ FLAGS_BLENDING
Definition TMaterial.h:25
@ FLAGS_ALPHAUPDATE
Definition TMaterial.h:30
@ FLAGS_NO_CULL
Definition TMaterial.h:24
@ FLAGS_ALPHATEXTURE
Definition TMaterial.h:31
@ FLAGS_NO_DEPTH_TEST
Definition TMaterial.h:29

Constructor & Destructor Documentation

◆ TMaterial()

TMaterial::TMaterial ( )

Definition at line 16 of file TMaterial.cpp.

17{
20 m_iNumTex = 0;
23 m_szName[ 0 ] = '\0';
24}
#define TNULL
Definition Typedefs.h:23
TShader * m_pShader
Definition TMaterial.h:75
TTexture * m_pTextures[MAXTEXTURES]
Definition TMaterial.h:78
TRegMaterial * m_pRegMaterial
Definition TMaterial.h:76
TUINT32 m_iNumTex
Definition TMaterial.h:77
TCHAR m_szName[NAMESIZELIMIT+1]
Definition TMaterial.h:79
Flags m_Flags
Definition TMaterial.h:74
static void MemClear(void *ptr, TSIZE size)
Definition TUtil.h:91

◆ ~TMaterial()

TMaterial::~TMaterial ( )

Definition at line 28 of file TMaterial.cpp.

29{
30}

Member Function Documentation

◆ AddRenderPacket()

TRenderPacket * TMaterial::AddRenderPacket ( TMesh * a_pMesh)

Definition at line 131 of file TMaterial.cpp.

132{
133 TVALIDPTR( a_pMesh );
135
136 return m_pRegMaterial->AddRenderPacket( a_pMesh );
137}
#define TVALIDPTR(PTR)
Definition Defines.h:139

◆ Create()

TBOOL TMaterial::Create ( )
protectedvirtual

Definition at line 40 of file TMaterial.cpp.

41{
42 TASSERT( TFALSE == IsCreated() );
44 return TTRUE;
45}
#define TASSERT(X,...)
Definition Defines.h:138
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
TBOOL IsCreated() const

◆ Destroy()

void TMaterial::Destroy ( )

Definition at line 55 of file TMaterial.cpp.

56{
57 OnDestroy();
58 delete this;
59}
virtual void OnDestroy()
Definition TMaterial.cpp:33

◆ GetName()

const TCHAR * TMaterial::GetName ( ) const
inline

Definition at line 67 of file TMaterial.h.

67{ return m_szName; }

◆ GetRegMaterial()

TRegMaterial * TMaterial::GetRegMaterial ( ) const

Definition at line 144 of file TMaterial.cpp.

145{
146 return m_pRegMaterial;
147}

◆ GetShader()

TShader * TMaterial::GetShader ( ) const

Definition at line 67 of file TMaterial.cpp.

68{
69 return m_pShader;
70}

◆ GetTexture()

TTexture * TMaterial::GetTexture ( TUINT32 a_iStage = 0) const

Definition at line 89 of file TMaterial.cpp.

90{
91 return m_pTextures[ a_iStage ];
92}

◆ GetTextureNum()

TUINT32 TMaterial::GetTextureNum ( ) const

Definition at line 84 of file TMaterial.cpp.

85{
86 return m_iNumTex;
87}

◆ IsCreated()

TBOOL TMaterial::IsCreated ( ) const

Definition at line 126 of file TMaterial.cpp.

127{
128 return m_Flags & FLAGS_CREATED;
129}

◆ OnDestroy()

void TMaterial::OnDestroy ( )
protectedvirtual

Definition at line 33 of file TMaterial.cpp.

34{
35 TASSERT( TTRUE == IsCreated() );
37}

◆ PostRender()

void TMaterial::PostRender ( )
protectedvirtual

Definition at line 51 of file TMaterial.cpp.

52{
53}

◆ PreRender()

void TMaterial::PreRender ( )
protectedvirtual

Definition at line 47 of file TMaterial.cpp.

48{
49}

◆ SetFlags()

void TMaterial::SetFlags ( Flags a_eFlag,
TBOOL a_bEnable )

Definition at line 109 of file TMaterial.cpp.

110{
111 if ( set )
112 {
113 if ( flag & ( FLAGS_NO_CULL | FLAGS_BLENDING | FLAGS_UNK3 ) )
114 {
116 }
117
118 m_Flags |= flag;
119 }
120 else
121 {
122 m_Flags &= ~flag;
123 }
124}

◆ SetName()

void TMaterial::SetName ( const TCHAR * a_szName)

Definition at line 95 of file TMaterial.cpp.

96{
97 if ( a_szName == TNULL )
98 m_szName[ 0 ] = '\0';
99
100 TINT iNameLen = TStringManager::String8Length( a_szName );
101
102 if ( NAMESIZELIMIT - 1 < iNameLen )
103 TUtil::Log( "[ERROR] %s is to long, needs to be less then %d characters\n", a_szName, NAMESIZELIMIT );
104
106}
int TINT
Definition Typedefs.h:7
static constexpr TUINT NAMESIZELIMIT
Definition TMaterial.h:18
static TSIZE String8Length(const TCHAR *str)
static TCHAR * String8Copy(TCHAR *dst, const TCHAR *src, TSIZE size=-1)
static void Log(const TCHAR *a_szFormat,...)
Definition TUtil.cpp:65

◆ SetRegMaterial()

void TMaterial::SetRegMaterial ( TRegMaterial * a_pRegMaterial)

Definition at line 139 of file TMaterial.cpp.

140{
141 m_pRegMaterial = pRegMaterial;
142}

◆ SetShader()

void TMaterial::SetShader ( TShader * a_pShader)

Definition at line 61 of file TMaterial.cpp.

62{
64 m_pShader = pShader;
65}

◆ SetTexture()

void TMaterial::SetTexture ( TUINT32 a_iStage,
TTexture * a_pTexture )

Definition at line 78 of file TMaterial.cpp.

79{
80 TASSERT( a_iStage < MAXTEXTURES );
81 m_pTextures[ a_iStage ] = a_pTexture;
82}
static constexpr TUINT MAXTEXTURES
Definition TMaterial.h:17

◆ SetTextureNum()

void TMaterial::SetTextureNum ( TUINT32 a_iNumTextures)

Definition at line 72 of file TMaterial.cpp.

73{
74 TASSERT( a_iNumTextures <= MAXTEXTURES );
75 m_iNumTex = a_iNumTextures;
76}

◆ TDECLARE_CLASS()

TMaterial::TDECLARE_CLASS ( TMaterial ,
TObject  )

Member Data Documentation

◆ m_Flags

Flags TMaterial::m_Flags
protected

Definition at line 74 of file TMaterial.h.

◆ m_iNumTex

TUINT32 TMaterial::m_iNumTex
protected

Definition at line 77 of file TMaterial.h.

◆ m_pRegMaterial

TRegMaterial* TMaterial::m_pRegMaterial
protected

Definition at line 76 of file TMaterial.h.

◆ m_pShader

TShader* TMaterial::m_pShader
protected

Definition at line 75 of file TMaterial.h.

◆ m_pTextures

TTexture* TMaterial::m_pTextures[MAXTEXTURES]
protected

Definition at line 78 of file TMaterial.h.

◆ m_szName

TCHAR TMaterial::m_szName[NAMESIZELIMIT+1]
protected

Definition at line 79 of file TMaterial.h.

◆ MAXTEXTURES

TUINT TMaterial::MAXTEXTURES = 6
staticconstexpr

Definition at line 17 of file TMaterial.h.

◆ NAMESIZELIMIT

TUINT TMaterial::NAMESIZELIMIT = 31
staticconstexpr

Definition at line 18 of file TMaterial.h.

◆ TRegMaterial

friend TMaterial::TRegMaterial

Definition at line 34 of file TMaterial.h.


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