PxVehicleUtilControl.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_CONTROL_H
14 #define PX_VEHICLE_CONTROL_H
15 
18 #include "vehicle/PxVehicleSDK.h"
22 
23 
24 #ifndef PX_DOXYGEN
25 namespace physx
26 {
27 #endif
28 
29 #ifdef PX_CHECKED
30  void testValidAnalogValue(const PxF32 actualValue, const PxF32 minVal, const PxF32 maxVal, const char* errorString);
31 #endif
32 
38 {
39 public:
40 
45 
50 };
52 
58 {
59 public:
60 
65 
70 };
72 
78 {
79 public:
80 
82  {
84  {
85  mRawDigitalInputs[i]=false;
86  mRawAnalogInputs[i]=0.0f;
87  }
88 
89  mGearUp = false;
90  mGearDown = false;
91  }
92 
94  {
95  }
96 
101  void setDigitalAccel(const bool accelKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL]=accelKeyPressed;}
102 
107  void setDigitalBrake(const bool brakeKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE]=brakeKeyPressed;}
108 
113  void setDigitalHandbrake(const bool handbrakeKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE]=handbrakeKeyPressed;}
114 
119  void setDigitalSteerLeft(const bool steerLeftKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_LEFT]=steerLeftKeyPressed;}
120 
125  void setDigitalSteerRight(const bool steerRightKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT]=steerRightKeyPressed;}
126 
127 
132  bool getDigitalAccel() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL];}
133 
138  bool getDigitalBrake() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE];}
139 
145 
151 
157 
158 
163  void setAnalogAccel(const PxReal accel)
164  {
165 #ifdef PX_CHECKED
166  testValidAnalogValue(accel, 0.0f, 1.0f, "Analog accel must be in range (0,1)");
167 #endif
168  mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL]=accel;
169  }
170 
175  void setAnalogBrake(const PxReal brake)
176  {
177 #ifdef PX_CHECKED
178  testValidAnalogValue(brake, 0.0f, 1.0f, "Analog brake must be in range (0,1)");
179 #endif
180  mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE]=brake;
181  }
182 
187  void setAnalogHandbrake(const PxReal handbrake)
188  {
189 #ifdef PX_CHECKED
190  testValidAnalogValue(handbrake, 0.0f, 1.0f, "Analog handbrake must be in range (0,1)");
191 #endif
192  mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE]=handbrake;
193  }
194 
199  void setAnalogSteer(const PxReal steer)
200  {
201 #ifdef PX_CHECKED
202  testValidAnalogValue(steer, -1.0f, 1.0f, "Analog steer must be in range (-1,1)");
203 #endif
205  }
206 
212 
218 
224 
229 
234  void setGearUp(const bool gearUpKeyPressed) {mGearUp=gearUpKeyPressed;}
235 
240  void setGearDown(const bool gearDownKeyPressed) {mGearDown=gearDownKeyPressed;}
241 
246  bool getGearUp() const {return mGearUp;}
247 
252  bool getGearDown() const {return mGearDown;}
253 
254 private:
255 
258 
259  bool mGearUp;
260  bool mGearDown;
261 };
262 
274  (const PxVehicleKeySmoothingData& keySmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
275  const PxVehicleDrive4WRawInputData& rawInputData,
276  const PxReal timestep,
277  const bool isVehicleInAir,
278  PxVehicleDrive4W& focusVehicle);
279 
291  (const PxVehiclePadSmoothingData& padSmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
292  const PxVehicleDrive4WRawInputData& rawInputData,
293  const PxReal timestep,
294  const bool isVehicleInAir,
295  PxVehicleDrive4W& focusVehicle);
296 
297 
303 {
304 public:
305 
308 };
309 
321  (const PxVehicleKeySmoothingData& keySmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
322  const PxVehicleDriveNWRawInputData& rawInputData,
323  const PxReal timestep,
324  const bool isVehicleInAir,
325  PxVehicleDriveNW& focusVehicle);
326 
338  (const PxVehiclePadSmoothingData& padSmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
339  const PxVehicleDriveNWRawInputData& rawInputData,
340  const PxReal timestep,
341  const bool isVehicleInAir,
342  PxVehicleDriveNW& focusVehicle);
343 
344 
350 {
351 public:
352 
354  : mMode(mode)
355  {
357  {
358  mRawAnalogInputs[i]=0.0f;
359  mRawDigitalInputs[i]=false;
360  }
361 
362  mGearUp=false;
363  mGearDown=false;
364  }
365 
367  {
368  }
369 
375  {
376  return mMode;
377  }
378 
383  void setDigitalAccel(const bool b) {mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL]=b;}
384 
390 
396 
402 
408 
413  bool getDigitalAccel() const {return mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL];}
414 
420 
426 
432 
438 
439 
445  void setAnalogAccel(const PxF32 accel)
446  {
447 #ifdef PX_CHECKED
448  testValidAnalogValue(accel, 0.0f, 1.0f, "Tank analog accel must be in range (-1,1)");
449 #endif
450  mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL]=accel;
451  }
452 
458  void setAnalogLeftThrust(const PxF32 leftThrust)
459  {
460 #ifdef PX_CHECKED
462  {
463  testValidAnalogValue(leftThrust, -1.0f, 1.0f, "Tank left thrust must be in range (-1,1) in eSPECIAL mode.");
464  }
465  else
466  {
467  testValidAnalogValue(leftThrust, 0.0f, 1.0f, "Tank left thrust must be in range (0,1) in eSTANDARD mode.");
468  }
469 #endif
470  mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_LEFT]=leftThrust;
471  }
472 
478  void setAnalogRightThrust(const PxF32 rightThrust)
479  {
480 #ifdef PX_CHECKED
482  {
483  testValidAnalogValue(rightThrust, -1.0f, 1.0f, "Tank right thrust must be in range (-1,1) in eSPECIAL mode.");
484  }
485  else
486  {
487  testValidAnalogValue(rightThrust, 0.0f, 1.0f, "Tank right thrust must be in range (0,1) in eSTANDARD mode.");
488  }
489 #endif
490  mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_RIGHT]=rightThrust;
491  }
492 
498  void setAnalogLeftBrake(const PxF32 leftBrake)
499  {
500 #ifdef PX_CHECKED
501  testValidAnalogValue(leftBrake, 0.0f, 1.0f, "Tank left brake must be in range (0,1).");
502 #endif
503  mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_LEFT]=leftBrake;
504  }
505 
511  void setAnalogRightBrake(const PxF32 rightBrake)
512  {
513 #ifdef PX_CHECKED
514  testValidAnalogValue(rightBrake, 0.0f, 1.0f, "Tank right brake must be in range (0,1).");
515 #endif
516  mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_RIGHT]=rightBrake;
517  }
518 
523  PxF32 getAnalogAccel() const
524  {
525  return mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL];
526  }
527 
532  PxF32 getAnalogLeftThrust() const
533  {
535  }
536 
541  PxF32 getAnalogRightThrust() const
542  {
544  }
545 
550  PxF32 getAnalogLeftBrake() const
551  {
553  }
554 
559  PxF32 getAnalogRightBrake() const
560  {
562  }
563 
568  void setGearUp(const bool gearUp) {mGearUp=gearUp;}
569 
574  void setGearDown(const bool gearDown) {mGearDown=gearDown;}
575 
580  bool getGearUp() const {return mGearUp;}
581 
586  bool getGearDown() const {return mGearDown;}
587 
588 private:
589 
591 
594 
595  bool mGearUp;
596  bool mGearDown;
597 };
598 
608 (const PxVehicleKeySmoothingData& keySmoothing,
609  const PxVehicleDriveTankRawInputData& rawInputData,
610  const PxReal timestep,
611  PxVehicleDriveTank& focusVehicle);
612 
613 
623 (const PxVehiclePadSmoothingData& padSmoothing,
624  const PxVehicleDriveTankRawInputData& rawInputData,
625  const PxReal timestep,
626  PxVehicleDriveTank& focusVehicle);
627 
628 
629 #ifndef PX_DOXYGEN
630 } // namespace physx
631 #endif
632 
634 #endif //PX_VEHICLE_CONTROL_H


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