PxVehicleNoDrive.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 #ifndef PX_VEHICLE_NO_DRIVE_H
31 #define PX_VEHICLE_NO_DRIVE_H
32 
38 
39 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
45 struct PxFilterData;
46 class PxGeometry;
47 class PxPhysics;
48 class PxBatchQuery;
50 class PxShape;
51 class PxMaterial;
52 class PxRigidDynamic;
53 
58 {
59 //= ATTENTION! =====================================================================================
60 // Changing the data layout of this class breaks the binary serialization format. See comments for
61 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
62 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
63 // accordingly.
64 //==================================================================================================
65 public:
66 
67  friend class PxVehicleUpdate;
68 
78  static PxVehicleNoDrive* allocate(const PxU32 nbWheels);
79 
84  void free();
85 
94  void setup
95  (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData);
96 
106  static PxVehicleNoDrive* create
107  (PxPhysics* physics, PxRigidDynamic* vehActor, const PxVehicleWheelsSimData& wheelsData);
108 
116  void setToRestState();
117 
128  void setBrakeTorque(const PxU32 id, const PxReal brakeTorque);
129 
140  void setDriveTorque(const PxU32 id, const PxReal driveTorque);
141 
152  void setSteerAngle(const PxU32 id, const PxReal steerAngle);
153 
159  PxReal getBrakeTorque(const PxU32 id) const;
160 
166  PxReal getDriveTorque(const PxU32 id) const;
167 
173  PxReal getSteerAngle(const PxU32 id) const;
174 
175 private:
176 
180 
181 #if PX_P64_FAMILY
182  PxU32 mPad[2];
183 #else
184  PxU32 mPad[1];
185 #endif
186 
190  bool isValid() const;
191 
192 
193 //serialization
194 public:
195  PxVehicleNoDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags) {}
196  virtual void exportExtraData(PxSerializationContext&);
197  void importExtraData(PxDeserializationContext&);
198  static PxVehicleNoDrive* createObject(PxU8*& address, PxDeserializationContext& context);
199  static void getBinaryMetaData(PxOutputStream& stream);
200  virtual const char* getConcreteTypeName() const { return "PxVehicleNoDrive"; }
201  virtual bool isKindOf(const char* name) const { return !::strcmp("PxVehicleNoDrive", name) || PxBase::isKindOf(name); }
202  PxU32 getNbSteerAngle() const { return mWheelsSimData.getNbWheels(); }
203  PxU32 getNbDriveTorque() const { return mWheelsSimData.getNbWheels(); }
204  PxU32 getNbBrakeTorque() const { return mWheelsSimData.getNbWheels(); }
205 protected:
208 //~serialization
209 };
210 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleNoDrive) & 15));
211 
212 #if !PX_DOXYGEN
213 } // namespace physx
214 #endif
215 
217 #endif //PX_VEHICLE_NO_DRIVE_H
Definition: GuContactBuffer.h:37
Friction for each combination of driving surface type and tire type.
Definition: PxVehicleTireFriction.h:62
PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.
Definition: PxRigidDynamic.h:83
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition: PxFiltering.h:366
Data structure with instanced dynamics data and configuration data of a vehicle with no drive model...
Definition: PxVehicleNoDrive.h:57
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition: PxVehicleNoDrive.h:201
Abstract class for collision shapes.
Definition: PxShape.h:142
Batched queries object. This is used to perform several queries at the same time. ...
Definition: PxBatchQuery.h:57
float PxReal
Definition: PxSimpleTypes.h:78
virtual bool isKindOf(const char *superClass) const
Returns whether a given type name matches with the type of this instance.
Definition: PxBase.h:178
PxReal * mBrakeTorques
Definition: PxVehicleNoDrive.h:179
A geometry object.
Definition: PxGeometry.h:75
Output stream class for I/O.
Definition: PxIO.h:114
Data structure describing configuration data of a vehicle with up to 20 wheels.
Definition: PxVehicleWheels.h:59
PxReal * mDriveTorques
Definition: PxVehicleNoDrive.h:178
PxU32 getNbDriveTorque() const
Definition: PxVehicleNoDrive.h:203
PxU32 getNbSteerAngle() const
Definition: PxVehicleNoDrive.h:202
uint8_t PxU8
Definition: PxSimpleTypes.h:75
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition: PxVehicleNoDrive.h:200
PxVehicleNoDrive(PxBaseFlags baseFlags)
Definition: PxVehicleNoDrive.h:195
#define PX_COMPILE_TIME_ASSERT(exp)
Definition: PxPreprocessor.h:447
~PxVehicleNoDrive()
Definition: PxVehicleNoDrive.h:207
Data structure with instanced dynamics data and configuration data of a vehicle with just wheels...
Definition: PxVehicleWheels.h:676
Binary deserialization context class.
Definition: PxSerialFramework.h:174
Material class to represent a set of surface properties.
Definition: PxMaterial.h:130
PxReal * mSteerAngles
Definition: PxVehicleNoDrive.h:177
PxU32 getNbBrakeTorque() const
Definition: PxVehicleNoDrive.h:204
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition: PxPhysics.h:71
uint32_t PxU32
Definition: Px.h:48
Binary serialization context class.
Definition: PxSerialFramework.h:99