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

#include <ASkinMaterial_DX8.h>

Inheritance diagram for ASkinMaterialHAL:
ASkinMaterial

Public Member Functions

 TDECLARE_CLASS (ASkinMaterialHAL, ASkinMaterial)
 
 ASkinMaterialHAL ()
 
 ~ASkinMaterialHAL ()
 
virtual void OnDestroy () override
 
virtual void PreRender () override
 
virtual void PostRender () override
 
virtual TBOOL Create (BLENDMODE a_eBlendMode) override
 
virtual void SetBlendMode (BLENDMODE a_eBlendMode) override
 
virtual void CopyToAlphaBlendMaterial ()
 
void SetOrderTable (Toshi::TOrderTable *a_pOrderTable)
 
ASkinMaterialHALGetAlphaBlendMaterial () const
 
void SetAlphaBlendMaterial (ASkinMaterialHAL *val)
 
TBOOL IsHDLighting () const
 
void SetHDLighting (TBOOL a_bIsHDLighting)
 
TBOOL HasLighting1Tex () const
 
TBOOL HasLighting2Tex () const
 
Toshi::TTextureResourceHAL * GetLightingTexture (ELightingTexture a_eTexture) const
 
Toshi::TTextureResourceHAL * GetSomeTexture () const
 
- Public Member Functions inherited from ASkinMaterial
 ASkinMaterial ()
 
 ~ASkinMaterial ()
 
BLENDMODE GetBlendMode () const
 
void SetTexture (Toshi::TTexture *a_pTexture)
 
void SetLightingTexture (ELightingTexture a_eTex, Toshi::TTexture *a_pTexture)
 

Additional Inherited Members

- Public Types inherited from ASkinMaterial
enum  ELightingTexture_ : ELightingTexture {
  LT_0 , LT_1 , LT_2 , LT_3 ,
  LT_NUMOF
}
 
using ELightingTexture = TUINT
 
using BLENDMODE = TUINT
 
- Protected Attributes inherited from ASkinMaterial
Toshi::TTexture * m_pTexture
 
Toshi::TTexture * m_apLightingTextures [LT_NUMOF]
 
BLENDMODE m_eBlendMode
 
TBOOL m_bFlag
 

Detailed Description

Definition at line 7 of file ASkinMaterial_DX8.h.

Constructor & Destructor Documentation

◆ ASkinMaterialHAL()

ASkinMaterialHAL::ASkinMaterialHAL ( )

Definition at line 19 of file ASkinMaterial_DX8.cpp.

20 : m_pAlphaBlendMaterial( TNULL ), m_pAssignedOrderTable( TNULL ), m_pSomeTexture( TNULL ), m_bIsHDLighting( TTRUE )
21{
22}
#define TNULL
Definition Typedefs.h:23
#define TTRUE
Definition Typedefs.h:25

◆ ~ASkinMaterialHAL()

ASkinMaterialHAL::~ASkinMaterialHAL ( )

Definition at line 24 of file ASkinMaterial_DX8.cpp.

25{
26 if ( TNULL != m_pRegMaterial )
27 {
28 TOrderTable::DeregisterMaterial( m_pRegMaterial );
29 }
30
31 if ( TNULL != m_pAlphaBlendMaterial )
32 {
33 delete m_pAlphaBlendMaterial;
34 }
35}
static void DeregisterMaterial(TRegMaterial *a_pRegMat)

Member Function Documentation

◆ CopyToAlphaBlendMaterial()

void ASkinMaterialHAL::CopyToAlphaBlendMaterial ( )
virtual

Definition at line 204 of file ASkinMaterial_DX8.cpp.

