diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/client/thermalmaterialproxy.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/client/thermalmaterialproxy.cpp')
| -rw-r--r-- | mp/src/game/client/thermalmaterialproxy.cpp | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/mp/src/game/client/thermalmaterialproxy.cpp b/mp/src/game/client/thermalmaterialproxy.cpp index 188c7558..9386294c 100644 --- a/mp/src/game/client/thermalmaterialproxy.cpp +++ b/mp/src/game/client/thermalmaterialproxy.cpp @@ -1,105 +1,105 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-#include "cbase.h"
-#include "proxyentity.h"
-#include "materialsystem/imaterial.h"
-#include "materialsystem/imaterialvar.h"
-
-void HueToRGB( float frac, Vector& color );
-
-// $ThermalVar : name of variable to run Thermal wave on (can either be a color or a float)
-// $ThermalPeriod: time that it takes to go through whole Thermal wave in seconds (default: 1.0f)
-// $ThermalMax : the max value for the Thermal wave (default: 1.0f )
-// $ThermalMin: the min value for the Thermal wave (default: 0.0f )
-class CThermalMaterialProxy : public CEntityMaterialProxy
-{
-public:
- CThermalMaterialProxy();
- virtual ~CThermalMaterialProxy();
- virtual bool Init( IMaterial *pMaterial, KeyValues* pKeyValues );
- virtual void OnBind( C_BaseEntity *pEntity );
-
-private:
- IMaterialVar *m_ThermalVar;
- IMaterialVar *m_ThermalPeriod;
- IMaterialVar *m_ThermalMax;
- IMaterialVar *m_ThermalMin;
-};
-
-CThermalMaterialProxy::CThermalMaterialProxy()
-{
- m_ThermalVar = NULL;
- m_ThermalPeriod = NULL;
- m_ThermalMax = NULL;
- m_ThermalMin = NULL;
-}
-
-CThermalMaterialProxy::~CThermalMaterialProxy()
-{
-}
-
-
-bool CThermalMaterialProxy::Init( IMaterial *pMaterial, KeyValues* pKeyValues )
-{
- bool foundVar;
-
- m_ThermalVar = pMaterial->FindVar( "$color", &foundVar, false );
- if( !foundVar )
- {
- m_ThermalVar = NULL;
- return false;
- }
-
- m_ThermalPeriod = pMaterial->FindVar( "$ThermalPeriod", &foundVar, false );
- if( !foundVar )
- {
- m_ThermalPeriod = NULL;
- }
-
- m_ThermalMax = pMaterial->FindVar( "$ThermalMax", &foundVar, false );
- if( !foundVar )
- {
- m_ThermalMax = NULL;
- }
-
- m_ThermalMin = pMaterial->FindVar( "$ThermalMin", &foundVar, false );
- if( !foundVar )
- {
- m_ThermalMin = NULL;
- }
- return true;
-}
-
-void CThermalMaterialProxy::OnBind( C_BaseEntity *pEntity )
-{
-// FIXME, enable this later
-return;
-
- if( !m_ThermalVar )
- {
- return;
- }
-
- float min, max, period, value;
-
- // set default values if these variables don't exist.
- min = m_ThermalMin ? m_ThermalMin->GetFloatValue() : 0.0f;
- max = m_ThermalMax ? m_ThermalMax->GetFloatValue() : 1.0f;
- period = m_ThermalPeriod ? m_ThermalPeriod->GetFloatValue() : 1.0f;
-
- // get a value in [0,1]
- value = ( sin( 2.0f * M_PI * gpGlobals->curtime / period ) * 0.5f ) + 0.5f;
- // get a value in [min,max]
- value = ( max - min ) * value + min;
-
- Vector color;
- HueToRGB( 360.f * value, color );
-
- m_ThermalVar->SetVecValue( color[0], color[1], color[2] );
-}
-
-EXPOSE_INTERFACE( CThermalMaterialProxy, IMaterialProxy, "Thermal" IMATERIAL_PROXY_INTERFACE_VERSION );
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "proxyentity.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/imaterialvar.h" + +void HueToRGB( float frac, Vector& color ); + +// $ThermalVar : name of variable to run Thermal wave on (can either be a color or a float) +// $ThermalPeriod: time that it takes to go through whole Thermal wave in seconds (default: 1.0f) +// $ThermalMax : the max value for the Thermal wave (default: 1.0f ) +// $ThermalMin: the min value for the Thermal wave (default: 0.0f ) +class CThermalMaterialProxy : public CEntityMaterialProxy +{ +public: + CThermalMaterialProxy(); + virtual ~CThermalMaterialProxy(); + virtual bool Init( IMaterial *pMaterial, KeyValues* pKeyValues ); + virtual void OnBind( C_BaseEntity *pEntity ); + +private: + IMaterialVar *m_ThermalVar; + IMaterialVar *m_ThermalPeriod; + IMaterialVar *m_ThermalMax; + IMaterialVar *m_ThermalMin; +}; + +CThermalMaterialProxy::CThermalMaterialProxy() +{ + m_ThermalVar = NULL; + m_ThermalPeriod = NULL; + m_ThermalMax = NULL; + m_ThermalMin = NULL; +} + +CThermalMaterialProxy::~CThermalMaterialProxy() +{ +} + + +bool CThermalMaterialProxy::Init( IMaterial *pMaterial, KeyValues* pKeyValues ) +{ + bool foundVar; + + m_ThermalVar = pMaterial->FindVar( "$color", &foundVar, false ); + if( !foundVar ) + { + m_ThermalVar = NULL; + return false; + } + + m_ThermalPeriod = pMaterial->FindVar( "$ThermalPeriod", &foundVar, false ); + if( !foundVar ) + { + m_ThermalPeriod = NULL; + } + + m_ThermalMax = pMaterial->FindVar( "$ThermalMax", &foundVar, false ); + if( !foundVar ) + { + m_ThermalMax = NULL; + } + + m_ThermalMin = pMaterial->FindVar( "$ThermalMin", &foundVar, false ); + if( !foundVar ) + { + m_ThermalMin = NULL; + } + return true; +} + +void CThermalMaterialProxy::OnBind( C_BaseEntity *pEntity ) +{ +// FIXME, enable this later +return; + + if( !m_ThermalVar ) + { + return; + } + + float min, max, period, value; + + // set default values if these variables don't exist. + min = m_ThermalMin ? m_ThermalMin->GetFloatValue() : 0.0f; + max = m_ThermalMax ? m_ThermalMax->GetFloatValue() : 1.0f; + period = m_ThermalPeriod ? m_ThermalPeriod->GetFloatValue() : 1.0f; + + // get a value in [0,1] + value = ( sin( 2.0f * M_PI * gpGlobals->curtime / period ) * 0.5f ) + 0.5f; + // get a value in [min,max] + value = ( max - min ) * value + min; + + Vector color; + HueToRGB( 360.f * value, color ); + + m_ThermalVar->SetVecValue( color[0], color[1], color[2] ); +} + +EXPOSE_INTERFACE( CThermalMaterialProxy, IMaterialProxy, "Thermal" IMATERIAL_PROXY_INTERFACE_VERSION ); |