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_UTILSTELEMETRY_H
00031 #define PX_VEHICLE_UTILSTELEMETRY_H
00032
00036 #include "vehicle/PxVehicleSDK.h"
00037 #include "foundation/PxSimpleTypes.h"
00038 #include "foundation/PxVec3.h"
00039
00040 #if !PX_DOXYGEN
00041 namespace physx
00042 {
00043 #endif
00044
00045 #if PX_DEBUG_VEHICLE_ON
00046
00047 class PxVehicleGraphDesc
00048 {
00049
00050 friend class PxVehicleGraph;
00051
00052 PxVehicleGraphDesc();
00053
00058 PxReal mPosX;
00059
00064 PxReal mPosY;
00065
00070 PxReal mSizeX;
00071
00076 PxReal mSizeY;
00077
00081 PxVec3 mBackgroundColor;
00082
00086 PxReal mAlpha;
00087
00088 private:
00089
00090 bool isValid() const;
00091 };
00092
00093 struct PxVehicleGraphChannelDesc
00094 {
00095 public:
00096
00097 friend class PxVehicleGraph;
00098
00099 PxVehicleGraphChannelDesc();
00100
00104 PxReal mMinY;
00105
00109 PxReal mMaxY;
00110
00115 PxReal mMidY;
00116
00120 PxVec3 mColorLow;
00121
00125 PxVec3 mColorHigh;
00126
00130 char* mTitle;
00131
00132 private:
00133
00134 bool isValid() const;
00135 };
00136
00137 struct PxVehicleWheelGraphChannel
00138 {
00139 enum Enum
00140 {
00141 eJOUNCE=0,
00142 eSUSPFORCE,
00143 eTIRELOAD,
00144 eNORMALIZED_TIRELOAD,
00145 eWHEEL_OMEGA,
00146 eTIRE_FRICTION,
00147 eTIRE_LONG_SLIP,
00148 eNORM_TIRE_LONG_FORCE,
00149 eTIRE_LAT_SLIP,
00150 eNORM_TIRE_LAT_FORCE,
00151 eNORM_TIRE_ALIGNING_MOMENT,
00152 eMAX_NB_WHEEL_CHANNELS
00153 };
00154 };
00155
00156 struct PxVehicleDriveGraphChannel
00157 {
00158 enum Enum
00159 {
00160 eENGINE_REVS=0,
00161 eENGINE_DRIVE_TORQUE,
00162 eCLUTCH_SLIP,
00163 eACCEL_CONTROL,
00164 eBRAKE_CONTROL,
00165 eHANDBRAKE_CONTROL,
00166 eSTEER_LEFT_CONTROL,
00167 eSTEER_RIGHT_CONTROL,
00168 eGEAR_RATIO,
00169 eMAX_NB_DRIVE_CHANNELS
00170 };
00171 };
00172
00173 struct PxVehicleGraphType
00174 {
00175 enum Enum
00176 {
00177 eWHEEL=0,
00178 eDRIVE
00179 };
00180 };
00181
00182
00183 class PxVehicleGraph
00184 {
00185 public:
00186
00187 friend class PxVehicleTelemetryData;
00188 friend class PxVehicleUpdate;
00189
00190 enum
00191 {
00192 eMAX_NB_SAMPLES=256
00193 };
00194
00195 enum
00196 {
00197 eMAX_NB_TITLE_CHARS=256
00198 };
00199
00200 enum
00201 {
00202 eMAX_NB_CHANNELS=12
00203 };
00204
00208 void setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType);
00209
00213 void clearRecordedChannelData();
00214
00218 const PxVec3& getBackgroundColor() const {return mBackgroundColor;}
00219
00223 PxReal getBackgroundAlpha() const {return mBackgroundAlpha;}
00224
00233 void getBackgroundCoords(PxReal& xMin, PxReal& yMin, PxReal& xMax, PxReal& yMax) const {xMin = mBackgroundMinX;xMax = mBackgroundMaxX;yMin = mBackgroundMinY;yMax = mBackgroundMaxY;}
00234
00242 void computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const;
00243
00247 PxF32 getLatestValue(const PxU32 channel) const ;
00248
00249 private:
00250
00251
00252 PxReal mChannelMinY[eMAX_NB_CHANNELS];
00253 PxReal mChannelMaxY[eMAX_NB_CHANNELS];
00254
00255 PxReal mChannelMidY[eMAX_NB_CHANNELS];
00256
00257 PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
00258 PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
00259
00260 char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
00261
00262 PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
00263
00264
00265 PxVec3 mBackgroundColor;
00266 PxReal mBackgroundAlpha;
00267 PxReal mBackgroundMinX;
00268 PxReal mBackgroundMaxX;
00269 PxReal mBackgroundMinY;
00270 PxReal mBackgroundMaxY;
00271
00272 PxU32 mSampleTide;
00273
00274 PxU32 mNbChannels;
00275
00276 PxU32 mPad[2];
00277
00278
00279 void setup
00280 (const PxF32 graphSizeX, const PxF32 graphSizeY,
00281 const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
00282 const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
00283 const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00284
00285 void updateTimeSlice(const PxReal* const samples);
00286
00287 void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
00288
00289 void setupEngineGraph
00290 (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
00291 const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00292
00293 void setupWheelGraph
00294 (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
00295 const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00296
00297 PxVehicleGraph();
00298 ~PxVehicleGraph();
00299 };
00300 PX_COMPILE_TIME_ASSERT(PxU32(PxVehicleGraph::eMAX_NB_CHANNELS) >= PxU32(PxVehicleWheelGraphChannel::eMAX_NB_WHEEL_CHANNELS) && PxU32(PxVehicleGraph::eMAX_NB_CHANNELS) >= PxU32(PxVehicleDriveGraphChannel::eMAX_NB_DRIVE_CHANNELS));
00301 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
00302
00303 class PxVehicleTelemetryData
00304 {
00305 public:
00306
00307 friend class PxVehicleUpdate;
00308
00313 static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
00314
00319 void free();
00320
00324 void setup
00325 (const PxReal graphSizeX, const PxReal graphSizeY,
00326 const PxReal engineGraphPosX, const PxReal engineGraphPosY,
00327 const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
00328 const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00329
00333 void clear();
00334
00338 const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
00339
00343 PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
00344
00348 const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
00349
00353 const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
00354
00358 const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
00359
00360 private:
00361
00367 PxVehicleGraph* mEngineGraph;
00368
00374 PxVehicleGraph* mWheelGraphs;
00375
00379 PxVec3* mTireforceAppPoints;
00380
00384 PxVec3* mSuspforceAppPoints;
00385
00389 PxU32 mNbActiveWheels;
00390
00391 PxU32 mPad[3];
00392
00393 private:
00394
00395 PxVehicleTelemetryData(){}
00396 ~PxVehicleTelemetryData(){}
00397 };
00398
00399 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
00400
00401 #endif //PX_DEBUG_VEHICLE_ON
00402
00403
00404
00405 #if !PX_DOXYGEN
00406 }
00407 #endif
00408
00410 #endif //PX_VEHICLE_UTILSTELEMETRY_H