00001
00002 #ifndef __CW_VEHICLE_H_
00003 #define __CW_VEHICLE_H_
00004
00005 #include "CarWorldClasses.h"
00006
00007
00008 class CWVehicle;
00009
00010
00011 struct CWCommand
00012 {
00013 CWCommand();
00014 REAL GasBrake;
00015 REAL Steer;
00016 REAL SteerFeedBack;
00017 bool HandBrake;
00018 };
00019
00020 class Wheel
00021 {
00022 public:
00023 Wheel(
00024 const Point3D &RelPos = Point3D(),
00025 REAL SpringStiffness = 30000,
00026 REAL MaxTravel = -0.5f,
00027 REAL MaxLoad = 5000,
00028 REAL WheelRadius = 0.4f,
00029 REAL DamperCompression = 2000,
00030 REAL DamperRebound = 2000,
00031 REAL Grip = 1.0f,
00032 REAL AccelFactor = 4000,
00033 REAL BrakeFactor = 4000,
00034 REAL SteerFactor = .5f,
00035 bool LockUp = true
00036 );
00037 void draw_init();
00038 void reset();
00039 void Set(
00040 const Ref &ARef,
00041 CWCommand &ACommand,
00042 CarWorld &CW
00043 );
00044
00045 Point3D CalcForce();
00046 FixedVector &GetRay();
00047 void draw();
00048
00049
00050 public:
00051 OFFObject Model;
00052 string ModelFile;
00053 Point3D ModelPos;
00054 Point3D ModelScale;
00055
00056 Point3D RelPos;
00057 REAL SpringStiffness;
00058 REAL MaxTravel;
00059 REAL MaxLoad;
00060 REAL WheelRadius;
00061 REAL DamperCompression;
00062 REAL DamperRebound;
00063 REAL Grip;
00064 REAL AccelFactor;
00065 REAL BrakeFactor;
00066 REAL SteerFactor;
00067 bool LockUp;
00068
00069
00070 public:
00071 REAL Thrust;
00072 REAL Angle;
00073 bool Lock;
00074 Point3D Acceleration;
00075 Ref MyRef;
00076 Point3D LandSpeed, LandDirection;
00077 FixedVector Ray;
00078 REAL Gs;
00079 REAL Travel, DeltaTravel;
00080 Contact MyContact;
00081 };
00082
00083
00084 struct CWVehicleState
00085 {
00086 Ref m_Ref;
00087 CWCommand m_Command;
00088 };
00089
00090 class CWVehicle : public CWFeature
00091 {
00092 public:
00093 CWVehicle(const char *name);
00094 void load(const char *name);
00095 virtual ~CWVehicle();
00096 void reset();
00097 void update();
00098 REAL GetSpeed() const;
00099
00100
00101
00102 void UpdateCWVehicleParams();
00103
00104 void draw_init();
00105 void draw();
00106 void drawShape();
00107 void ProjectShadow(const Point3D &LightDirection);
00108 void drawInfo();
00109
00110 CWVehicleState GetState();
00111 void SetState(CWVehicleState &state);
00112 public:
00113
00114 string ModelFile;
00115 Point3D ModelPos;
00116 Point3D ModelScale;
00117
00118 Point3D InitPos;
00119
00120 REAL Mass;
00121 REAL Weight;
00122 REAL MassDistrib;
00123
00124 REAL RedLine;
00125 REAL MaxTorque;
00126 REAL Friction;
00127
00128
00129 CWCommand MyCommand;
00130 DriveTrain MyDriveTrain;
00131 InertRef MyRef;
00132 vector<Wheel> Wheels;
00133 OFFObject Model;
00134 };
00135
00136 #endif //__CW_VEHICLE_H_