Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Screen warp overlay
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "view.h"
  9. #include "c_sun.h"
  10. #include "particles_simple.h"
  11. #include "precache_register.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. PRECACHE_REGISTER_BEGIN( GLOBAL, PrecacheEffectWarp )
  15. PRECACHE( MATERIAL, "sun/overlay" )
  16. PRECACHE_REGISTER_END()
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Special draw for the warped overlay
  19. //-----------------------------------------------------------------------------
  20. void CWarpOverlay::Draw( bool bCacheFullSceneState )
  21. {
  22. // Get the vector to the sun.
  23. Vector vToGlow;
  24. if( m_bDirectional )
  25. vToGlow = m_vDirection;
  26. else
  27. vToGlow = m_vPos - CurrentViewOrigin();
  28. VectorNormalize( vToGlow );
  29. float flDot = vToGlow.Dot( CurrentViewForward() );
  30. if( flDot <= g_flOverlayRange )
  31. return;
  32. UpdateGlowObstruction( vToGlow, bCacheFullSceneState );
  33. if( m_flGlowObstructionScale == 0 )
  34. return;
  35. CMatRenderContextPtr pRenderContext( materials );
  36. //FIXME: Allow multiple?
  37. for( int iSprite=0; iSprite < m_nSprites; iSprite++ )
  38. {
  39. CGlowSprite *pSprite = &m_Sprites[iSprite];
  40. // Figure out the color and size to draw it.
  41. float flHorzSize, flVertSize;
  42. Vector vColor;
  43. CalcSpriteColorAndSize( flDot, pSprite, &flHorzSize, &flVertSize, &vColor );
  44. // Setup the basis to draw the sprite.
  45. Vector vBasePt, vUp, vRight;
  46. CalcBasis( vToGlow, flHorzSize, flVertSize, vBasePt, vUp, vRight );
  47. // Draw the sprite.
  48. IMaterial *pMaterial = materials->FindMaterial( "sun/overlay", TEXTURE_GROUP_CLIENT_EFFECTS );
  49. IMesh *pMesh = pRenderContext->GetDynamicMesh( false, 0, 0, pMaterial );
  50. CMeshBuilder builder;
  51. builder.Begin( pMesh, MATERIAL_QUADS, 1 );
  52. Vector vPt;
  53. vPt = vBasePt - vRight + vUp;
  54. builder.Position3fv( vPt.Base() );
  55. builder.Color4f( VectorExpand(vColor), 1 );
  56. builder.TexCoord2f( 0, 0, 1 );
  57. builder.AdvanceVertex();
  58. vPt = vBasePt + vRight + vUp;
  59. builder.Position3fv( vPt.Base() );
  60. builder.Color4f( VectorExpand(vColor), 1 );
  61. builder.TexCoord2f( 0, 1, 1 );
  62. builder.AdvanceVertex();
  63. vPt = vBasePt + vRight - vUp;
  64. builder.Position3fv( vPt.Base() );
  65. builder.Color4f( VectorExpand(vColor), 1 );
  66. builder.TexCoord2f( 0, 1, 0 );
  67. builder.AdvanceVertex();
  68. vPt = vBasePt - vRight - vUp;
  69. builder.Position3fv( vPt.Base() );
  70. builder.Color4f( VectorExpand(vColor), 1 );
  71. builder.TexCoord2f( 0, 0, 0 );
  72. builder.AdvanceVertex();
  73. builder.End( false, true );
  74. }
  75. }