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.

116 lines
3.2 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef CLIENTALPHAPROPERTY_H
  8. #define CLIENTALPHAPROPERTY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "iclientalphaproperty.h"
  13. #define CLIENT_ALPHA_DISTANCE_FADE_MODE_BIT_COUNT 1
  14. //-----------------------------------------------------------------------------
  15. // Implementation class
  16. //-----------------------------------------------------------------------------
  17. class CClientAlphaProperty : public IClientAlphaProperty
  18. {
  19. // Inherited from IClientAlphaProperty
  20. public:
  21. virtual IClientUnknown* GetIClientUnknown();
  22. virtual void SetAlphaModulation( uint8 a );
  23. virtual void SetRenderFX( RenderFx_t nRenderFx, RenderMode_t nRenderMode, float flStartTime = FLT_MAX, float flDuration = 0.0f );
  24. virtual void SetFade( float flGlobalFadeScale, float flDistFadeMinDist, float flDistFadeMaxDist );
  25. virtual void SetDesyncOffset( int nOffset );
  26. virtual void EnableAlphaModulationOverride( bool bEnable );
  27. virtual void EnableShadowAlphaModulationOverride( bool bEnable );
  28. virtual void SetDistanceFadeMode( ClientAlphaDistanceFadeMode_t nFadeMode );
  29. // Other public methods
  30. public:
  31. CClientAlphaProperty( );
  32. void Init( IClientUnknown *pUnk );
  33. // NOTE: Only the client shadow manager should ever call this method!
  34. void SetShadowHandle( ClientShadowHandle_t hShadowHandle );
  35. // Returns the current alpha modulation (no fades or render FX taken into account)
  36. uint8 GetAlphaModulation() const;
  37. // Compute the render alpha (after fades + render FX are applied)
  38. uint8 ComputeRenderAlpha( ) const;
  39. // Returns alpha fade
  40. float GetMinFadeDist() const;
  41. float GetMaxFadeDist() const;
  42. float GetGlobalFadeScale() const;
  43. // Should this ignore the Z buffer?
  44. bool IgnoresZBuffer( void ) const;
  45. private:
  46. int ComputeRenderEffectBlend( int nRenderEffect ) const;
  47. private:
  48. // NOTE: Be careful if you add data to this class.
  49. // It needs to be no more than 32 bytes, which it is right now
  50. // (remember the vtable adds 4 bytes). Try to restrict usage
  51. // to reserved areas or figure out a way of compressing existing fields
  52. IClientUnknown *m_pOuter;
  53. ClientShadowHandle_t m_hShadowHandle;
  54. uint16 m_nRenderFX : 5;
  55. uint16 m_nRenderMode : 4;
  56. uint16 m_bAlphaOverride : 1;
  57. uint16 m_bShadowAlphaOverride : 1;
  58. uint16 m_nDistanceFadeMode : CLIENT_ALPHA_DISTANCE_FADE_MODE_BIT_COUNT;
  59. uint16 m_nReserved : 4;
  60. uint16 m_nDesyncOffset;
  61. uint8 m_nAlpha;
  62. uint8 m_nReserved2;
  63. uint16 m_nDistFadeStart;
  64. uint16 m_nDistFadeEnd;
  65. float m_flFadeScale;
  66. float m_flRenderFxStartTime;
  67. float m_flRenderFxDuration;
  68. friend class CClientLeafSystem;
  69. };
  70. // Returns the current alpha modulation
  71. inline uint8 CClientAlphaProperty::GetAlphaModulation() const
  72. {
  73. return m_nAlpha;
  74. }
  75. inline float CClientAlphaProperty::GetMinFadeDist() const
  76. {
  77. return m_nDistFadeStart;
  78. }
  79. inline float CClientAlphaProperty::GetMaxFadeDist() const
  80. {
  81. return m_nDistFadeEnd;
  82. }
  83. inline float CClientAlphaProperty::GetGlobalFadeScale() const
  84. {
  85. return m_flFadeScale;
  86. }
  87. inline bool CClientAlphaProperty::IgnoresZBuffer( void ) const
  88. {
  89. return m_nRenderMode == kRenderGlow || m_nRenderMode == kRenderWorldGlow;
  90. }
  91. #endif // CLIENTALPHAPROPERTY_H