materialeffect.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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/materialeffect.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 12/07/01 2:43p $*
  31. * *
  32. * $Revision:: 3 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef MATERIALEFFECT_H
  41. #define MATERIALEFFECT_H
  42. #include "always.h"
  43. #include "multilist.h"
  44. #include "refcount.h"
  45. class PhysClass;
  46. class RenderInfoClass;
  47. class MaterialPassClass;
  48. /**
  49. ** MaterialEffectClass
  50. ** This class is an abstract base class for any kind of "extra pass" material effect. Phys objects
  51. ** support a list of these effects being added to them and will push and pop the effects during
  52. ** rendering. For "transient" effects like shadows, the auto-remove flag can be enabled which
  53. ** will cause the physics object to un-link the effect after rendering is complete.
  54. **
  55. ** NOTES:
  56. **
  57. ** I need to abstract the differences between the stealth effect and things like texture projections
  58. ** and shadows. By clumping all of the stealth effect stuff into an external class, we'll be able
  59. ** to apply it both to the character and any other models like his first person hands, etc. By
  60. ** unifying texture projectors and these new types of effects, we can just upgrade the list
  61. ** that is already present in all PhysClass's.
  62. **
  63. ** This means that when shadows are linked onto render objects, they will need to be wrapped by
  64. ** a class derived from this new abstract base class. We'll probably want to recycle the wrappers
  65. ** since shadows are re-attached every frame. This also means that the wrapper needs an auto-remove
  66. ** flag so the phys object can discard it after rendering is complete if necessary.
  67. **
  68. ** If we want to also use the stealth object for game logic, we need to ensure that its internal
  69. ** variables update even when it doesn't get rendered. The PhysClass could timestep all of the
  70. ** currently attached material effects. The only ones attached during timestep would be the
  71. ** "persistant" ones...
  72. **
  73. */
  74. class MaterialEffectClass : public MultiListObjectClass, public RefCountClass
  75. {
  76. public:
  77. MaterialEffectClass(void);
  78. virtual ~MaterialEffectClass(void);
  79. void Enable_Auto_Remove(bool onoff) { AutoRemoveEnabled = onoff; }
  80. bool Is_Auto_Remove_Enabled(void) { return AutoRemoveEnabled; }
  81. void Enable_Suppress_Shadows(bool onoff) { SuppressShadows = onoff; }
  82. bool Are_Shadows_Suppressed(void) { return SuppressShadows; }
  83. virtual void Timestep(float dt) { }
  84. virtual void Render_Push(RenderInfoClass & rinfo,PhysClass * obj) = 0;
  85. virtual void Render_Pop(RenderInfoClass & rinfo) = 0;
  86. static void Timestep_All_Effects(float dt);
  87. private:
  88. bool AutoRemoveEnabled;
  89. bool SuppressShadows;
  90. };
  91. /**
  92. ** SimpleEffectClass
  93. ** This is a material effect object which simply causes a material pass to be added. The texture
  94. ** projection system uses this in "Auto Remove" mode to simply get the shadow pass applied to
  95. ** each object that the shadow falls on. These objects are Auto-Pooled for fast allocation and
  96. ** de-allocation so the user cannot derive a class from SimpleEffectClass.
  97. */
  98. #define SIMPLE_EFFECT_GROWTH_STEP 256
  99. class SimpleEffectClass : public MaterialEffectClass , public AutoPoolClass<SimpleEffectClass,SIMPLE_EFFECT_GROWTH_STEP>
  100. {
  101. public:
  102. SimpleEffectClass(MaterialPassClass * matpass);
  103. ~SimpleEffectClass(void);
  104. virtual void Render_Push(RenderInfoClass & rinfo,PhysClass * obj);
  105. virtual void Render_Pop(RenderInfoClass & rinfo);
  106. private:
  107. MaterialPassClass * MatPass;
  108. };
  109. #endif //MATERIALEFFECT_H