physdecalsys.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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/physdecalsys.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 6/29/01 11:26a $*
  31. * *
  32. * $Revision:: 4 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef PHYSDECALSYS_H
  38. #define PHYSDECALSYS_H
  39. #include "always.h"
  40. #include "vector.h"
  41. #include "simplevec.h"
  42. #include "multilist.h"
  43. #include "decalsys.h"
  44. class MeshClass;
  45. class PhysicsSceneClass;
  46. class CameraClass;
  47. class PhysClass;
  48. class DistAlphaVPClass;
  49. /**
  50. ** PhysDecalSysClass
  51. ** This derived DecalSystemClass provides two pools of decals. One pool is a
  52. ** fixed size buffer of decals which are recycled when the buffer fills up. The second
  53. ** pool is for "permanent" decals.
  54. **
  55. ** Saving and loading of decals is currently not possible so the external user will have
  56. ** to track the parameters used to create any decals that he wants to survive across
  57. ** a save-load.
  58. **
  59. ** The decal ID used by this system is formatted in a way so that we
  60. */
  61. class PhysDecalSysClass : public DecalSystemClass
  62. {
  63. public:
  64. PhysDecalSysClass(PhysicsSceneClass * parent_scene);
  65. virtual ~PhysDecalSysClass(void);
  66. /*
  67. ** Create_Decal - this is the interface typically used by PhysicsSceneClass to create new decals
  68. ** Update_Decal_Fade_Distances - this updates the alpha fading parameters
  69. */
  70. void Update_Decal_Fade_Distances(const CameraClass & camera);
  71. int Create_Decal( const Matrix3D & tm,
  72. const char * texture_name,
  73. float radius,
  74. bool is_permanent,
  75. bool apply_to_translucent_meshes,
  76. PhysClass * only_this_obj);
  77. bool Remove_Decal(uint32 id);
  78. /*
  79. ** Create and release DecalGenerators. Note that this is the point at which the
  80. ** decal system can track "logical" decals. The generator will keep an internal list
  81. ** of all of the render objects which generated decals which you should copy if you
  82. ** want to track them (e.g. if you want to cap the maximum number of active decals and
  83. ** kill the old ones...)
  84. */
  85. virtual void Unlock_Decal_Generator(DecalGeneratorClass * generator);
  86. /*
  87. ** When a decal-mesh is destroyed, it must inform the DecalSystem. Otherwise, systems
  88. ** which track decals can get dangling pointers.
  89. */
  90. virtual void Decal_Mesh_Destroyed(uint32 decal_id,DecalMeshClass * mesh);
  91. /*
  92. ** Control over the size of the temporary decal array. When this array is filled, the
  93. ** oldest decals are removed as new decals are added.
  94. */
  95. void Set_Temporary_Decal_Pool_Size(int count);
  96. int Get_Temporary_Decal_Pool_Size(void);
  97. protected:
  98. virtual uint32 Generate_Decal_Id(void);
  99. bool is_decal_id_permanent(uint32 id);
  100. bool internal_remove_decal(uint32 id,MeshClass * mesh);
  101. void allocate_resources(void);
  102. void release_resources(void);
  103. /**
  104. ** LogicalDecalClass
  105. ** This class is used to track all of the meshes that were affected when a
  106. ** decal is generated.
  107. */
  108. class LogicalDecalClass : public MultiListObjectClass
  109. {
  110. public:
  111. LogicalDecalClass(void);
  112. ~LogicalDecalClass(void);
  113. bool operator == (const LogicalDecalClass & that) { return false; }
  114. bool operator != (const LogicalDecalClass & that) { return true; }
  115. void Reset(void);
  116. void Init(DecalGeneratorClass * gen);
  117. uint32 DecalID;
  118. SimpleDynVecClass<MeshClass *> Meshes;
  119. };
  120. PhysicsSceneClass * ParentScene; // scene that this decal system works with
  121. bool CreatePermanentDecals; // internal setting, are we creating permanent or temporary decals
  122. uint32 NextTempDecalIndex; // index of the next temporary decal
  123. VectorClass<LogicalDecalClass> TempDecals; // array of logical decals for
  124. MultiListClass<LogicalDecalClass> PermanentDecals; // linked list of permanent decals
  125. VertexMaterialClass * DecalMaterial; // material used by all decals in WWPhys
  126. ShaderClass DecalShader; // shader used by all decals in WWPhys
  127. DistAlphaVPClass* DecalDistAlphaVP;
  128. };
  129. #endif //PHYSDECALSYS_H