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/warp_overlay.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/warp_overlay.cpp')
| -rw-r--r-- | game/client/warp_overlay.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/game/client/warp_overlay.cpp b/game/client/warp_overlay.cpp new file mode 100644 index 0000000..f851fac --- /dev/null +++ b/game/client/warp_overlay.cpp @@ -0,0 +1,95 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Screen warp overlay +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "view.h" +#include "c_sun.h" +#include "particles_simple.h" +#include "clienteffectprecachesystem.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +CLIENTEFFECT_REGISTER_BEGIN( PrecacheEffectWarp ) +CLIENTEFFECT_MATERIAL( "sun/overlay" ) +CLIENTEFFECT_REGISTER_END() + +//----------------------------------------------------------------------------- +// Purpose: Special draw for the warped overlay +//----------------------------------------------------------------------------- +void CWarpOverlay::Draw( bool bCacheFullSceneState ) +{ + // Get the vector to the sun. + Vector vToGlow; + + if( m_bDirectional ) + vToGlow = m_vDirection; + else + vToGlow = m_vPos - CurrentViewOrigin(); + + VectorNormalize( vToGlow ); + + float flDot = vToGlow.Dot( CurrentViewForward() ); + + if( flDot <= g_flOverlayRange ) + return; + + UpdateGlowObstruction( vToGlow, bCacheFullSceneState ); + if( m_flGlowObstructionScale == 0 ) + return; + + CMatRenderContextPtr pRenderContext( materials ); + + //FIXME: Allow multiple? + for( int iSprite=0; iSprite < m_nSprites; iSprite++ ) + { + CGlowSprite *pSprite = &m_Sprites[iSprite]; + + // Figure out the color and size to draw it. + float flHorzSize, flVertSize; + Vector vColor; + CalcSpriteColorAndSize( flDot, pSprite, &flHorzSize, &flVertSize, &vColor ); + + // Setup the basis to draw the sprite. + Vector vBasePt, vUp, vRight; + CalcBasis( vToGlow, flHorzSize, flVertSize, vBasePt, vUp, vRight ); + + // Draw the sprite. + IMaterial *pMaterial = materials->FindMaterial( "sun/overlay", TEXTURE_GROUP_CLIENT_EFFECTS ); + IMesh *pMesh = pRenderContext->GetDynamicMesh( false, 0, 0, pMaterial ); + + CMeshBuilder builder; + builder.Begin( pMesh, MATERIAL_QUADS, 1 ); + + Vector vPt; + + vPt = vBasePt - vRight + vUp; + builder.Position3fv( vPt.Base() ); + builder.Color4f( VectorExpand(vColor), 1 ); + builder.TexCoord2f( 0, 0, 1 ); + builder.AdvanceVertex(); + + vPt = vBasePt + vRight + vUp; + builder.Position3fv( vPt.Base() ); + builder.Color4f( VectorExpand(vColor), 1 ); + builder.TexCoord2f( 0, 1, 1 ); + builder.AdvanceVertex(); + + vPt = vBasePt + vRight - vUp; + builder.Position3fv( vPt.Base() ); + builder.Color4f( VectorExpand(vColor), 1 ); + builder.TexCoord2f( 0, 1, 0 ); + builder.AdvanceVertex(); + + vPt = vBasePt - vRight - vUp; + builder.Position3fv( vPt.Base() ); + builder.Color4f( VectorExpand(vColor), 1 ); + builder.TexCoord2f( 0, 0, 0 ); + builder.AdvanceVertex(); + + builder.End( false, true ); + } +} |