Snow.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // FILE: Snow.h /////////////////////////////////////////////////////////
  19. #pragma once
  20. #ifndef _SNOW_H_
  21. #define _SNOW_H_
  22. #include "Lib/BaseType.h"
  23. #include "Common/SubsystemInterface.h"
  24. #include "Common/Overridable.h"
  25. #include "Common/Override.h"
  26. #include "WWMATH/Vector3.h"
  27. #include "WWMATH/Vector4.h"
  28. //-------------------------------------------------------------------------------------------------
  29. /** This structure keeps the transparency and vertex settings, which are the same regardless of the
  30. time of day. They can be overridden on a per-map basis. */
  31. //-------------------------------------------------------------------------------------------------
  32. class WeatherSetting : public Overridable
  33. {
  34. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( WeatherSetting, "WeatherSetting" )
  35. public:
  36. AsciiString m_snowTexture;
  37. Real m_snowFrequencyScaleX; ///<used to adjust snow position.
  38. Real m_snowFrequencyScaleY; ///<used to adjust snow position.
  39. Real m_snowAmplitude; ///<used to adjust amount of of snow movement. (in world units)
  40. Real m_snowPointSize; ///<used to control hardware point-sprite size. (in arbitrary units - see DX SDK Docs).
  41. Real m_snowMaxPointSize; ///<used to control maximum size (in pixels) of point sprite.
  42. Real m_snowMinPointSize; ///<used to control the minimum size (in piexels) of point sprite.
  43. Real m_snowQuadSize; ///<used to control quad size when no hardware point sprites. (world width/height of quad)
  44. Real m_snowBoxDimensions; ///<used to set dimensions of box surrounding camera. (world units)
  45. Real m_snowBoxDensity; ///<used to control how many emitters are present per world unit
  46. Real m_snowVelocity; ///<used to set speed at which snow falls (world units/sec).
  47. Bool m_usePointSprites; ///<used to disable hardware point-sprite support.
  48. Bool m_snowEnabled; ///<enable/disable snow on the map.
  49. public:
  50. WeatherSetting()
  51. {
  52. m_snowTexture = "EXSnowFlake.tga";
  53. m_snowFrequencyScaleX=0.0533f;
  54. m_snowFrequencyScaleY=0.0275f;
  55. m_snowAmplitude=5.0f;
  56. m_snowPointSize=1.0f;
  57. m_snowQuadSize=0.5f;
  58. m_snowBoxDimensions=200;
  59. m_snowBoxDensity=1;
  60. m_snowVelocity=4;
  61. m_usePointSprites=TRUE;
  62. m_snowEnabled=FALSE;
  63. m_snowMaxPointSize=64.0f;
  64. m_snowMinPointSize=0.0f;
  65. }
  66. static const FieldParse m_weatherSettingFieldParseTable[]; ///< the parse table for INI definition
  67. /// Get the INI parsing table for loading
  68. const FieldParse *getFieldParse( void ) const { return m_weatherSettingFieldParseTable; }
  69. };
  70. EMPTY_DTOR(WeatherSetting)
  71. extern OVERRIDE<WeatherSetting> TheWeatherSetting;
  72. class SnowManager : public SubsystemInterface
  73. {
  74. public :
  75. enum{
  76. SNOW_NOISE_X=64, //dimensions table holding noise function used for initial snow positions.
  77. SNOW_NOISE_Y=64, //dimensions table holding noise function used for initial snow positions.
  78. };
  79. SnowManager(void);
  80. ~SnowManager(void);
  81. virtual void init( void );
  82. virtual void reset( void );
  83. virtual void updateIniSettings (void);
  84. void setVisible(Bool showWeather); ///<enable/disable rendering of weather - assuming it's available on map.
  85. protected :
  86. Real *m_startingHeights;
  87. Real m_time; ///<time elapsed since it started snowing.
  88. Real m_velocity; ///<positive velocity of falling snow
  89. Real m_fullTimePeriod; ///<time for snow to complete a full animation cycle.
  90. Real m_frequencyScaleX; ///<used to adjust snow position.
  91. Real m_frequencyScaleY; ///<used to adjust snow position.
  92. Real m_amplitude; ///<used to adjust amount of of snow movement.
  93. Real m_pointSize; ///<used to control hardware point-sprite size.
  94. Real m_maxPointSize; ///<used to control maximum pixel size of sprites.
  95. Real m_minPointSize; ///<used to control minimum pixel size of sprites.
  96. Real m_quadSize; ///<used to control quad size when no hardware point sprites.
  97. Real m_boxDimensions; ///<used to set dimensions of box surrounding camera.
  98. Real m_emitterSpacing; ///<used to control how many emitters are present per world unit
  99. Bool m_isVisible; ///<used to prevent map weather (if defined) from rendering.
  100. };
  101. extern SnowManager *TheSnowManager; ///< the ray effects singleton external
  102. #endif // _SNOW_H_