OpenBarnyard
 
Loading...
Searching...
No Matches
ASkinMesh_DX8.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "ASkinMesh_DX8.h"
3#include "ASkinShader_DX8.h"
4#include "ASkinMaterial_DX8.h"
5
9
10//-----------------------------------------------------------------------------
11// Enables memory debugging.
12// Note: Should be the last include!
13//-----------------------------------------------------------------------------
14#include <Core/TMemoryDebugOn.h>
15
17
19
20// $Barnyard: FUNCTION 005f3f20
22{
23 auto pRenderInterface = TRenderD3DInterface::Interface();
24 auto pCurrentContext = TRenderContextD3D::Upcast( pRenderInterface->GetCurrentContext() );
25
26 if ( TSkeletonInstance* pSkeletonInstance = pCurrentContext->GetSkeletonInstance() )
27 {
28 TMaterial* pMaterial;
29
30 if ( !TDYNAMICCAST( ASkinShaderHAL, m_pOwnerShader )->IsAlphaBlendMaterial() ||
31 pCurrentContext->GetAlphaBlend() >= 1.0f )
32 {
33 pMaterial = TDYNAMICCAST( ASkinMaterialHAL, m_pMaterial );
34 }
35 else
36 {
37 pMaterial = TDYNAMICCAST( ASkinMaterialHAL, m_pMaterial )->GetAlphaBlendMaterial();
38 }
39
40 auto pRenderPacket = pMaterial->AddRenderPacket( this );
41 pRenderPacket->SetModelViewMatrix( pCurrentContext->GetModelViewMatrix() );
42 pRenderPacket->SetSkeletonInstance( pSkeletonInstance );
43 pRenderPacket->SetAmbientColour( pCurrentContext->GetAmbientColour().AsVector3() );
44 pRenderPacket->SetLightColour( pRenderInterface->GetLightColour().AsBasisVector3( 0 ) );
45 pRenderPacket->SetLightDirection( pRenderInterface->GetLightDirection().AsBasisVector3( 0 ) );
46 pRenderPacket->SetAlpha( pCurrentContext->GetAlphaBlend() );
47 pRenderPacket->SetShadeCoeff( TUINT( pCurrentContext->GetShadeCoeff() * 255.0f ) );
48
49 ASkinShaderHAL::sm_oWorldViewMatrix = pCurrentContext->GetWorldViewMatrix();
50 ASkinShaderHAL::sm_oViewModelMatrix = pCurrentContext->GetViewModelMatrix();
51 }
52
53 return TTRUE;
54}
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define TDYNAMICCAST(T, OBJECT)
Definition TObject.h:227
#define TDEFINE_CLASS(...)
Definition TObject.h:120
unsigned int TUINT
Definition Typedefs.h:8
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
static TRenderContextD3D * Upcast(TRenderContext *a_pRenderContext)
static TFORCEINLINE TRenderD3DInterface * Interface()
Gets the render interface singleton.
virtual TBOOL Render() override
static Toshi::TMatrix44 sm_oViewModelMatrix
static Toshi::TMatrix44 sm_oWorldViewMatrix