205{
206 if ( TNULL != m_pAlphaBlendMaterial )
207 {
208 m_pAlphaBlendMaterial->m_iNumTex = m_iNumTex;
209 m_pAlphaBlendMaterial->m_pTexture = m_pTexture;
210 m_pAlphaBlendMaterial->m_apLightingTextures[ LT_0 ] = m_apLightingTextures[ LT_0 ];
211 m_pAlphaBlendMaterial->m_apLightingTextures[ LT_1 ] = m_apLightingTextures[ LT_1 ];
212 m_pAlphaBlendMaterial->m_apLightingTextures[ LT_2 ] = m_apLightingTextures[ LT_2 ];
213 m_pAlphaBlendMaterial->m_apLightingTextures[ LT_3 ] = m_apLightingTextures[ LT_3 ];
214
215 m_pAlphaBlendMaterial->SetFlags( TMaterial::FLAGS_BLENDING, TTRUE );
216 }
217}
@ FLAGS_BLENDING
Definition TMaterial.h:25
Toshi::TTexture * m_pTexture
Toshi::TTexture * m_apLightingTextures[LT_NUMOF]

◆ Create()

TBOOL ASkinMaterialHAL::Create ( BLENDMODE a_eBlendMode)
overridevirtual

Reimplemented from ASkinMaterial.

Definition at line 169 of file ASkinMaterial_DX8.cpp.

170{
171 SetBlendMode( a_eBlendMode );
172 return BaseClass::Create( a_eBlendMode );
173}
virtual void SetBlendMode(BLENDMODE a_eBlendMode) override

◆ GetAlphaBlendMaterial()

ASkinMaterialHAL * ASkinMaterialHAL::GetAlphaBlendMaterial ( ) const
inline

Definition at line 36 of file ASkinMaterial_DX8.h.

36{ return m_pAlphaBlendMaterial; }

◆ GetLightingTexture()

Toshi::TTextureResourceHAL * ASkinMaterialHAL::GetLightingTexture ( ELightingTexture a_eTexture) const

Definition at line 237 of file ASkinMaterial_DX8.cpp.

238{
239 TASSERT( a_eTexture < LT_NUMOF );
240 return TDYNAMICCAST( TTextureResourceHAL, m_apLightingTextures[ a_eTexture ] );
241}
#define TASSERT(X,...)
Definition Defines.h:138
#define TDYNAMICCAST(T, OBJECT)
Definition TObject.h:227

◆ GetSomeTexture()

Toshi::TTextureResourceHAL * ASkinMaterialHAL::GetSomeTexture ( ) const

Definition at line 243 of file ASkinMaterial_DX8.cpp.

244{
245 return TDYNAMICCAST( TTextureResourceHAL, m_pSomeTexture );
246}

◆ HasLighting1Tex()

TBOOL ASkinMaterialHAL::HasLighting1Tex ( ) const
inline

Definition at line 41 of file ASkinMaterial_DX8.h.

41{ return m_bHasLighting1Tex; }

◆ HasLighting2Tex()

TBOOL ASkinMaterialHAL::HasLighting2Tex ( ) const
inline

Definition at line 42 of file ASkinMaterial_DX8.h.

42{ return m_bHasLighting2Tex; }

◆ IsHDLighting()

TBOOL ASkinMaterialHAL::IsHDLighting ( ) const
inline

Definition at line 39 of file ASkinMaterial_DX8.h.

39{ return m_bIsHDLighting; }

◆ OnDestroy()

void ASkinMaterialHAL::OnDestroy ( )
overridevirtual

Definition at line 37 of file ASkinMaterial_DX8.cpp.

38{
39 if ( m_pAssignedOrderTable )
40 {
41 TOrderTable::DeregisterMaterial( m_pRegMaterial );
42 m_pAssignedOrderTable = TNULL;
43 }
44
45 BaseClass::OnDestroy();
46}

◆ PostRender()

void ASkinMaterialHAL::PostRender ( )
overridevirtual

Definition at line 145 of file ASkinMaterial_DX8.cpp.

146{
147 auto pRender = TRenderD3DInterface::Interface();
148 auto pD3DDevice = pRender->GetDirect3DDevice();
149 auto pShader = TDYNAMICCAST( ASkinShaderHAL, GetShader() );
150
151 pD3DDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
152 pD3DDevice->SetTexture( 0, TNULL );
153 pD3DDevice->SetTexture( 1, TNULL );
154 pD3DDevice->SetTexture( 2, TNULL );
155 pD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
156 pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
157
158 pShader->SetAlphaRef( 128 );
159
160 if ( m_Flags & FLAGS_NO_CULL )
161 {
162 pD3DDevice->SetRenderState( D3DRS_CULLMODE, pShader->IsEnableRenderEnvMap() ? D3DCULL_CCW : D3DCULL_CW );
163 }
164
165 pD3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
167}
static TFORCEINLINE TRenderD3DInterface * Interface()
Gets the render interface singleton.
static TUINT sm_eRenderStateFlags

