PxVehicleDrive.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 #ifndef PX_VEHICLE_DRIVE_H
14 #define PX_VEHICLE_DRIVE_H
15 
21 
22 #ifndef PX_DOXYGEN
23 namespace physx
24 {
25 #endif
26 
27 struct PxFilterData;
28 class PxGeometry;
29 class PxPhysics;
30 class PxBatchQuery;
32 class PxShape;
33 class PxMaterial;
34 class PxRigidDynamic;
35 
41 {
42 //= ATTENTION! =====================================================================================
43 // Changing the data layout of this class breaks the binary serialization format. See comments for
44 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
45 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
46 // accordingly.
47 //==================================================================================================
48 public:
49 
50  friend class PxVehicleDriveTank;
51 
55  PX_FORCE_INLINE const PxVehicleEngineData& getEngineData() const
56  {
57  return mEngine;
58  }
59 
64  void setEngineData(const PxVehicleEngineData& engine);
65 
69  PX_FORCE_INLINE const PxVehicleGearsData& getGearsData() const
70  {
71  return mGears;
72  }
73 
78  void setGearsData(const PxVehicleGearsData& gears);
79 
83  PX_FORCE_INLINE const PxVehicleClutchData& getClutchData() const
84  {
85  return mClutch;
86  }
87 
92  void setClutchData(const PxVehicleClutchData& clutch);
93 
97  PX_FORCE_INLINE const PxVehicleAutoBoxData& getAutoBoxData() const
98  {
99  return mAutoBox;
100  }
101 
106  void setAutoBoxData(const PxVehicleAutoBoxData& autobox);
107 
108 protected:
109  /*
110  \brief Engine simulation data
111  @see setEngineData, getEngineData
112  */
114 
115  /*
116  \brief Gear simulation data
117  @see setGearsData, getGearsData
118  */
120 
121  /*
122  \brief Clutch simulation data
123  @see setClutchData, getClutchData
124  */
126 
127  /*
128  \brief Autobox simulation data
129  @see setAutoboxData, getAutoboxData
130  */
132 
138  bool isValid() const;
139 
140 
141 //serialization
142 public:
144  PxVehicleDriveSimData(const PxEMPTY&) : mEngine(PxEmpty), mGears(PxEmpty), mClutch(PxEmpty), mAutoBox(PxEmpty) {}
145  static void getBinaryMetaData(PxOutputStream& stream);
146 //~serialization
147 };
149 
150 
156 {
157 public:
158 
159  enum
160  {
161  eMAX_NB_ANALOG_INPUTS=16
162  };
163 
164  friend class PxVehicleDrive;
165 
169  void setToRestState();
170 
177  void setAnalogInput(const PxU32 type, const PxReal analogVal);
178 
184  PxReal getAnalogInput(const PxU32 type) const;
185 
195  void setGearUp(const bool digitalVal)
196  {
197  mGearUpPressed = digitalVal;
198  }
199 
209  void setGearDown(const bool digitalVal)
210  {
211  mGearDownPressed = digitalVal;
212  }
213 
218  bool getGearUp() const
219  {
220  return mGearUpPressed;
221  }
222 
227  bool getGearDown() const
228  {
229  return mGearDownPressed;
230  }
231 
237  PX_FORCE_INLINE void setUseAutoGears(const bool useAutoGears)
238  {
239  mUseAutoGears=useAutoGears;
240  }
241 
246  PX_FORCE_INLINE bool getUseAutoGears() const
247  {
248  return mUseAutoGears;
249  }
250 
255  PX_FORCE_INLINE void toggleAutoGears()
256  {
257  mUseAutoGears = !mUseAutoGears;
258  }
259 
271  PX_FORCE_INLINE void setCurrentGear(PxU32 currentGear)
272  {
273  mCurrentGear = currentGear;
274  }
275 
283  PX_FORCE_INLINE PxU32 getCurrentGear() const
284  {
285  return mCurrentGear;
286  }
287 
299  PX_FORCE_INLINE void setTargetGear(PxU32 targetGear)
300  {
301  mTargetGear = targetGear;
302  }
303 
311  PX_FORCE_INLINE PxU32 getTargetGear() const
312  {
313  return mTargetGear;
314  }
315 
325  PX_FORCE_INLINE void startGearChange(const PxU32 targetGear)
326  {
327  mTargetGear=targetGear;
328  }
329 
337  PX_FORCE_INLINE void forceGearChange(const PxU32 targetGear)
338  {
339  mTargetGear=targetGear;
340  mCurrentGear=targetGear;
341  }
342 
348  PX_FORCE_INLINE void setEngineRotationSpeed(const PxF32 speed)
349  {
350  mEnginespeed = speed;
351  }
352 
358  PX_FORCE_INLINE PxReal getEngineRotationSpeed() const
359  {
360  return mEnginespeed;
361  }
362 
372  PX_FORCE_INLINE PxReal getGearSwitchTime() const
373  {
374  return mGearSwitchTime;
375  }
376 
384  PX_FORCE_INLINE PxReal getAutoBoxSwitchTime() const
385  {
386  return mAutoBoxSwitchTime;
387  }
388 
398  PxReal mControlAnalogVals[eMAX_NB_ANALOG_INPUTS];
399 
405 
414 
423 
429 
435 
441 
447 
453 
454 private:
456 
461  bool isValid() const;
462 
463 //serialization
464 public:
467  PxU32 getNbAnalogInput() const { return eMAX_NB_ANALOG_INPUTS; }
468  PX_FORCE_INLINE void setGearChange(const PxU32 gearChange) { mTargetGear= gearChange; }
469  PX_FORCE_INLINE PxU32 getGearChange() const { return mTargetGear; }
470  PX_FORCE_INLINE void setGearSwitchTime(const PxReal switchTime) { mGearSwitchTime = switchTime; }
471  PX_FORCE_INLINE void setAutoBoxSwitchTime(const PxReal autoBoxSwitchTime) { mAutoBoxSwitchTime = autoBoxSwitchTime; }
472 //~serialization
473 };
475 
481 {
482 //= ATTENTION! =====================================================================================
483 // Changing the data layout of this class breaks the binary serialization format. See comments for
484 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
485 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
486 // accordingly.
487 //==================================================================================================
488 public:
489 
490  friend class PxVehicleUpdate;
491 
497 
498 protected:
499 
503  bool isValid() const;
504 
508  void setToRestState();
509 
513  static PxU32 computeByteSize(const PxU32 nbWheels4);
514 
518  static PxU8* patchupPointers(PxVehicleDrive* vehDrive, PxU8* ptr, const PxU32 nbWheels4, const PxU32 nbWheels);
519 
524  void free();
525 
529  void setup
530  (PxPhysics* physics, PxRigidDynamic* vehActor,
531  const PxVehicleWheelsSimData& wheelsData,
532  const PxU32 nbDrivenWheels, const PxU32 nbNonDrivenWheels);
533 
534 //serialization
535 public:
536  static void getBinaryMetaData(PxOutputStream& stream);
537  PxVehicleDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags), mDriveDynData(PxEmpty) {}
538  virtual const char* getConcreteTypeName() const { return "PxVehicleDrive"; }
539 protected:
540  PxVehicleDrive(PxType concreteType, PxBaseFlags baseFlags) : PxVehicleWheels(concreteType, baseFlags) {}
542  virtual bool isKindOf(const char* name) const { return !strcmp("PxVehicleDrive", name) || PxBase::isKindOf(name); }
543 //~serialization
544 };
545 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive) & 15));
546 
547 #ifndef PX_DOXYGEN
548 } // namespace physx
549 #endif
550 
552 #endif //PX_VEHICLE_DRIVE_H


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