Team Fortress 2 Source Code as on 22/4/2020
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.

103 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef FX_WATER_H
  7. #define FX_WATER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "particles_simple.h"
  12. #include "fx.h"
  13. #include "tier0/memdbgon.h"
  14. class CSplashParticle : public CSimpleEmitter
  15. {
  16. public:
  17. CSplashParticle( const char *pDebugName ) : CSimpleEmitter( pDebugName ), m_bUseClipHeight( false ) {}
  18. // Create
  19. static CSplashParticle *Create( const char *pDebugName )
  20. {
  21. return new CSplashParticle( pDebugName );
  22. }
  23. // Roll
  24. virtual float UpdateRoll( SimpleParticle *pParticle, float timeDelta );
  25. // Velocity
  26. virtual void UpdateVelocity( SimpleParticle *pParticle, float timeDelta );
  27. // Alpha
  28. virtual float UpdateAlpha( const SimpleParticle *pParticle );
  29. void SetClipHeight( float flClipHeight );
  30. // Simulation
  31. void SimulateParticles( CParticleSimulateIterator *pIterator );
  32. private:
  33. CSplashParticle( const CSplashParticle & );
  34. float m_flClipHeight;
  35. bool m_bUseClipHeight;
  36. };
  37. class WaterDebrisEffect : public CSimpleEmitter
  38. {
  39. public:
  40. WaterDebrisEffect( const char *pDebugName ) : CSimpleEmitter( pDebugName ) {}
  41. static WaterDebrisEffect* Create( const char *pDebugName );
  42. virtual float UpdateAlpha( const SimpleParticle *pParticle );
  43. private:
  44. WaterDebrisEffect( const WaterDebrisEffect & );
  45. };
  46. extern void FX_WaterRipple( const Vector &origin, float scale, Vector *pColor, float flLifetime=1.5, float flAlpha=1 );
  47. extern void FX_GunshotSplash( const Vector &origin, const Vector &normal, float scale );
  48. extern void FX_GunshotSlimeSplash( const Vector &origin, const Vector &normal, float scale );
  49. //-----------------------------------------------------------------------------
  50. // Purpose: Retrieve and alter lighting for splashes
  51. // Input : position - point to check
  52. // *color - tint of the lighting at this point
  53. // *luminosity - adjusted luminosity at this point
  54. //-----------------------------------------------------------------------------
  55. inline void FX_GetSplashLighting( Vector position, Vector *color, float *luminosity )
  56. {
  57. // Compute our lighting at our position
  58. Vector totalColor = engine->GetLightForPoint( position, true );
  59. // Get our lighting information
  60. UTIL_GetNormalizedColorTintAndLuminosity( totalColor, color, luminosity );
  61. // Fake a specular highlight (too dim otherwise)
  62. if ( luminosity != NULL )
  63. {
  64. *luminosity = MIN( 1.0f, (*luminosity) * 4.0f );
  65. // Clamp so that we never go completely translucent
  66. if ( *luminosity < 0.25f )
  67. {
  68. *luminosity = 0.25f;
  69. }
  70. }
  71. // Only take a quarter of the tint, mostly we want to be white
  72. if ( color != NULL )
  73. {
  74. (*color) = ( (*color) * 0.25f ) + Vector( 0.75f, 0.75f, 0.75f );
  75. }
  76. }
  77. #include "tier0/memdbgoff.h"
  78. #endif // FX_WATER_H