diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf2/ztestmaterialproxy.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'game/client/tf2/ztestmaterialproxy.cpp')
| -rw-r--r-- | game/client/tf2/ztestmaterialproxy.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/game/client/tf2/ztestmaterialproxy.cpp b/game/client/tf2/ztestmaterialproxy.cpp new file mode 100644 index 0000000..102cd34 --- /dev/null +++ b/game/client/tf2/ztestmaterialproxy.cpp @@ -0,0 +1,64 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "materialsystem/imaterialproxy.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/imaterialvar.h" + +// $sineVar : name of variable that controls the alpha level (float) +class CzTestMaterialProxy : public IMaterialProxy +{ +public: + CzTestMaterialProxy(); + virtual ~CzTestMaterialProxy(); + virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues ); + virtual void OnBind( void *pC_BaseEntity ); + virtual void Release( void ) { delete this; } +private: + C_BaseEntity *BindArgToEntity( void *pArg ); + + IMaterialVar *m_AlphaVar; +}; + +CzTestMaterialProxy::CzTestMaterialProxy() +{ + m_AlphaVar = NULL; +} + +CzTestMaterialProxy::~CzTestMaterialProxy() +{ +} + +C_BaseEntity *CzTestMaterialProxy::BindArgToEntity( void *pArg ) +{ + IClientRenderable *pRend = (IClientRenderable *)pArg; + return pRend->GetIClientUnknown()->GetBaseEntity(); +} + +bool CzTestMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues ) +{ + bool foundVar; + m_AlphaVar = pMaterial->FindVar( "$alpha", &foundVar, false ); + return foundVar; +} + +void CzTestMaterialProxy::OnBind( void *pC_BaseEntity ) +{ + C_BaseEntity *pEnt = BindArgToEntity( pC_BaseEntity ); + if( !pEnt ) + { + return; + } + + if (m_AlphaVar) + { + m_AlphaVar->SetFloatValue( pEnt->m_clrRender.a ); + } + +} + +EXPOSE_INTERFACE( CzTestMaterialProxy, IMaterialProxy, "zTest" IMATERIAL_PROXY_INTERFACE_VERSION ); |