◆ PreRender()

void ASkinMaterialHAL::PreRender ( )
overridevirtual

Definition at line 48 of file ASkinMaterial_DX8.cpp.

49{
50 auto pRender = TRenderD3DInterface::Interface();
51 auto pD3DDevice = pRender->GetDirect3DDevice();
52
53 TTextureResourceHAL* pTexture = TDYNAMICCAST( TTextureResourceHAL, m_pTexture );
54 TTextureResourceHAL* pLT0Texture = TNULL;
55 TTextureResourceHAL* pLT1Texture = TNULL;
56
58
59 if ( m_bIsHDLighting )
60 {
61 pLT0Texture = TDYNAMICCAST( TTextureResourceHAL, m_apLightingTextures[ LT_0 ] );
62 pLT1Texture = TDYNAMICCAST( TTextureResourceHAL, m_apLightingTextures[ LT_1 ] );
63
64 pRender->SetTextureAddress( 1, ADDRESSINGMODE_CLAMP, TEXCOORD_UV );
65 pRender->SetTextureAddress( 2, ADDRESSINGMODE_CLAMP, TEXCOORD_UV );
66 pRender->SetTextureAddress( 3, ADDRESSINGMODE_CLAMP, TEXCOORD_UV );
67 pRender->SetTextureAddress( 4, ADDRESSINGMODE_CLAMP, TEXCOORD_UV );
68
69 pD3DDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, 2 );
70 pD3DDevice->SetTextureStageState( 2, D3DTSS_MAGFILTER, 2 );
71 pD3DDevice->SetTextureStageState( 3, D3DTSS_MAGFILTER, 2 );
72 pD3DDevice->SetTextureStageState( 4, D3DTSS_MAGFILTER, 2 );
73
74 m_bHasLighting1Tex = pLT0Texture != TNULL;
75 m_bHasLighting2Tex = pLT1Texture != TNULL;
76 }
77
78 if ( pTexture != TNULL )
79 {
80 pTexture->Validate();
81
82 if ( pTexture->GetD3DTexture() != TNULL )
83 {
84 pD3DDevice->SetTexture( 0, pTexture->GetD3DTexture() );
85
86 if ( pLT1Texture == TNULL )
87 {
88 pD3DDevice->SetTexture( 1, TNULL );
89 pD3DDevice->SetTexture( 2, TNULL );
90 }
91 else
92 {
93 pD3DDevice->SetTexture( 1, pLT1Texture->GetD3DTexture() );
94 pD3DDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, 0 );
95
96 if ( pLT0Texture == TNULL )
97 {
98 pD3DDevice->SetTexture( 2, TNULL );
99 }
100 else
101 {
102 pD3DDevice->SetTexture( 2, pLT0Texture->GetD3DTexture() );
103 pD3DDevice->SetTextureStageState( 2, D3DTSS_MIPFILTER, 0 );
104 }
105 }
106
107 pD3DDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, 2 );
108 pRender->SetTextureAddress( 0, pTexture->GetAddressUState(), TEXCOORD_U );
109 pRender->SetTextureAddress( 0, pTexture->GetAddressVState(), TEXCOORD_V );
110 }
111 }
112 else
113 {
114 pD3DDevice->SetTexture( 0, TNULL );
115 }
116
117 if ( m_eBlendMode == 0 || m_eBlendMode == 1 || m_eBlendMode != 3 )
118 {
119 pD3DDevice->SetRenderState( D3DRS_SRCBLEND, 5 );
120 pD3DDevice->SetRenderState( D3DRS_DESTBLEND, 6 );
121 pD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
122 }
123 else
124 {
125 pD3DDevice->SetRenderState( D3DRS_SRCBLEND, 5 );
126 pD3DDevice->SetRenderState( D3DRS_DESTBLEND, 2 );
127 pD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
128 }
129
130 if ( m_Flags & FLAGS_NO_CULL )
131 pD3DDevice->SetRenderState( D3DRS_CULLMODE, 1 );
132
133 auto pShader = TDYNAMICCAST( ASkinShaderHAL, GetShader() );
134 pShader->SetAlphaRef( ( m_Flags & FLAGS_BLENDING ) ? 1 : 128 );
135
136 pD3DDevice->SetRenderState( D3DRS_COLORVERTEX, 0 );
137 pD3DDevice->SetRenderState( D3DRS_CULLMODE, 1 );
138
139 auto pRenderContext = TRenderContextD3D::Upcast( pRender->GetCurrentContext() );
140
141 if ( pRenderContext->IsFogEnabled() )
142 pRenderContext->EnableFogHAL();
143}
@ ADDRESSINGMODE_CLAMP
Definition TRender.h:42
@ TEXCOORD_UV
Definition TRender.h:29
@ TEXCOORD_U
Definition TRender.h:30
@ TEXCOORD_V
Definition TRender.h:31
static TRenderContextD3D * Upcast(TRenderContext *a_pRenderContext)
IDirect3DTexture8 * GetD3DTexture()
virtual TBOOL Validate() override
ADDRESSINGMODE GetAddressUState() const
ADDRESSINGMODE GetAddressVState() const
BLENDMODE m_eBlendMode

