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-2017 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 #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 //= ATTENTION! =====================================================================================
00060 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00061 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00062 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00063 // accordingly.
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     \brief Engine simulation data
00128     @see setEngineData, getEngineData
00129     */
00130     PxVehicleEngineData             mEngine;
00131 
00132     /*
00133     \brief Gear simulation data
00134     @see setGearsData, getGearsData
00135     */
00136     PxVehicleGearsData              mGears;
00137 
00138     /*
00139     \brief Clutch simulation data
00140     @see setClutchData, getClutchData
00141     */
00142     PxVehicleClutchData             mClutch;
00143 
00144     /*
00145     \brief Autobox simulation data
00146     @see setAutoboxData, getAutoboxData
00147     */
00148     PxVehicleAutoBoxData            mAutoBox;
00149 
00155     bool isValid() const;
00156 
00157 
00158 //serialization
00159 public:
00160     PxVehicleDriveSimData() {}
00161     PxVehicleDriveSimData(const PxEMPTY) :  mEngine(PxEmpty), mGears(PxEmpty), mClutch(PxEmpty), mAutoBox(PxEmpty) {}
00162     static void getBinaryMetaData(PxOutputStream& stream);
00163 //~serialization
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 //serialization
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 //~serialization
00490 };
00491 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveDynData) & 15));
00492 
00497 class PxVehicleDrive : public PxVehicleWheels
00498 {
00499 //= ATTENTION! =====================================================================================
00500 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00501 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00502 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00503 // accordingly.
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 //serialization
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 //~serialization
00558 };
00559 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive) & 15));
00560 
00561 #if !PX_DOXYGEN
00562 } // namespace physx
00563 #endif
00564 
00566 #endif //PX_VEHICLE_DRIVE_H


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