00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef PX_VEHICLE_DRIVE_H
00031 #define PX_VEHICLE_DRIVE_H
00032
00036 #include "vehicle/PxVehicleWheels.h"
00037 #include "vehicle/PxVehicleComponents.h"
00038
00039 #if !PX_DOXYGEN
00040 namespace physx
00041 {
00042 #endif
00043
00044 struct PxFilterData;
00045 class PxGeometry;
00046 class PxPhysics;
00047 class PxBatchQuery;
00048 class PxVehicleDrivableSurfaceToTireFrictionPairs;
00049 class PxShape;
00050 class PxMaterial;
00051 class PxRigidDynamic;
00052
00057 class PxVehicleDriveSimData
00058 {
00059
00060
00061
00062
00063
00064
00065 public:
00066
00067 friend class PxVehicleDriveTank;
00068
00072 PX_FORCE_INLINE const PxVehicleEngineData& getEngineData() const
00073 {
00074 return mEngine;
00075 }
00076
00081 void setEngineData(const PxVehicleEngineData& engine);
00082
00086 PX_FORCE_INLINE const PxVehicleGearsData& getGearsData() const
00087 {
00088 return mGears;
00089 }
00090
00095 void setGearsData(const PxVehicleGearsData& gears);
00096
00100 PX_FORCE_INLINE const PxVehicleClutchData& getClutchData() const
00101 {
00102 return mClutch;
00103 }
00104
00109 void setClutchData(const PxVehicleClutchData& clutch);
00110
00114 PX_FORCE_INLINE const PxVehicleAutoBoxData& getAutoBoxData() const
00115 {
00116 return mAutoBox;
00117 }
00118
00123 void setAutoBoxData(const PxVehicleAutoBoxData& autobox);
00124
00125 protected:
00126
00127
00128
00129
00130 PxVehicleEngineData mEngine;
00131
00132
00133
00134
00135
00136 PxVehicleGearsData mGears;
00137
00138
00139
00140
00141
00142 PxVehicleClutchData mClutch;
00143
00144
00145
00146
00147
00148 PxVehicleAutoBoxData mAutoBox;
00149
00155 bool isValid() const;
00156
00157
00158
00159 public:
00160 PxVehicleDriveSimData() {}
00161 PxVehicleDriveSimData(const PxEMPTY) : mEngine(PxEmpty), mGears(PxEmpty), mClutch(PxEmpty), mAutoBox(PxEmpty) {}
00162 static void getBinaryMetaData(PxOutputStream& stream);
00163
00164 };
00165 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimData) & 15));
00166
00167
00172 class PxVehicleDriveDynData
00173 {
00174 public:
00175
00176 enum
00177 {
00178 eMAX_NB_ANALOG_INPUTS=16
00179 };
00180
00181 friend class PxVehicleDrive;
00182
00186 void setToRestState();
00187
00194 void setAnalogInput(const PxU32 type, const PxReal analogVal);
00195
00201 PxReal getAnalogInput(const PxU32 type) const;
00202
00212 void setGearUp(const bool digitalVal)
00213 {
00214 mGearUpPressed = digitalVal;
00215 }
00216
00226 void setGearDown(const bool digitalVal)
00227 {
00228 mGearDownPressed = digitalVal;
00229 }
00230
00235 bool getGearUp() const
00236 {
00237 return mGearUpPressed;
00238 }
00239
00244 bool getGearDown() const
00245 {
00246 return mGearDownPressed;
00247 }
00248
00254 PX_FORCE_INLINE void setUseAutoGears(const bool useAutoGears)
00255 {
00256 mUseAutoGears=useAutoGears;
00257 }
00258
00263 PX_FORCE_INLINE bool getUseAutoGears() const
00264 {
00265 return mUseAutoGears;
00266 }
00267
00272 PX_FORCE_INLINE void toggleAutoGears()
00273 {
00274 mUseAutoGears = !mUseAutoGears;
00275 }
00276
00288 PX_FORCE_INLINE void setCurrentGear(PxU32 currentGear)
00289 {
00290 mCurrentGear = currentGear;
00291 }
00292
00300 PX_FORCE_INLINE PxU32 getCurrentGear() const
00301 {
00302 return mCurrentGear;
00303 }
00304
00316 PX_FORCE_INLINE void setTargetGear(PxU32 targetGear)
00317 {
00318 mTargetGear = targetGear;
00319 }
00320
00328 PX_FORCE_INLINE PxU32 getTargetGear() const
00329 {
00330 return mTargetGear;
00331 }
00332
00342 PX_FORCE_INLINE void startGearChange(const PxU32 targetGear)
00343 {
00344 mTargetGear=targetGear;
00345 }
00346
00354 PX_FORCE_INLINE void forceGearChange(const PxU32 targetGear)
00355 {
00356 mTargetGear=targetGear;
00357 mCurrentGear=targetGear;
00358 }
00359
00365 PX_FORCE_INLINE void setEngineRotationSpeed(const PxF32 speed)
00366 {
00367 mEnginespeed = speed;
00368 }
00369
00375 PX_FORCE_INLINE PxReal getEngineRotationSpeed() const
00376 {
00377 return mEnginespeed;
00378 }
00379
00389 PX_FORCE_INLINE PxReal getGearSwitchTime() const
00390 {
00391 return mGearSwitchTime;
00392 }
00393
00401 PX_FORCE_INLINE PxReal getAutoBoxSwitchTime() const
00402 {
00403 return mAutoBoxSwitchTime;
00404 }
00405
00415 PxReal mControlAnalogVals[eMAX_NB_ANALOG_INPUTS];
00416
00421 bool mUseAutoGears;
00422
00430 bool mGearUpPressed;
00431
00439 bool mGearDownPressed;
00440
00445 PxU32 mCurrentGear;
00446
00451 PxU32 mTargetGear;
00452
00457 PxReal mEnginespeed;
00458
00463 PxReal mGearSwitchTime;
00464
00469 PxReal mAutoBoxSwitchTime;
00470
00471 private:
00472 PxU32 mPad[2];
00473
00478 bool isValid() const;
00479
00480
00481 public:
00482 PxVehicleDriveDynData();
00483 PxVehicleDriveDynData(const PxEMPTY) {}
00484 PxU32 getNbAnalogInput() const { return eMAX_NB_ANALOG_INPUTS; }
00485 PX_FORCE_INLINE void setGearChange(const PxU32 gearChange) { mTargetGear= gearChange; }
00486 PX_FORCE_INLINE PxU32 getGearChange() const { return mTargetGear; }
00487 PX_FORCE_INLINE void setGearSwitchTime(const PxReal switchTime) { mGearSwitchTime = switchTime; }
00488 PX_FORCE_INLINE void setAutoBoxSwitchTime(const PxReal autoBoxSwitchTime) { mAutoBoxSwitchTime = autoBoxSwitchTime; }
00489
00490 };
00491 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveDynData) & 15));
00492
00497 class PxVehicleDrive : public PxVehicleWheels
00498 {
00499
00500
00501
00502
00503
00504
00505 public:
00506
00507 friend class PxVehicleUpdate;
00508
00513 PxVehicleDriveDynData mDriveDynData;
00514
00515 protected:
00516
00520 bool isValid() const;
00521
00525 void setToRestState();
00526
00530 static PxU32 computeByteSize(const PxU32 numWheels);
00531 static PxU8* patchupPointers(const PxU32 nbWheels, PxVehicleDrive* vehDrive, PxU8* ptr);
00532 virtual void init(const PxU32 numWheels);
00533
00538 void free();
00539
00543 void setup
00544 (PxPhysics* physics, PxRigidDynamic* vehActor,
00545 const PxVehicleWheelsSimData& wheelsData,
00546 const PxU32 nbDrivenWheels, const PxU32 nbNonDrivenWheels);
00547
00548
00549 public:
00550 static void getBinaryMetaData(PxOutputStream& stream);
00551 PxVehicleDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags), mDriveDynData(PxEmpty) {}
00552 virtual const char* getConcreteTypeName() const { return "PxVehicleDrive"; }
00553 protected:
00554 PxVehicleDrive(PxType concreteType, PxBaseFlags baseFlags) : PxVehicleWheels(concreteType, baseFlags) {}
00555 ~PxVehicleDrive() {}
00556 virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleDrive", name) || PxBase::isKindOf(name); }
00557
00558 };
00559 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive) & 15));
00560
00561 #if !PX_DOXYGEN
00562 }
00563 #endif
00564
00566 #endif //PX_VEHICLE_DRIVE_H