PxVehicleDrive4W.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2008-2018 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_4WDRIVE_H
00031 #define PX_VEHICLE_4WDRIVE_H
00032 
00036 #include "vehicle/PxVehicleDrive.h"
00037 #include "vehicle/PxVehicleWheels.h"
00038 #include "vehicle/PxVehicleComponents.h"
00039 
00040 
00041 #if !PX_DOXYGEN
00042 namespace physx
00043 {
00044 #endif
00045 
00046 struct PxFilterData;
00047 class PxGeometry;
00048 class PxPhysics;
00049 class PxBatchQuery;
00050 class PxVehicleDrivableSurfaceToTireFrictionPairs;
00051 class PxShape;
00052 class PxMaterial;
00053 class PxRigidDynamic;
00054 
00060 class PxVehicleDriveSimData4W : public PxVehicleDriveSimData
00061 {
00062 //= ATTENTION! =====================================================================================
00063 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00064 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00065 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00066 // accordingly.
00067 //==================================================================================================
00068 public:
00069 
00070     friend class PxVehicleDrive4W;
00071 
00072     PxVehicleDriveSimData4W() 
00073         : PxVehicleDriveSimData()
00074     {
00075     }
00076 
00081     PX_FORCE_INLINE const PxVehicleDifferential4WData& getDiffData() const 
00082     {
00083         return mDiff;
00084     }
00085 
00090     PX_FORCE_INLINE const PxVehicleAckermannGeometryData& getAckermannGeometryData() const 
00091     {
00092         return mAckermannGeometry;
00093     }
00094 
00099     void setDiffData(const PxVehicleDifferential4WData& diff);
00100 
00105     void setAckermannGeometryData(const PxVehicleAckermannGeometryData& ackermannData);
00106 
00107 private:
00108 
00113     PxVehicleDifferential4WData     mDiff;
00114 
00119     PxVehicleAckermannGeometryData  mAckermannGeometry;
00120 
00126     bool isValid() const;
00127 
00128 //serialization
00129 public:
00130     PxVehicleDriveSimData4W(const PxEMPTY) : PxVehicleDriveSimData(PxEmpty), mDiff(PxEmpty), mAckermannGeometry(PxEmpty)  {}
00131     static void getBinaryMetaData(PxOutputStream& stream);
00132 //~serialization
00133 };
00134 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimData4W) & 15));
00135 
00136 
00137 
00144 struct PxVehicleDrive4WWheelOrder
00145 {
00146     enum Enum
00147     {
00148         eFRONT_LEFT=0,
00149         eFRONT_RIGHT,
00150         eREAR_LEFT,
00151         eREAR_RIGHT
00152     };
00153 };
00154 
00161 struct PxVehicleDrive4WControl
00162 {
00163     enum Enum
00164     {
00165         eANALOG_INPUT_ACCEL=0,
00166         eANALOG_INPUT_BRAKE,        
00167         eANALOG_INPUT_HANDBRAKE,    
00168         eANALOG_INPUT_STEER_LEFT,   
00169         eANALOG_INPUT_STEER_RIGHT,  
00170         eMAX_NB_DRIVE4W_ANALOG_INPUTS
00171     };
00172 };
00173 
00177 class PxVehicleDrive4W : public PxVehicleDrive
00178 {
00179 //= ATTENTION! =====================================================================================
00180 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00181 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00182 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00183 // accordingly.
00184 //==================================================================================================
00185 public:
00186     friend class PxVehicleUpdate;
00187         
00197     static PxVehicleDrive4W* allocate(const PxU32 nbWheels);
00198 
00203     void free();
00204 
00216     void setup
00217         (PxPhysics* physics, PxRigidDynamic* vehActor,
00218          const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData4W& driveData,
00219          const PxU32 nbNonDrivenWheels);
00220 
00233     static PxVehicleDrive4W* create
00234         (PxPhysics* physics, PxRigidDynamic* vehActor,
00235          const PxVehicleWheelsSimData& wheelsData, const PxVehicleDriveSimData4W& driveData,
00236          const PxU32 nbNonDrivenWheels);
00237 
00245     void setToRestState();
00246 
00251     PxVehicleDriveSimData4W mDriveSimData;
00252 
00253 private:
00254 
00258     bool isValid() const;   
00259 
00260 //serialization
00261 protected:
00262                                     PxVehicleDrive4W();
00263                                     ~PxVehicleDrive4W(){}
00264     virtual     bool                isKindOf(const char* name)  const   { return !::strcmp("PxVehicleDrive4W", name) || PxBase::isKindOf(name); }
00265 public:
00266     static      PxVehicleDrive4W*   createObject(PxU8*& address, PxDeserializationContext& context);
00267     static      void                getBinaryMetaData(PxOutputStream& stream);
00268                                     PxVehicleDrive4W(PxBaseFlags baseFlags) : PxVehicleDrive(baseFlags), mDriveSimData(PxEmpty) {}
00269     virtual     const char*         getConcreteTypeName() const         { return "PxVehicleDrive4W";    }
00270 //~serialization    
00271 };
00272 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive4W) & 15));
00273 
00274 #if !PX_DOXYGEN
00275 } // namespace physx
00276 #endif
00277 
00279 #endif //PX_VEHICLE_4WDRIVE_H


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