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_CORE_COMPONENTS_H
00031 #define PX_VEHICLE_CORE_COMPONENTS_H
00032
00036 #include "foundation/PxMemory.h"
00037 #include "foundation/PxVec3.h"
00038 #include "common/PxCoreUtilityTypes.h"
00039 #include "PxVehicleSDK.h"
00040 #include "common/PxTypeInfo.h"
00041
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046
00047 class PxVehicleChassisData
00048 {
00049 public:
00050
00051 friend class PxVehicleDriveSimData4W;
00052
00053 PxVehicleChassisData()
00054 : mMOI(PxVec3(0,0,0)),
00055 mMass(1500),
00056 mCMOffset(PxVec3(0,0,0))
00057 {
00058 }
00059
00065 PxVec3 mMOI;
00066
00072 PxReal mMass;
00073
00079 PxVec3 mCMOffset;
00080
00081 private:
00082
00083 PxReal pad;
00084
00085 bool isValid() const;
00086 };
00087 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleChassisData)& 0x0f));
00088
00089 class PxVehicleEngineData
00090 {
00091 public:
00092
00093 friend class PxVehicleDriveSimData;
00094
00095 enum
00096 {
00097 eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8
00098 };
00099
00100 PxVehicleEngineData()
00101 : mMOI(1.0f),
00102 mPeakTorque(500.0f),
00103 mMaxOmega(600.0f),
00104 mDampingRateFullThrottle(0.15f),
00105 mDampingRateZeroThrottleClutchEngaged(2.0f),
00106 mDampingRateZeroThrottleClutchDisengaged(0.35f)
00107 {
00108 mTorqueCurve.addPair(0.0f, 0.8f);
00109 mTorqueCurve.addPair(0.33f, 1.0f);
00110 mTorqueCurve.addPair(1.0f, 0.8f);
00111
00112 mRecipMOI=1.0f/mMOI;
00113 mRecipMaxOmega=1.0f/mMaxOmega;
00114 }
00115
00121 PxFixedSizeLookupTable<eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES> mTorqueCurve;
00122
00128 PxReal mMOI;
00129
00139 PxReal mPeakTorque;
00140
00148 PxReal mMaxOmega;
00149
00165 PxReal mDampingRateFullThrottle;
00166
00167
00183 PxReal mDampingRateZeroThrottleClutchEngaged;
00184
00200 PxReal mDampingRateZeroThrottleClutchDisengaged;
00201
00205 PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;}
00206
00210 PX_FORCE_INLINE PxReal getRecipMaxOmega() const {return mRecipMaxOmega;}
00211
00212 private:
00213
00221 PxReal mRecipMOI;
00222
00230 PxReal mRecipMaxOmega;
00231
00232 bool isValid() const;
00233
00234
00235
00236 public:
00237 PxVehicleEngineData(const PxEMPTY) : mTorqueCurve(PxEmpty) {}
00238
00239 };
00240 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleEngineData)& 0x0f));
00241
00242 class PxVehicleGearsData
00243 {
00244 public:
00245
00246 friend class PxVehicleDriveSimData;
00247
00248 enum Enum
00249 {
00250 eREVERSE=0,
00251 eNEUTRAL,
00252 eFIRST,
00253 eSECOND,
00254 eTHIRD,
00255 eFOURTH,
00256 eFIFTH,
00257 eSIXTH,
00258 eSEVENTH,
00259 eEIGHTH,
00260 eNINTH,
00261 eTENTH,
00262 eELEVENTH,
00263 eTWELFTH,
00264 eTHIRTEENTH,
00265 eFOURTEENTH,
00266 eFIFTEENTH,
00267 eSIXTEENTH,
00268 eSEVENTEENTH,
00269 eEIGHTEENTH,
00270 eNINETEENTH,
00271 eTWENTIETH,
00272 eTWENTYFIRST,
00273 eTWENTYSECOND,
00274 eTWENTYTHIRD,
00275 eTWENTYFOURTH,
00276 eTWENTYFIFTH,
00277 eTWENTYSIXTH,
00278 eTWENTYSEVENTH,
00279 eTWENTYEIGHTH,
00280 eTWENTYNINTH,
00281 eTHIRTIETH,
00282 eGEARSRATIO_COUNT
00283 };
00284
00285 PxVehicleGearsData()
00286 : mFinalRatio(4.0f),
00287 mNbRatios(7),
00288 mSwitchTime(0.5f)
00289 {
00290 mRatios[PxVehicleGearsData::eREVERSE]=-4.0f;
00291 mRatios[PxVehicleGearsData::eNEUTRAL]=0.0f;
00292 mRatios[PxVehicleGearsData::eFIRST]=4.0f;
00293 mRatios[PxVehicleGearsData::eSECOND]=2.0f;
00294 mRatios[PxVehicleGearsData::eTHIRD]=1.5f;
00295 mRatios[PxVehicleGearsData::eFOURTH]=1.1f;
00296 mRatios[PxVehicleGearsData::eFIFTH]=1.0f;
00297
00298 for(PxU32 i = PxVehicleGearsData::eSIXTH; i < PxVehicleGearsData::eGEARSRATIO_COUNT; ++i)
00299 mRatios[i]=0.f;
00300 }
00301
00307 PxReal mRatios[PxVehicleGearsData::eGEARSRATIO_COUNT];
00308
00314 PxReal mFinalRatio;
00315
00321 PxU32 mNbRatios;
00322
00330 PxReal mSwitchTime;
00331
00332 private:
00333
00334 PxReal mPad;
00335
00336 bool isValid() const;
00337
00338
00339 public:
00340 PxVehicleGearsData(const PxEMPTY) {}
00341 PxReal getGearRatio(PxVehicleGearsData::Enum a) const {return mRatios[a];}
00342 void setGearRatio(PxVehicleGearsData::Enum a, PxReal ratio) { mRatios[a] = ratio;}
00343
00344 };
00345 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGearsData)& 0x0f));
00346
00347 class PxVehicleAutoBoxData
00348 {
00349 public:
00350
00351 friend class PxVehicleDriveSimData;
00352
00353 PxVehicleAutoBoxData()
00354 {
00355 for(PxU32 i=0;i<PxVehicleGearsData::eGEARSRATIO_COUNT;i++)
00356 {
00357 mUpRatios[i]=0.65f;
00358 mDownRatios[i]=0.50f;
00359 }
00360
00361 mUpRatios[PxVehicleGearsData::eNEUTRAL]=0.15f;
00362
00363 mDownRatios[PxVehicleGearsData::eREVERSE]=2.0f;
00364 }
00365
00374 PxReal mUpRatios[PxVehicleGearsData::eGEARSRATIO_COUNT];
00375
00384 PxReal mDownRatios[PxVehicleGearsData::eGEARSRATIO_COUNT];
00385
00397 void setLatency(const PxReal latency)
00398 {
00399 mDownRatios[PxVehicleGearsData::eREVERSE]=latency;
00400 }
00401
00409 PxReal getLatency() const
00410 {
00411 return mDownRatios[PxVehicleGearsData::eREVERSE];
00412 }
00413
00414 private:
00415 bool isValid() const;
00416
00417
00418 public:
00419 PxVehicleAutoBoxData(const PxEMPTY) {}
00420
00421 PxReal getUpRatios(PxVehicleGearsData::Enum a) const {return mUpRatios[a];}
00422 void setUpRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mUpRatios[a] = ratio;}
00423
00424 PxReal getDownRatios(PxVehicleGearsData::Enum a) const {return mDownRatios[a];}
00425 void setDownRatios(PxVehicleGearsData::Enum a, PxReal ratio) { mDownRatios[a] = ratio;}
00426
00427 };
00428 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAutoBoxData)& 0x0f));
00429
00430 class PxVehicleDifferential4WData
00431 {
00432 public:
00433
00434 friend class PxVehicleDriveSimData4W;
00435
00436 enum Enum
00437 {
00438 eDIFF_TYPE_LS_4WD,
00439 eDIFF_TYPE_LS_FRONTWD,
00440 eDIFF_TYPE_LS_REARWD,
00441 eDIFF_TYPE_OPEN_4WD,
00442 eDIFF_TYPE_OPEN_FRONTWD,
00443 eDIFF_TYPE_OPEN_REARWD,
00444 eMAX_NB_DIFF_TYPES
00445 };
00446
00447 PxVehicleDifferential4WData()
00448 : mFrontRearSplit(0.45f),
00449 mFrontLeftRightSplit(0.5f),
00450 mRearLeftRightSplit(0.5f),
00451 mCentreBias(1.3f),
00452 mFrontBias(1.3f),
00453 mRearBias(1.3f),
00454 mType(PxVehicleDifferential4WData::eDIFF_TYPE_LS_4WD)
00455 {
00456 }
00457
00465 PxReal mFrontRearSplit;
00466
00474 PxReal mFrontLeftRightSplit;
00475
00483 PxReal mRearLeftRightSplit;
00484
00493 PxReal mCentreBias;
00494
00503 PxReal mFrontBias;
00504
00513 PxReal mRearBias;
00514
00520 PxVehicleDifferential4WData::Enum mType;
00521
00522 private:
00523
00524 PxReal mPad[1];
00525
00526 bool isValid() const;
00527
00528
00529 public:
00530 PxVehicleDifferential4WData(const PxEMPTY) {}
00531
00532 };
00533 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDifferential4WData)& 0x0f));
00534
00535 class PxVehicleDifferentialNWData
00536 {
00537 public:
00538
00539 friend class PxVehicleDriveSimDataNW;
00540 friend class PxVehicleUpdate;
00541
00542 PxVehicleDifferentialNWData()
00543 {
00544 PxMemSet(mBitmapBuffer, 0, sizeof(PxU32) * (((PX_MAX_NB_WHEELS + 31) & ~31) >> 5));
00545 mNbDrivenWheels=0;
00546 mInvNbDrivenWheels=0.0f;
00547 }
00548
00556 void setDrivenWheel(const PxU32 wheelId, const bool drivenState);
00557
00561 bool getIsDrivenWheel(const PxU32 wheelId) const;
00562
00563 private:
00564
00565 PxU32 mBitmapBuffer[((PX_MAX_NB_WHEELS + 31) & ~31) >> 5];
00566 PxU32 mNbDrivenWheels;
00567 PxReal mInvNbDrivenWheels;
00568 PxU32 mPad;
00569
00570 bool isValid() const;
00571
00572
00573 public:
00574 PxVehicleDifferentialNWData(const PxEMPTY) {}
00575 PxU32 getDrivenWheelStatus() const;
00576 void setDrivenWheelStatus(PxU32 status);
00577
00578 };
00579 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDifferentialNWData)& 0x0f));
00580
00581
00582 class PxVehicleAckermannGeometryData
00583 {
00584 public:
00585
00586 friend class PxVehicleDriveSimData4W;
00587
00588 PxVehicleAckermannGeometryData()
00589 : mAccuracy(1.0f),
00590 mFrontWidth(0.0f),
00591 mRearWidth(0.0f),
00592 mAxleSeparation(0.0f)
00593 {
00594 }
00595
00611 PxReal mAccuracy;
00612
00620 PxReal mFrontWidth;
00621
00629 PxReal mRearWidth;
00630
00638 PxReal mAxleSeparation;
00639
00640 private:
00641
00642 bool isValid() const;
00643
00644
00645 public:
00646 PxVehicleAckermannGeometryData(const PxEMPTY) {}
00647
00648 };
00649 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAckermannGeometryData)& 0x0f));
00650
00655 struct PxVehicleClutchAccuracyMode
00656 {
00657 enum Enum
00658 {
00659 eESTIMATE = 0,
00660 eBEST_POSSIBLE
00661 };
00662 };
00663
00664 class PxVehicleClutchData
00665 {
00666 public:
00667
00668 friend class PxVehicleDriveSimData;
00669
00670 PxVehicleClutchData()
00671 : mStrength(10.0f),
00672 mAccuracyMode(PxVehicleClutchAccuracyMode::eBEST_POSSIBLE),
00673 mEstimateIterations(5)
00674 {
00675 }
00676
00695 PxReal mStrength;
00696
00711 PxVehicleClutchAccuracyMode::Enum mAccuracyMode;
00712
00724 PxU32 mEstimateIterations;
00725
00726 private:
00727
00728 PxU8 mPad[4];
00729
00730 bool isValid() const;
00731
00732
00733 public:
00734 PxVehicleClutchData(const PxEMPTY) {}
00735
00736 };
00737 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleClutchData)& 0x0f));
00738
00739
00762 class PxVehicleTireLoadFilterData
00763 {
00764 public:
00765
00766 friend class PxVehicleWheelsSimData;
00767
00768 PxVehicleTireLoadFilterData()
00769 : mMinNormalisedLoad(0),
00770 mMinFilteredNormalisedLoad(0.2308f),
00771 mMaxNormalisedLoad(3.0f),
00772 mMaxFilteredNormalisedLoad(3.0f)
00773 {
00774 mDenominator=1.0f/(mMaxNormalisedLoad - mMinNormalisedLoad);
00775 }
00776
00780 PxReal mMinNormalisedLoad;
00781
00785 PxReal mMinFilteredNormalisedLoad;
00786
00790 PxReal mMaxNormalisedLoad;
00791
00795 PxReal mMaxFilteredNormalisedLoad;
00796
00797 PX_FORCE_INLINE PxReal getDenominator() const {return mDenominator;}
00798
00799 private:
00800
00804
00805 PxReal mDenominator;
00806
00807 PxU32 mPad[3];
00808
00809 bool isValid() const;
00810
00811
00812 public:
00813 PxVehicleTireLoadFilterData(const PxEMPTY) {}
00814
00815 };
00816 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireLoadFilterData)& 0x0f));
00817
00818 class PxVehicleWheelData
00819 {
00820 public:
00821
00822 friend class PxVehicleWheels4SimData;
00823
00824 PxVehicleWheelData()
00825 : mRadius(0.0f),
00826 mWidth(0.0f),
00827 mMass(20.0f),
00828 mMOI(0.0f),
00829 mDampingRate(0.25f),
00830 mMaxBrakeTorque(1500.0f),
00831 mMaxHandBrakeTorque(0.0f),
00832 mMaxSteer(0.0f),
00833 mToeAngle(0.0f),
00834 mRecipRadius(0.0f),
00835 mRecipMOI(0.0f)
00836 {
00837 }
00838
00846 PxReal mRadius;
00847
00855 PxReal mWidth;
00856
00864 PxReal mMass;
00865
00873 PxReal mMOI;
00874
00882 PxReal mDampingRate;
00883
00891 PxReal mMaxBrakeTorque;
00892
00900 PxReal mMaxHandBrakeTorque;
00901
00909 PxReal mMaxSteer;
00910
00918 PxReal mToeAngle;
00919
00925 PX_FORCE_INLINE PxReal getRecipRadius() const {return mRecipRadius;}
00926
00932 PX_FORCE_INLINE PxReal getRecipMOI() const {return mRecipMOI;}
00933
00934 private:
00935
00943 PxReal mRecipRadius;
00944
00952 PxReal mRecipMOI;
00953
00954 PxReal mPad[1];
00955
00956 bool isValid() const;
00957 };
00958 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelData)& 0x0f));
00959
00960 class PxVehicleSuspensionData
00961 {
00962 public:
00963
00964 friend class PxVehicleWheels4SimData;
00965
00966 PxVehicleSuspensionData()
00967 : mSpringStrength(0.0f),
00968 mSpringDamperRate(0.0f),
00969 mMaxCompression(0.3f),
00970 mMaxDroop(0.1f),
00971 mSprungMass(0.0f),
00972 mCamberAtRest(0.0f),
00973 mCamberAtMaxCompression(0.0f),
00974 mCamberAtMaxDroop(0.0f),
00975 mRecipMaxCompression(1.0f),
00976 mRecipMaxDroop(1.0f)
00977 {
00978 }
00979
00987 PxReal mSpringStrength;
00988
00996 PxReal mSpringDamperRate;
00997
01005 PxReal mMaxCompression;
01006
01014 PxReal mMaxDroop;
01015
01047 PxReal mSprungMass;
01048
01057 PxReal mCamberAtRest;
01058
01069 PxReal mCamberAtMaxCompression;
01070
01081 PxReal mCamberAtMaxDroop;
01082
01090 PX_FORCE_INLINE PxReal getRecipMaxCompression() const {return mRecipMaxCompression;}
01091
01099 PX_FORCE_INLINE PxReal getRecipMaxDroop() const {return mRecipMaxDroop;}
01100
01106 void setMassAndPreserveNaturalFrequency(const PxReal newSprungMass)
01107 {
01108 const PxF32 oldStrength = mSpringStrength;
01109 const PxF32 oldSprungMass = mSprungMass;
01110 const PxF32 newStrength = oldStrength * (newSprungMass / oldSprungMass);
01111 mSpringStrength = newStrength;
01112 mSprungMass = newSprungMass;
01113 }
01114
01115 private:
01116
01122 PxReal mRecipMaxCompression;
01123
01129 PxReal mRecipMaxDroop;
01130
01131
01132 PxReal mPad[2];
01133
01134 bool isValid() const;
01135 };
01136 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleSuspensionData)& 0x0f));
01137
01138 class PxVehicleAntiRollBarData
01139 {
01140 public:
01141
01142 friend class PxVehicleWheelsSimData;
01143
01144 PxVehicleAntiRollBarData()
01145 : mWheel0(0xffffffff),
01146 mWheel1(0xffffffff),
01147 mStiffness(0.0f)
01148 {
01149 }
01150
01151
01152
01153
01154 PxU32 mWheel0;
01155
01156
01157
01158
01159 PxU32 mWheel1;
01160
01161
01162
01163
01164
01165
01166
01167
01168 PxF32 mStiffness;
01169
01170 private:
01171
01172 PxF32 mPad[1];
01173
01174 bool isValid() const;
01175 };
01176 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleAntiRollBarData)& 0x0f));
01177
01178 class PxVehicleTireData
01179 {
01180 public:
01181 friend class PxVehicleWheels4SimData;
01182
01183 PxVehicleTireData()
01184 : mLatStiffX(2.0f),
01185 mLatStiffY(0.3125f*(180.0f / PxPi)),
01186 mLongitudinalStiffnessPerUnitGravity(1000.0f),
01187 mCamberStiffnessPerUnitGravity(0.1f*(180.0f / PxPi)),
01188 mType(0)
01189 {
01190 mFrictionVsSlipGraph[0][0]=0.0f;
01191 mFrictionVsSlipGraph[0][1]=1.0f;
01192 mFrictionVsSlipGraph[1][0]=0.1f;
01193 mFrictionVsSlipGraph[1][1]=1.0f;
01194 mFrictionVsSlipGraph[2][0]=1.0f;
01195 mFrictionVsSlipGraph[2][1]=1.0f;
01196
01197 mRecipLongitudinalStiffnessPerUnitGravity=1.0f/mLongitudinalStiffnessPerUnitGravity;
01198
01199 mFrictionVsSlipGraphRecipx1Minusx0=1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0]);
01200 mFrictionVsSlipGraphRecipx2Minusx1=1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0]);
01201 }
01202
01210 PxReal mLatStiffX;
01211
01227 PxReal mLatStiffY;
01228
01240 PxReal mLongitudinalStiffnessPerUnitGravity;
01241
01253 PxReal mCamberStiffnessPerUnitGravity;
01254
01288 PxReal mFrictionVsSlipGraph[3][2];
01289
01297 PxU32 mType;
01298
01304 PX_FORCE_INLINE PxReal getRecipLongitudinalStiffnessPerUnitGravity() const {return mRecipLongitudinalStiffnessPerUnitGravity;}
01305
01311 PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx1Minusx0() const {return mFrictionVsSlipGraphRecipx1Minusx0;}
01312
01318 PX_FORCE_INLINE PxReal getFrictionVsSlipGraphRecipx2Minusx1() const {return mFrictionVsSlipGraphRecipx2Minusx1;}
01319
01320 private:
01321
01329 PxReal mRecipLongitudinalStiffnessPerUnitGravity;
01330
01338 PxReal mFrictionVsSlipGraphRecipx1Minusx0;
01339
01347 PxReal mFrictionVsSlipGraphRecipx2Minusx1;
01348
01349 PxReal mPad[2];
01350
01351 bool isValid() const;
01352 };
01353 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTireData)& 0x0f));
01354 #if !PX_DOXYGEN
01355 }
01356 #endif
01357
01359 #endif //PX_VEHICLE_CORE_COMPONENTS_H