◆ SetAlphaBlendMaterial()

void ASkinMaterialHAL::SetAlphaBlendMaterial ( ASkinMaterialHAL * val)
inline

Definition at line 37 of file ASkinMaterial_DX8.h.

37{ m_pAlphaBlendMaterial = val; }

◆ SetBlendMode()

void ASkinMaterialHAL::SetBlendMode ( BLENDMODE a_eBlendMode)
overridevirtual

Reimplemented from ASkinMaterial.

Definition at line 175 of file ASkinMaterial_DX8.cpp.

176{
177 auto pShader = TDYNAMICCAST( ASkinShaderHAL, GetShader() );
178
179 switch ( a_eBlendMode )
180 {
181 case 0:
182 SetOrderTable( pShader->GetOrderTable( 0 ) );
183 break;
184 case 1:
185 case 5:
186 SetOrderTable( pShader->GetOrderTable( 1 ) );
187 break;
188 case 2:
189 case 6:
190 SetOrderTable( pShader->GetOrderTable( 1 ) );
191 break;
192 case 3:
193 case 4:
194 SetOrderTable( pShader->GetOrderTable( 1 ) );
195 break;
196 case 7:
197 SetOrderTable( pShader->GetOrderTable( 2 ) );
198 break;
199 }
200
201 BaseClass::SetBlendMode( a_eBlendMode );
202}
void SetOrderTable(Toshi::TOrderTable *a_pOrderTable)

◆ SetHDLighting()

void ASkinMaterialHAL::SetHDLighting ( TBOOL a_bIsHDLighting)
inline

Definition at line 40 of file ASkinMaterial_DX8.h.

40{ m_bIsHDLighting = a_bIsHDLighting; }

◆ SetOrderTable()

void ASkinMaterialHAL::SetOrderTable ( Toshi::TOrderTable * a_pOrderTable)

Definition at line 219 of file ASkinMaterial_DX8.cpp.

220{
221 if ( a_pOrderTable != m_pAssignedOrderTable )
222 {
223 if ( m_pAssignedOrderTable )
224 {
225 TOrderTable::DeregisterMaterial( GetRegMaterial() );
226 }
227
228 if ( a_pOrderTable )
229 {
230 a_pOrderTable->RegisterMaterial( this );
231 }
232
233 m_pAssignedOrderTable = a_pOrderTable;
234 }
235}

◆ TDECLARE_CLASS()

ASkinMaterialHAL::TDECLARE_CLASS ( ASkinMaterialHAL ,
ASkinMaterial  )

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