PhysX SDK 3.2 API Reference: PxVehicleDrive.h Source File

PhysX SDK 3.2 API

PxVehicleDrive.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 #ifndef PX_VEHICLE_DRIVE_H
00031 #define PX_VEHICLE_DRIVE_H
00032 
00036 #include "vehicle/PxVehicleWheels.h"
00037 #include "vehicle/PxVehicleComponents.h"
00038 
00039 #ifndef PX_DOXYGEN
00040 namespace physx
00041 {
00042 #endif
00043 
00044 struct PxFilterData;
00045 class PxGeometry;
00046 class PxPhysics;
00047 class PxBatchQuery;
00048 struct PxRaycastQueryResult;
00049 class PxVehicleDrivableSurfaceToTireFrictionPairs;
00050 class PxShape;
00051 class PxMaterial;
00052 class PxRigidDynamic;
00053 
00058 class PxVehicleDriveSimData
00059 {
00060 
00061 public:
00062 
00063     friend class PxVehicleDriveTank;
00064 
00068     PX_FORCE_INLINE const PxVehicleEngineData& getEngineData() const 
00069     {
00070         return mEngine;
00071     }
00072 
00076     PX_FORCE_INLINE const PxVehicleGearsData& getGearsData() const 
00077     {
00078         return mGears;
00079     }
00080 
00084     PX_FORCE_INLINE const PxVehicleClutchData& getClutchData() const 
00085     {
00086         return mClutch;
00087     }
00088 
00092     PX_FORCE_INLINE const PxVehicleAutoBoxData& getAutoBoxData() const 
00093     {
00094         return mAutoBox;
00095     }
00096 
00100     void setEngineData(const PxVehicleEngineData& engine);
00101 
00105     void setGearsData(const PxVehicleGearsData& gears);
00106 
00110     void setClutchData(const PxVehicleClutchData& clutch);
00111 
00115     void setAutoBoxData(const PxVehicleAutoBoxData& autobox);
00116 
00117 protected:
00118 
00119     /*
00120     \brief Engine simulation data
00121     @see setEngineData, getEngineData
00122     */
00123     PxVehicleEngineData             mEngine;
00124 
00125     /*
00126     \brief Gear simulation data
00127     @see setGearsData, getGearsData
00128     */
00129     PxVehicleGearsData              mGears;
00130 
00131     /*
00132     \brief Clutch simulation data
00133     @see setClutchData, getClutchData
00134     */
00135     PxVehicleClutchData             mClutch;
00136 
00137     /*
00138     \brief Autobox simulation data
00139     @see setAutoboxData, getAutoboxData
00140     */
00141     PxVehicleAutoBoxData            mAutoBox;
00142 
00148     bool isValid() const;
00149 
00150 };
00151 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimData) & 15));
00152 
00153 
00158 class PxVehicleDriveDynData
00159 {
00160 public:
00161 
00162     friend class PxVehicleDrive;
00163 
00164     PxVehicleDriveDynData();
00165 
00169     void setToRestState();
00170 
00174     void setAnalogInput(const PxReal analogVal, const PxU32 type);
00175 
00179     PxReal getAnalogInput(const PxU32 type);
00180 
00184     void setGearUp(const bool digitalVal) 
00185     {
00186         mGearUpPressed = digitalVal;
00187     }
00188 
00192     void setGearDown(const bool digitalVal) 
00193     {
00194         mGearDownPressed = digitalVal;
00195     }
00196 
00200     bool getGearUp() const 
00201     {
00202         return mGearUpPressed;
00203     }
00204 
00208     bool getGearDown() const 
00209     {
00210         return mGearDownPressed;
00211     }
00212 
00216     PX_FORCE_INLINE bool getUseAutoGears() const
00217     {
00218         return mUseAutoGears;
00219     }
00220 
00224     PX_FORCE_INLINE void toggleAutoGears() 
00225     {
00226         mUseAutoGears = !mUseAutoGears;
00227     }
00228 
00232     PX_FORCE_INLINE PxU32 getCurrentGear() const
00233     {
00234         return mCurrentGear;
00235     }
00236 
00240     PX_FORCE_INLINE PxU32 getTargetGear() const
00241     {
00242         return mTargetGear;
00243     }
00244  
00248     PX_FORCE_INLINE void startGearChange(const PxU32 targetGear)
00249     {
00250         mTargetGear=targetGear;
00251     }
00252 
00256     PX_FORCE_INLINE void forceGearChange(const PxU32 targetGear)
00257     {
00258         mTargetGear=targetGear;
00259         mCurrentGear=targetGear;
00260     }
00261 
00265     PX_FORCE_INLINE PxReal getEngineRotationSpeed() const
00266     {
00267         return mEnginespeed;
00268     }
00269 
00273     PX_FORCE_INLINE void setUseAutoGears(const bool useAutoGears)
00274     {
00275         mUseAutoGears=useAutoGears;
00276     }
00277 
00278 public:
00279 
00280     enum
00281     {
00282         eANALOG_INPUT_ACCEL=0,
00283         eMAX_NUM_ANALOG_INPUTS=16
00284     };
00285 
00298     PxReal mControlAnalogVals[eMAX_NUM_ANALOG_INPUTS];
00299 
00304     bool mUseAutoGears;
00305 
00310     bool mGearUpPressed;
00311 
00316     bool mGearDownPressed;
00317 
00322     PxU32 mCurrentGear;
00323 
00328     PxU32 mTargetGear;
00329 
00334     PxReal mEnginespeed;
00335 
00340     PxReal mGearSwitchTime;
00341 
00346     PxReal mAutoBoxSwitchTime;
00347 
00348 private:
00349 
00350     PxU32 mPad[2];
00351 
00356     bool isValid() const;
00357 };
00358 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveDynData) & 15));
00359 
00364 class PxVehicleDrive : public PxVehicleWheels
00365 {
00366 public:
00367 
00368     friend class PxVehicleUpdate;
00369 
00374     PxVehicleDriveDynData mDriveDynData;
00375 
00376 protected:
00377 
00378     PxVehicleDrive()
00379     {
00380     }
00381 
00382     ~PxVehicleDrive()
00383     {
00384     }
00385 
00389     bool isValid() const;
00390 
00394     void setToRestState();
00395 
00399     static PxU32 computeByteSize(const PxU32 numWheels4);
00400 
00404     static PxU8* patchupPointers(PxVehicleDrive* vehDrive, PxU8* ptr, const PxU32 numWheels4, const PxU32 numWheels);
00405 
00410     void free();
00411 
00415     void setup
00416         (PxPhysics* physics, PxRigidDynamic* vehActor, 
00417          const PxVehicleWheelsSimData& wheelsData,
00418          const PxU32 numDrivenWheels, const PxU32 numNonDrivenWheels);
00419 };
00420 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive) & 15));
00421 
00422 #ifndef PX_DOXYGEN
00423 } // namespace physx
00424 #endif
00425 
00427 #endif //PX_VEHICLE_DRIVE_H


Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com