dynamicshadowmanager.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ** Command & Conquer Renegade(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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/dynamicshadowmanager.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 12/05/01 6:28p $*
  31. * *
  32. * $Revision:: 3 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef DYNAMICSHADOWMANAGER_H
  38. #define DYNAMICSHADOWMANAGER_H
  39. #include "always.h"
  40. #include "vector3.h"
  41. class ChunkLoadClass;
  42. class ChunkSaveClass;
  43. class PhysClass;
  44. class DynTexProjectClass;
  45. class DynamicShadowManagerDefClass;
  46. /**
  47. ** DynamicShadowManagerClass
  48. ** This is another class designed to be embedded in a physics object. It's responsibility
  49. ** is to update and manage the dynamic shadow projection(s) for its parent.
  50. */
  51. class DynamicShadowManagerClass
  52. {
  53. public:
  54. DynamicShadowManagerClass(PhysClass & parent);
  55. ~DynamicShadowManagerClass(void);
  56. /*
  57. ** Call Update_Shadow in your Post_Timestep_Process function
  58. */
  59. void Update_Shadow(void);
  60. /*
  61. ** You can explicitly set the nearz and farz planes for the shadow or
  62. ** if they are set to -1.0f, the code will handle them automatically.
  63. ** Typically game objects like characters and vehicles should use the
  64. ** automatic setting while cinematics may need a manual setting. For
  65. ** example, a flying airplane may need to cast a long shadow for the
  66. ** shadow to hit the ground.
  67. */
  68. void Set_Shadow_Planes(float znear = -1.0f,float zfar = -1.0f);
  69. void Get_Shadow_Planes(float * set_znear,float * set_zfar);
  70. /*
  71. ** Vehicles now have enourmous muzzle flashes that cause the shadow
  72. ** bounding box to be much larger than it should be. This causes low
  73. ** shadow resolution as well as per-polygon culling visual errors
  74. */
  75. void Enable_Force_Use_Blob_Box(bool onoff) { ForceUseBlobBox = onoff; }
  76. bool Is_Force_Use_Blob_Box_Enabled(void) { return ForceUseBlobBox; }
  77. void Set_Blob_Box_Projection_Scale(const Vector3 & scl) { BlobBoxProjectionScale = scl; }
  78. const Vector3 & Get_Blob_Box_Projection_Scale(void) { return BlobBoxProjectionScale; }
  79. /*
  80. ** Accessor to indicate whether we are actually casting a shadow
  81. */
  82. bool Is_Casting_Shadow(void) { return (Shadow != NULL); }
  83. protected:
  84. /*
  85. ** Internal shadow support.
  86. */
  87. void Allocate_Shadow(void);
  88. void Release_Shadow(void);
  89. PhysClass & Parent;
  90. DynTexProjectClass * Shadow;
  91. float ShadowNearZ;
  92. float ShadowFarZ;
  93. bool ForceUseBlobBox;
  94. Vector3 BlobBoxProjectionScale;
  95. };
  96. inline void DynamicShadowManagerClass::Set_Shadow_Planes(float znear,float zfar)
  97. {
  98. ShadowNearZ = znear;
  99. ShadowFarZ = zfar;
  100. }
  101. inline void DynamicShadowManagerClass::Get_Shadow_Planes(float * set_znear,float * set_zfar)
  102. {
  103. *set_znear = ShadowNearZ;
  104. *set_zfar = ShadowFarZ;
  105. }
  106. #endif // DYNAMICSHADOWMANAGER_H