staticanimphys.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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/staticanimphys.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 12/05/01 6:18p $*
  31. * *
  32. * $Revision:: 27 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef STATICANIMPHYS_H
  41. #define STATICANIMPHYS_H
  42. #include "always.h"
  43. #include "staticphys.h"
  44. #include "wwstring.h"
  45. #include "projectormanager.h"
  46. #include "animcollisionmanager.h"
  47. class StaticAnimPhysDefClass;
  48. class MeshClass;
  49. /**
  50. ** StaticAnimPhysClass
  51. ** This class is a static object which needs to perform additional processing
  52. ** each frame. Here are some of the features planned for this class:
  53. ** - animation which causes collisions in the world (like doors, elevators and more)
  54. ** - animation which updates a texture projector for effects like spot-lights, animated shadows
  55. ** - It can cause collisions due to its model animating (e.g. doors, lifts)
  56. ** and it can manage a texture projector.
  57. ** - Possibly support multiple models and switch between the models for damage
  58. */
  59. class StaticAnimPhysClass : public StaticPhysClass
  60. {
  61. public:
  62. StaticAnimPhysClass(void);
  63. ~StaticAnimPhysClass(void);
  64. virtual StaticAnimPhysClass * As_StaticAnimPhysClass(void) { return this; }
  65. void Init(const StaticAnimPhysDefClass & def);
  66. virtual void Set_Model(RenderObjClass * model);
  67. virtual void Vis_Render(SpecialRenderInfoClass & rinfo);
  68. /*
  69. ** Static properties
  70. */
  71. StaticAnimPhysDefClass * Get_StaticAnimPhysDef(void) { return (StaticAnimPhysDefClass *)Definition; }
  72. /*
  73. ** Processing
  74. */
  75. virtual bool Needs_Timestep(void);
  76. virtual void Timestep(float dt);
  77. /*
  78. ** State Import/Export and Save/Load
  79. */
  80. virtual bool Has_Dynamic_State(void) { return true; }
  81. virtual void Save_State(ChunkSaveClass & csave);
  82. virtual void Load_State(ChunkLoadClass & cload);
  83. /*
  84. ** Riders
  85. */
  86. virtual bool Internal_Link_Rider(PhysClass * rider);
  87. virtual bool Internal_Unlink_Rider(PhysClass * rider);
  88. /*
  89. ** Animation and animated collision control
  90. */
  91. AnimCollisionManagerClass & Get_Animation_Manager(void) { return AnimManager; }
  92. /*
  93. ** Shadow control. These are static texture projectors which affect
  94. ** dynamic objects. Examples are tree shadows and stained glass windows
  95. */
  96. void Set_Shadow(TexProjectClass * shadow);
  97. virtual bool Is_Casting_Shadow(void) { return (ShadowProjector != NULL); }
  98. void Debug_Display_Shadow(const Vector2 & v0,const Vector2 & v1);
  99. /*
  100. ** Save-Load Support
  101. */
  102. virtual const PersistFactoryClass & Get_Factory(void) const;
  103. virtual bool Save(ChunkSaveClass &csave);
  104. virtual bool Load(ChunkLoadClass &cload);
  105. virtual void On_Post_Load(void);
  106. protected:
  107. void Update_Cached_Model_Parameters(void);
  108. virtual void Update_Sun_Status(void);
  109. protected:
  110. /*
  111. ** Attached Projector Management
  112. */
  113. ProjectorManagerClass ProjectorManager;
  114. /*
  115. ** Animation, animated collision, and rider management
  116. */
  117. AnimCollisionManagerClass AnimManager;
  118. /*
  119. ** Static shadow management
  120. */
  121. TexProjectClass * ShadowProjector;
  122. private:
  123. StaticAnimPhysClass(const StaticPhysClass &);
  124. StaticAnimPhysClass & operator = (const StaticPhysClass &);
  125. };
  126. /**
  127. ** StaticAnimPhysDefClass
  128. ** Initialization data structure for StaticAnimPhysClass
  129. */
  130. class StaticAnimPhysDefClass : public StaticPhysDefClass
  131. {
  132. public:
  133. StaticAnimPhysDefClass(void);
  134. // From DefinitionClass
  135. virtual uint32 Get_Class_ID (void) const;
  136. virtual PersistClass * Create(void) const;
  137. // From PhysDefClass
  138. virtual const char * Get_Type_Name(void) { return "StaticAnimPhysDef"; }
  139. virtual bool Is_Type(const char *);
  140. // From PersistClass
  141. virtual const PersistFactoryClass & Get_Factory (void) const;
  142. virtual bool Save(ChunkSaveClass &csave);
  143. virtual bool Load(ChunkLoadClass &cload);
  144. // Editable interface requirements
  145. DECLARE_EDITABLE(StaticAnimPhysDefClass,StaticPhysDefClass);
  146. // Accessors
  147. bool Shadow_Dynamic_Objs(void) { return ShadowDynamicObjs; }
  148. bool Shadow_Is_Additive(void) { return ShadowIsAdditive; }
  149. bool Shadow_Ignores_Z_Rotation(void) { return ShadowIgnoresZRotation; }
  150. float Shadow_NearZ(void) { return ShadowNearZ; }
  151. float Shadow_FarZ(void) { return ShadowFarZ; }
  152. float Shadow_Intensity(void) { return ShadowIntensity; }
  153. bool Does_Collide_In_Pathfind(void) { return DoesCollideInPathfind; }
  154. protected:
  155. bool IsCosmetic;
  156. // Animation and animated collision support
  157. AnimCollisionManagerDefClass AnimManagerDef;
  158. // Animated projector support
  159. ProjectorManagerDefClass ProjectorManagerDef;
  160. // Static shadow support
  161. bool ShadowDynamicObjs;
  162. bool ShadowIsAdditive;
  163. bool ShadowIgnoresZRotation;
  164. float ShadowNearZ;
  165. float ShadowFarZ;
  166. float ShadowIntensity;
  167. // Pathfind support
  168. bool DoesCollideInPathfind;
  169. friend class StaticAnimPhysClass;
  170. };
  171. #endif //STATICANIMPHYS_H