PxVehicleWheels.h
Go to the documentation of this file.00001 // This code contains NVIDIA Confidential Information and is disclosed to you 00002 // under a form of NVIDIA software license agreement provided separately to you. 00003 // 00004 // Notice 00005 // NVIDIA Corporation and its licensors retain all intellectual property and 00006 // proprietary rights in and to this software and related documentation and 00007 // any modifications thereto. Any use, reproduction, disclosure, or 00008 // distribution of this software and related documentation without an express 00009 // license agreement from NVIDIA Corporation is strictly prohibited. 00010 // 00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES 00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, 00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. 00015 // 00016 // Information and code furnished is believed to be accurate and reliable. 00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such 00018 // information or for any infringement of patents or other rights of third parties that may 00019 // result from its use. No license is granted by implication or otherwise under any patent 00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice. 00021 // This code supersedes and replaces all information previously supplied. 00022 // NVIDIA Corporation products are not authorized for use as critical 00023 // components in life support devices or systems without express written approval of 00024 // NVIDIA Corporation. 00025 // 00026 // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved. 00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. 00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. 00029 00030 00031 #ifndef PX_VEHICLE_WHEELS_H 00032 #define PX_VEHICLE_WHEELS_H 00033 00037 #include "foundation/PxSimpleTypes.h" 00038 #include "vehicle/PxVehicleShaders.h" 00039 #include "vehicle/PxVehicleComponents.h" 00040 00041 #ifndef PX_DOXYGEN 00042 namespace physx 00043 { 00044 #endif 00045 00046 class PxVehicleWheels4SimData; 00047 class PxVehicleWheels4DynData; 00048 class PxRigidDynamic; 00049 class PxShape; 00050 class PxPhysics; 00051 class PxMaterial; 00052 00057 class PxVehicleWheelsSimData 00058 { 00059 public: 00060 00061 friend class PxVehicleWheels; 00062 friend class PxVehicleDrive4W; 00063 friend class PxVehicleDriveTank; 00064 friend class PxVehicleUpdate; 00065 00070 static PxVehicleWheelsSimData* allocate(const PxU32 numWheels); 00071 00081 void setChassisMass(const PxF32 chassisMass); 00082 00087 void free(); 00088 00092 PxVehicleWheelsSimData& operator=(const PxVehicleWheelsSimData& src); 00093 00097 void copy(const PxVehicleWheelsSimData& src, const PxU32 srcWheel, const PxU32 trgWheel); 00098 00103 PxU32 getNumWheels() const {return mNumActiveWheels;} 00104 00108 const PxVehicleSuspensionData& getSuspensionData(const PxU32 id) const; 00109 00113 const PxVehicleWheelData& getWheelData(const PxU32 id) const; 00114 00118 const PxVehicleTireData& getTireData(const PxU32 id) const; 00119 00123 const PxVec3& getSuspTravelDirection(const PxU32 id) const; 00124 00129 const PxVec3& getSuspForceAppPointOffset(const PxU32 id) const; 00130 00135 const PxVec3& getTireForceAppPointOffset(const PxU32 id) const; 00136 00140 const PxVec3& getWheelCentreOffset(const PxU32 id) const; 00141 00145 PX_FORCE_INLINE const PxVehicleTireLoadFilterData& getTireLoadFilterData() const 00146 { 00147 return mNormalisedLoadFilter; 00148 } 00149 00153 void setSuspensionData(const PxU32 id, const PxVehicleSuspensionData& susp); 00154 00158 void setWheelData(const PxU32 id, const PxVehicleWheelData& wheel); 00159 00163 void setTireData(const PxU32 id, const PxVehicleTireData& tire); 00164 00168 void setSuspTravelDirection(const PxU32 id, const PxVec3& dir); 00169 00174 void setSuspForceAppPointOffset(const PxU32 id, const PxVec3& offset); 00175 00180 void setTireForceAppPointOffset(const PxU32 id, const PxVec3& offset); 00181 00185 void setWheelCentreOffset(const PxU32 id, const PxVec3& offset); 00186 00190 void setTireLoadFilterData(const PxVehicleTireLoadFilterData& tireLoadFilter); 00191 00195 void disableWheel(const PxU32 wheel); 00196 00200 bool getIsWheelDisabled(const PxU32 wheel) const; 00201 00202 private: 00203 00204 PxVehicleWheelsSimData(){} 00205 ~PxVehicleWheelsSimData(){} 00206 00211 PxVehicleTireLoadFilterData mNormalisedLoadFilter; 00212 00216 PxVehicleWheels4SimData* mWheels4SimData; 00217 00221 PxU32 mNumWheels4; 00222 00226 PxU32 mNumActiveWheels; 00227 00228 #ifdef PX_X64 00229 //PxU32 mPad[0]; 00230 #else 00231 PxU32 mPad[1]; 00232 #endif 00233 00237 bool isValid() const; 00238 }; 00239 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelsSimData) & 15)); 00240 00241 00245 class PxVehicleWheelsDynData 00246 { 00247 public: 00248 00249 friend class PxVehicleWheels; 00250 friend class PxVehicleDrive4W; 00251 friend class PxVehicleDriveTank; 00252 friend class PxVehicleUpdate; 00253 00258 void setToRestState(); 00259 00263 void setTireForceShaderFunction(PxVehicleComputeTireForce tireForceShaderFn); 00264 00268 void setTireForceShaderData(const PxU32 tireId, const void* tireForceShaderData); 00269 00273 PxReal getWheelRotationSpeed(const PxU32 wheelIdx) const; 00274 00278 PxReal getSteer(const PxU32 wheelIdx) const; 00279 00283 PxReal getWheelRotationAngle(const PxU32 wheelIdx) const; 00284 00288 PxReal getSuspJounce(const PxU32 suspIdx) const; 00289 00293 PxReal getTireLongSlip(const PxU32 tireIdx) const; 00294 00298 PxReal getTireLatSlip(const PxU32 tireIdx) const; 00299 00303 PxReal getTireFriction(const PxU32 tireIdx) const; 00304 00308 PxU32 getTireDrivableSurfaceType(const PxU32 tireIdx) const; 00309 00313 const PxMaterial* getTireDrivableSurfaceMaterial(const PxU32 tireIdx) const; 00314 00318 void getSuspRaycast(const PxU32 suspIdx, PxVec3& start, PxVec3& dir, PxReal& length) const; 00319 00323 PxVec3 getSuspLineStart(const PxU32 tireIdx) const; 00324 00328 PxVec3 getSuspLineDir(const PxU32 tireIdx) const; 00329 00330 private: 00331 00335 bool isValid() const; 00336 00337 PxVehicleWheelsDynData(){} 00338 ~PxVehicleWheelsDynData(){} 00339 00343 PxVehicleWheels4DynData* mWheels4DynData; 00344 00348 PxVehicleTireForceCalculator* mTireForceCalculators; 00349 00353 PxU32 mNumWheels4; 00354 00358 PxU32 mNumActiveWheels; 00359 00360 #ifdef PX_X64 00361 PxU32 mPad[1]; 00362 #endif 00363 }; 00364 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheelsDynData) & 15)); 00365 00370 class PxVehicleWheels 00371 { 00372 public: 00373 00374 friend class PxVehicleUpdate; 00375 friend class PxVehicleConstraintShader; 00376 00381 PX_FORCE_INLINE PxU32 getVehicleType() const {return mType;} 00382 00386 PX_FORCE_INLINE PxRigidDynamic* getRigidDynamicActor() {return mActor;} 00387 00391 PX_FORCE_INLINE const PxRigidDynamic* getRigidDynamicActor() const {return mActor;} 00392 00402 void setWheelShapeMapping(const PxU32 wheelId, const PxI32 shapeId); 00403 00407 PxReal computeForwardSpeed() const; 00408 00412 PxReal computeSidewaysSpeed() const; 00413 00417 bool isInAir() const; 00418 00422 bool isInAir(const PxU32 wheelId) const; 00423 00427 PxVehicleWheelsSimData mWheelsSimData; 00428 00432 PxVehicleWheelsDynData mWheelsDynData; 00433 00434 protected: 00435 00439 void setToRestState(); 00440 00444 bool isValid() const; 00445 00449 static PxU32 computeByteSize(const PxU32 numWheels4); 00450 00454 static PxU8* patchupPointers(PxVehicleWheels* veh, PxU8* ptr, const PxU32 numWheels4, const PxU32 numWheels); 00455 00460 void free(); 00461 00465 void setup 00466 (PxPhysics* physics, PxRigidDynamic* vehActor, 00467 const PxVehicleWheelsSimData& wheelsData, 00468 const PxU32 numDrivenWheels, const PxU32 numNonDrivenWheels); 00469 00470 PxRigidDynamic* mActor; 00471 00475 PxU8 mWheelShapeMap[PX_MAX_NUM_WHEELS]; 00476 00480 PxU8 mType; 00481 00482 private: 00483 00488 PxU8 mOnConstraintReleaseCounter; 00489 00490 PxU8 mPad[2]; 00491 00492 #ifndef PX_X64 00493 PxU32 mPad2[1]; 00494 #endif 00495 }; 00496 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleWheels) & 15)); 00497 00498 #ifndef PX_DOXYGEN 00499 } // namespace physx 00500 #endif 00501 00503 #endif //PX_VEHICLE_WHEELS_H
Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com