W3DProjectedShadow.h 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // FILE: W3DProjectedShadow.h ///////////////////////////////////////////////////////////
  24. //
  25. // Real time shadow projection through textures.
  26. //
  27. // Author: Mark Wilczynski, February 2002
  28. //
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////
  31. #pragma once
  32. #ifndef __W3D_PROJECTED_SHADOW_H_
  33. #define __W3D_PROJECTED_SHADOW_H_
  34. #include "GameClient/Shadow.h"
  35. class W3DShadowTexture; //forward reference
  36. class W3DShadowTextureManager; //forward reference
  37. class W3DProjectedShadow; //forward reference
  38. class Drawable; //forward reference
  39. class W3DProjectedShadowManager : public ProjectedShadowManager
  40. {
  41. /* enum ShadowTextureType {
  42. STT_STATIC = 0x0001,
  43. STT_DYNAMIC = 0x0002,
  44. STT_SHARED
  45. };
  46. */
  47. public:
  48. W3DProjectedShadowManager( void );
  49. ~W3DProjectedShadowManager( void );
  50. Bool init(void); ///<allocate one-time shadow assets for length of entire game.
  51. void reset(void); ///<free all existing shadows - ready for next map.
  52. void shutdown(void); ///<free all assets prior to shutdown of entire game.
  53. Int renderShadows(RenderInfoClass & rinfo); ///<iterate over each object and render its shadow onto affected objects.
  54. void ReleaseResources(void); ///<release device dependent D3D resources.
  55. Bool ReAcquireResources(void); ///<allocate device dependent D3D resources.
  56. void invalidateCachedLightPositions(void); ///<forces shadows to update regardless of last lightposition
  57. virtual Shadow *addDecal(RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo); ///<add a non-shadow decal
  58. virtual Shadow *addDecal(Shadow::ShadowTypeInfo *shadowInfo); ///<add a non-shadow decal which does not follow an object.
  59. W3DProjectedShadow *addShadow( RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo, Drawable *draw); ///<add a new shadow with texture of given name or that of robj.
  60. void removeShadow (W3DProjectedShadow *shadow);
  61. void removeAllShadows(void); ///< Remove all shadows.
  62. TextureClass *getRenderTarget(void) { return m_dynamicRenderTarget;}
  63. SpecialRenderInfoClass *getRenderContext(void) { return m_shadowContext;}
  64. void updateRenderTargetTextures(void); ///<render into any textures that need updating.
  65. void queueDecal(W3DProjectedShadow *shadow); ///<add shadow decal to render list - decal conforms to terrain.
  66. void queueSimpleDecal(W3DProjectedShadow *shadow); ///< add shadow decal to render list - decal floats on terrain.
  67. void flushDecals(W3DShadowTexture *texture, ShadowType type); ///<empty queue by rendering all decals with given texture
  68. private:
  69. W3DProjectedShadow *m_shadowList;
  70. W3DProjectedShadow *m_decalList;
  71. TextureClass *m_dynamicRenderTarget; ///<offscreen video memory texture used to render all shadow textures.
  72. Bool m_renderTargetHasAlpha; ///<does render target have destination alpha support?
  73. CameraClass *m_shadowCamera; ///<camera used to render all shadow textures - configured by projector
  74. LightEnvironmentClass m_shadowLightEnv;
  75. SpecialRenderInfoClass *m_shadowContext;
  76. W3DShadowTextureManager *m_W3DShadowTextureManager;
  77. Int m_numDecalShadows; ///< number of decal shadows in the system.
  78. Int m_numProjectionShadows; ///< number of projected shadows in the system.
  79. Int renderProjectedTerrainShadow(W3DProjectedShadow *shadow, AABoxClass &box); ///<render shadow on map terrain.
  80. };
  81. extern W3DProjectedShadowManager *TheW3DProjectedShadowManager;
  82. #endif //__W3D_PROJECTED_SHADOW_H_