vehiclecurve.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 : LevelEdit *
  23. * *
  24. * $Archive:: /VSS_Sync/wwmath/vehiclecurve.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 6/13/01 2:18p $*
  29. * *
  30. * $Revision:: 6 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __VEHICLE_CURVE_H
  39. #define __VEHICLE_CURVE_H
  40. #include "curve.h"
  41. #include "vector.h"
  42. ////////////////////////////////////////////////////////////////////////////////////////////
  43. //
  44. // VehicleCurveClass
  45. //
  46. // A vehicle curve represents the path a vehicle would take through a series of points.
  47. // Each point on the curve passes through a turn-arc of the vehicle. The size of this
  48. // arc is determined by the turn radius which is used to initialize the curve.
  49. //
  50. ////////////////////////////////////////////////////////////////////////////////////////////
  51. class VehicleCurveClass : public Curve3DClass
  52. {
  53. public:
  54. ///////////////////////////////////////////////////////////////////////////
  55. // Public constructors/destructors
  56. ///////////////////////////////////////////////////////////////////////////
  57. VehicleCurveClass (void)
  58. : m_IsDirty (true),
  59. m_Radius (0),
  60. m_LastTime (0),
  61. m_Sharpness (0),
  62. m_SharpnessPos (0, 0, 0),
  63. Curve3DClass () { }
  64. VehicleCurveClass (float radius)
  65. : m_IsDirty (true),
  66. m_Radius (radius),
  67. m_LastTime (0),
  68. m_Sharpness (0),
  69. m_SharpnessPos (0, 0, 0),
  70. Curve3DClass () { }
  71. virtual ~VehicleCurveClass () {}
  72. ///////////////////////////////////////////////////////////////////////////
  73. // Public methods
  74. ///////////////////////////////////////////////////////////////////////////
  75. //
  76. // Initialization
  77. //
  78. void Initialize_Arc (float radius);
  79. //
  80. // From Curve3DClass
  81. //
  82. void Evaluate (float time, Vector3 *set_val);
  83. void Set_Key (int i,const Vector3 & point);
  84. int Add_Key (const Vector3 & point,float t);
  85. void Remove_Key (int i);
  86. void Clear_Keys (void);
  87. //
  88. // Vehicle curve specific
  89. //
  90. float Get_Current_Sharpness (Vector3 *position) const { *position = m_SharpnessPos; return m_Sharpness; }
  91. float Get_Last_Eval_Time (void) const { return m_LastTime; }
  92. //
  93. // Save-load support
  94. //
  95. virtual const PersistFactoryClass & Get_Factory(void) const;
  96. virtual bool Save(ChunkSaveClass &csave);
  97. virtual bool Load(ChunkLoadClass &cload);
  98. protected:
  99. ///////////////////////////////////////////////////////////////////////////
  100. // Protected methods
  101. ///////////////////////////////////////////////////////////////////////////
  102. void Update_Arc_List (void);
  103. void Load_Variables (ChunkLoadClass &cload);
  104. ///////////////////////////////////////////////////////////////////////////
  105. // Protected data types
  106. ///////////////////////////////////////////////////////////////////////////
  107. typedef struct _ArcInfoStruct
  108. {
  109. Vector3 center;
  110. Vector3 point_in;
  111. Vector3 point_out;
  112. float point_angle;
  113. float radius;
  114. float angle_in_delta;
  115. float angle_out_delta;
  116. _ArcInfoStruct (void)
  117. : center (0, 0, 0),
  118. point_in (0, 0, 0),
  119. point_out (0, 0, 0),
  120. point_angle (0),
  121. radius (0),
  122. angle_in_delta (0),
  123. angle_out_delta (0) { }
  124. bool operator== (const _ArcInfoStruct &src) { return false; }
  125. bool operator!= (const _ArcInfoStruct &src) { return true; }
  126. } ArcInfoStruct;
  127. typedef DynamicVectorClass<ArcInfoStruct> ARC_LIST;
  128. ///////////////////////////////////////////////////////////////////////////
  129. // Protected member data
  130. ///////////////////////////////////////////////////////////////////////////
  131. bool m_IsDirty;
  132. float m_Radius;
  133. ARC_LIST m_ArcList;
  134. float m_LastTime;
  135. float m_Sharpness;
  136. Vector3 m_SharpnessPos;
  137. };
  138. ///////////////////////////////////////////////////////////////////////////
  139. // Set_Key
  140. ///////////////////////////////////////////////////////////////////////////
  141. inline void
  142. VehicleCurveClass::Set_Key (int i,const Vector3 & point)
  143. {
  144. m_IsDirty = true;
  145. Curve3DClass::Set_Key (i, point);
  146. return ;
  147. }
  148. ///////////////////////////////////////////////////////////////////////////
  149. // Add_Key
  150. ///////////////////////////////////////////////////////////////////////////
  151. inline int
  152. VehicleCurveClass::Add_Key (const Vector3 & point,float t)
  153. {
  154. m_IsDirty = true;
  155. return Curve3DClass::Add_Key (point, t);
  156. }
  157. ///////////////////////////////////////////////////////////////////////////
  158. // Remove_Key
  159. ///////////////////////////////////////////////////////////////////////////
  160. inline void
  161. VehicleCurveClass::Remove_Key (int i)
  162. {
  163. m_IsDirty = true;
  164. Curve3DClass::Remove_Key (i);
  165. return ;
  166. }
  167. ///////////////////////////////////////////////////////////////////////////
  168. // Clear_Keys
  169. ///////////////////////////////////////////////////////////////////////////
  170. inline void
  171. VehicleCurveClass::Clear_Keys (void)
  172. {
  173. m_IsDirty = true;
  174. Curve3DClass::Clear_Keys ();
  175. return ;
  176. }
  177. #endif //__VEHICLE_CURVE_H