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.4 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // A class representing a light
  4. //
  5. //=============================================================================
  6. #ifndef DMELIGHT_H
  7. #define DMELIGHT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "movieobjects/dmedag.h"
  12. //-----------------------------------------------------------------------------
  13. // Forward declaration
  14. //-----------------------------------------------------------------------------
  15. struct LightDesc_t;
  16. //-----------------------------------------------------------------------------
  17. // A base class for lights
  18. //-----------------------------------------------------------------------------
  19. class CDmeLight : public CDmeDag
  20. {
  21. DEFINE_ELEMENT( CDmeLight, CDmeDag );
  22. public:
  23. // Sets the color and intensity
  24. // NOTE: Color is specified 0-255 floating point.
  25. void SetColor( const Color &color );
  26. void SetIntensity( float flIntensity );
  27. // Sets up render state in the material system for rendering
  28. virtual bool GetLightDesc( LightDesc_t *pDesc ) { return false; }
  29. protected:
  30. // Sets up render state in the material system for rendering
  31. void SetupRenderStateInternal( LightDesc_t &desc, float flAtten0, float flAtten1, float flAtten2 );
  32. CDmaVar< Color > m_Color;
  33. CDmaVar< float > m_flIntensity;
  34. };
  35. //-----------------------------------------------------------------------------
  36. // A directional light
  37. //-----------------------------------------------------------------------------
  38. class CDmeDirectionalLight : public CDmeLight
  39. {
  40. DEFINE_ELEMENT( CDmeDirectionalLight, CDmeLight );
  41. public:
  42. // Sets up render state in the material system for rendering
  43. virtual bool GetLightDesc( LightDesc_t *pDesc );
  44. };
  45. //-----------------------------------------------------------------------------
  46. // A point light
  47. //-----------------------------------------------------------------------------
  48. class CDmePointLight : public CDmeLight
  49. {
  50. DEFINE_ELEMENT( CDmePointLight, CDmeLight );
  51. public:
  52. // Sets the attenuation factors
  53. void SetAttenuation( float flConstant, float flLinear, float flQuadratic );
  54. // Sets the maximum range
  55. void SetMaxDistance( float flMaxDistance );
  56. // Sets up render state in the material system for rendering
  57. virtual bool GetLightDesc( LightDesc_t *pDesc );
  58. protected:
  59. CDmaVar< float > m_flAttenuation0;
  60. CDmaVar< float > m_flAttenuation1;
  61. CDmaVar< float > m_flAttenuation2;
  62. CDmaVar< float > m_flMaxDistance;
  63. };
  64. //-----------------------------------------------------------------------------
  65. // A spot light
  66. //-----------------------------------------------------------------------------
  67. class CDmeSpotLight : public CDmePointLight
  68. {
  69. DEFINE_ELEMENT( CDmeSpotLight, CDmePointLight );
  70. public:
  71. // Sets the spotlight angle factors
  72. // Angles are specified in degrees, as full angles (as opposed to half-angles)
  73. void SetAngles( float flInnerAngle, float flOuterAngle, float flAngularFalloff );
  74. // Sets up render state in the material system for rendering
  75. virtual bool GetLightDesc( LightDesc_t *pDesc );
  76. private:
  77. CDmaVar<float> m_flSpotInnerAngle;
  78. CDmaVar<float> m_flSpotOuterAngle;
  79. CDmaVar<float> m_flSpotAngularFalloff;
  80. };
  81. //-----------------------------------------------------------------------------
  82. // An ambient light
  83. //-----------------------------------------------------------------------------
  84. class CDmeAmbientLight : public CDmeLight
  85. {
  86. DEFINE_ELEMENT( CDmeAmbientLight, CDmeLight );
  87. };
  88. #endif // DMELIGHT_H