W3DShadow.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. #pragma once
  24. #ifndef __W3DSHADOW_H_
  25. #define __W3DSHADOW_H_
  26. #include "matrix4.h"
  27. #include "GameClient/Shadow.h"
  28. class Drawable; //forward reference
  29. // ShadowManager -------------------------------------------------------------
  30. class W3DShadowManager
  31. {
  32. public:
  33. W3DShadowManager( void );
  34. ~W3DShadowManager( void );
  35. Bool init( void ); ///<initialize resources used by manager, must have valid D3D device.
  36. void queueShadows(Bool state) {m_isShadowScene=state;} ///<flags system to process shadows on next render call.
  37. // shadow list management
  38. void Reset( void );
  39. Shadow* addShadow( RenderObjClass *robj,Shadow::ShadowTypeInfo *shadowInfo=NULL, Drawable *draw=NULL); ///< adds shadow caster to rendering system.
  40. void removeShadow(Shadow *shadow); ///< removed shadow from rendering system and frees its resources.
  41. void removeAllShadows(void); ///< Remove all shadows.
  42. void setShadowColor(UnsignedInt color) { m_shadowColor=color;} ///<sets the shadow color and alpha, value in ARGB format.
  43. UnsignedInt getShadowColor() { return m_shadowColor;} ///<gets the shadow color and alpha, value in ARGB format.
  44. void setLightPosition(Int lightIndex, Real x, Real y, Real z); ///<sets the position of a specific light source.
  45. void setTimeOfDay(TimeOfDay tod);
  46. void invalidateCachedLightPositions(void); ///<forces shadow volumes to update regardless of last lightposition
  47. Vector3 &getLightPosWorld(Int lightIndex); ///<returns the position of specified light source.
  48. Bool isShadowScene(void) {return m_isShadowScene;}
  49. inline void setStencilShadowMask(int mask) {m_stencilShadowMask=mask;} ///<mask used to mask out stencil bits used for storing occlusion/playerColor
  50. inline Int getStencilShadowMask(void) {return m_stencilShadowMask;}
  51. // rendering
  52. void RenderShadows( void );
  53. void ReleaseResources(void);
  54. Bool ReAcquireResources(void);
  55. protected:
  56. Bool m_isShadowScene; ///<flag if current scene needs shadows. No shadows on pre-pass and 2D.
  57. UnsignedInt m_shadowColor; ///<color and alpha for all shadows in scene.
  58. Int m_stencilShadowMask;
  59. }; // end class W3DShadowManager
  60. extern W3DShadowManager *TheW3DShadowManager;
  61. #endif //__W3DSHADOW_H_