vtolvehicle.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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/vtolvehicle.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 8/17/01 8:36p $*
  31. * *
  32. * $Revision:: 5 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef VTOLVEHICLE_H
  41. #define VTOLVEHICLE_H
  42. #include "vehiclephys.h"
  43. class VTOLVehicleDefClass;
  44. /**
  45. ** VTOLVehicleClass
  46. ** This physics object generates the behavior of a VTOL aircraft
  47. **
  48. ** Physical Behavior:
  49. ** I think all VTOL craft can use the same behavior. The vertical thrust
  50. ** is related to the user's setting and the position of the craft between
  51. ** the flight-map-meshes. The orientation of the craft is controlled by
  52. ** a controller which exerts torques to align the craft to a desired orientation
  53. ** The x-y accelerations of the craft will be related to its orientation.
  54. ** Turning will be an independent controller I guess...
  55. ** In addition, "WheelP" bones should be used to provide landing gear in case
  56. ** the orca tries to "land".
  57. **
  58. ** Model animation:
  59. ** For Orcas, I want to show the engines tilting and engine flames lengthening
  60. ** and shortening. For Helecopters, I want to just tilt the rotor... Maybe
  61. ** I'll just have to do each in a derived class which is custom coded for Orca
  62. ** or Helecopter behavior...
  63. ** - Decided to add support for all of the above behaviors to this class.
  64. **
  65. ** Ideas:
  66. ** - Rotor bones (helecopters), these always spin at a rate related to the
  67. ** engine and tilt for turning and accelerating
  68. ** - Thruster bones (orca engines), these rotate forward and back depending
  69. ** on how much the user is accelerating forward.
  70. ** - Flame bones (orca engines), these translate along their Z-axis to stretch
  71. ** a flame 'skin'.
  72. */
  73. class VTOLVehicleClass : public VehiclePhysClass
  74. {
  75. public:
  76. VTOLVehicleClass(void);
  77. virtual ~VTOLVehicleClass(void);
  78. virtual VTOLVehicleClass * As_VTOLVehicleClass(void) { return this; }
  79. const VTOLVehicleDefClass * Get_VTOLVehicleDef(void) { return (VTOLVehicleDefClass *)Definition; }
  80. void Init(const VTOLVehicleDefClass & def);
  81. virtual void Render(RenderInfoClass & rinfo);
  82. virtual void Set_Model(RenderObjClass * model);
  83. virtual void Timestep(float dt);
  84. /*
  85. ** Save-Load System
  86. */
  87. virtual const PersistFactoryClass & Get_Factory (void) const;
  88. virtual bool Save (ChunkSaveClass &csave);
  89. virtual bool Load (ChunkLoadClass &cload);
  90. virtual void On_Post_Load (void);
  91. protected:
  92. virtual bool Can_Go_To_Sleep(void) { return false; }
  93. virtual void Compute_Force_And_Torque(Vector3 * force,Vector3 * torque);
  94. virtual SuspensionElementClass * Alloc_Suspension_Element(void);
  95. virtual float Get_Normalized_Engine_Flame(void);
  96. void Release_Engine_Bones(void);
  97. void Update_Cached_Model_Parameters(void);
  98. /*
  99. ** Captured bones for physics-based graphical effects
  100. */
  101. SimpleVecClass<int> EngineAngleBones;
  102. SimpleVecClass<int> RotorAngleBones;
  103. /*
  104. ** Visual state variables
  105. */
  106. float NormalizedEngineRotation;
  107. float NormalizedEngineThrust;
  108. float RotorAngle;
  109. float RotorAngularVelocity;
  110. private:
  111. // not implemented
  112. VTOLVehicleClass(const VTOLVehicleClass &);
  113. VTOLVehicleClass & operator = (const VTOLVehicleClass &);
  114. };
  115. /**
  116. ** VTOLVehicleDefClass
  117. ** Initialization/Editor Integration for VTOLVehicleClass
  118. */
  119. class VTOLVehicleDefClass : public VehiclePhysDefClass
  120. {
  121. public:
  122. VTOLVehicleDefClass(void);
  123. /*
  124. ** From DefinitionClass
  125. */
  126. virtual uint32 Get_Class_ID (void) const;
  127. virtual PersistClass * Create(void) const;
  128. /*
  129. ** From PhysDefClass
  130. */
  131. virtual const char * Get_Type_Name(void) { return "VTOLVehicleDef"; }
  132. virtual bool Is_Type(const char *);
  133. /*
  134. ** From PersistClass
  135. */
  136. virtual const PersistFactoryClass & Get_Factory (void) const;
  137. virtual bool Save(ChunkSaveClass &csave);
  138. virtual bool Load(ChunkLoadClass &cload);
  139. /*
  140. ** Editable interface requirements
  141. */
  142. DECLARE_EDITABLE(VTOLVehicleDefClass,VehiclePhysDefClass);
  143. protected:
  144. /*
  145. ** Engine thrust in units of acceleration (force = mass * accel...)
  146. */
  147. float MaxVerticalAcceleration;
  148. float MaxHorizontalAcceleration;
  149. /*
  150. ** Vehicle behavior controls
  151. */
  152. float MaxFuselagePitch; // DEG_TO_RADF(15.0f);
  153. float MaxFuselageRoll; // DEG_TO_RADF(20.0f);
  154. float PitchControllerGain; // 45.5
  155. float PitchControllerDamping; // 12.75
  156. float RollControllerGain; // 45.5
  157. float RollControllerDamping; // 12.75
  158. float MaxYawVelocity; // DEG_TO_RADF(180.0f);
  159. float YawControllerGain; // 5.0f;
  160. /*
  161. ** Engine Graphical Behavior
  162. */
  163. float MaxEngineRotation;
  164. /*
  165. ** Rotor Graphical Behavior
  166. */
  167. float RotorSpeed;
  168. float RotorAcceleration;
  169. float RotorDeceleration;
  170. friend class VTOLVehicleClass;
  171. };
  172. #endif