wheelvehicle.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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/wheelvehicle.h $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 9/20/01 1:57p $*
  29. * *
  30. * $Revision:: 22 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef WHEELVEHICLE_H
  39. #define WHEELVEHICLE_H
  40. #ifndef ALWAYS_H
  41. #include "always.h"
  42. #endif
  43. #ifndef MOTORVEHICLE_H
  44. #include "motorvehicle.h"
  45. #endif
  46. #ifndef LOOKUPTABLE_H
  47. #include "lookuptable.h"
  48. #endif
  49. #include "wheel.h"
  50. class WheelClass;
  51. class NormalWheelClass;
  52. class WheeledVehicleDefClass;
  53. /**
  54. ** WheeledVehicleClass
  55. ** This is a derivation of RigidBodyClass which basically adds wheels to
  56. ** a rigid body object. Each wheel detected in the model will have a friction
  57. ** model and a spring-damper force. Each one will "roll" an amount derived
  58. ** from the motion of the contact point for the wheel. Special engine wheels
  59. ** drive the model and steering wheels can be turned. The goal here is for
  60. ** this class to handle all wheeled vehicles in the game. 3, 4, and 6 wheeled
  61. ** vehicles will hopefully be possible...
  62. **
  63. ** Wheeled Vehicle Physics Update Feb 29,2000
  64. ** - The two most important things to simulate are the forces at the contact
  65. ** patches of the tires and the behavior of the engine.
  66. */
  67. class WheeledVehicleClass : public MotorVehicleClass
  68. {
  69. public:
  70. WheeledVehicleClass(void);
  71. virtual ~WheeledVehicleClass(void);
  72. virtual WheeledVehicleClass * As_WheeledVehicleClass(void) { return this; }
  73. const WheeledVehicleDefClass * Get_WheeledVehicleDef(void);
  74. void Init(const WheeledVehicleDefClass & def);
  75. /*
  76. ** Save-Load System
  77. */
  78. virtual const PersistFactoryClass & Get_Factory (void) const;
  79. virtual bool Save (ChunkSaveClass &csave);
  80. virtual bool Load (ChunkLoadClass &cload);
  81. protected:
  82. virtual SuspensionElementClass * Alloc_Suspension_Element(void);
  83. virtual void Compute_Force_And_Torque(Vector3 * force,Vector3 * torque);
  84. virtual float Get_Ideal_Drive_Axle_Angular_Velocity(void);
  85. virtual bool Drive_Wheels_In_Contact(void);
  86. float SteeringAngle;
  87. private:
  88. WheeledVehicleClass(const WheeledVehicleClass &);
  89. WheeledVehicleClass & operator = (const WheeledVehicleClass &);
  90. };
  91. /**
  92. ** WheeledVehicleDefClass
  93. ** Initialization/Editor Integration for WheeledVehicleClass
  94. */
  95. class WheeledVehicleDefClass : public MotorVehicleDefClass
  96. {
  97. public:
  98. WheeledVehicleDefClass(void);
  99. // From DefinitionClass
  100. virtual uint32 Get_Class_ID (void) const;
  101. virtual PersistClass * Create(void) const;
  102. // From PhysDefClass
  103. virtual const char * Get_Type_Name(void) { return "WheeledVehicleDef"; }
  104. virtual bool Is_Type(const char *);
  105. // From PersistClass
  106. virtual const PersistFactoryClass & Get_Factory (void) const;
  107. virtual bool Save(ChunkSaveClass &csave);
  108. virtual bool Load(ChunkLoadClass &cload);
  109. // Read/Write access to our variables
  110. float Get_Max_Steering_Angle(void) const { return MaxSteeringAngle; }
  111. void Set_Max_Steering_Angle(float a) { MaxSteeringAngle = a; }
  112. // Editable interface requirements
  113. DECLARE_EDITABLE(WheeledVehicleDefClass,MotorVehicleDefClass);
  114. protected:
  115. float MaxSteeringAngle; // maximum angle for the steering wheels
  116. friend class WheeledVehicleClass;
  117. };
  118. /*
  119. ** Inline functions
  120. */
  121. inline const WheeledVehicleDefClass * WheeledVehicleClass::Get_WheeledVehicleDef(void)
  122. {
  123. return (WheeledVehicleDefClass *)Definition;
  124. }
  125. #endif