aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h')
-rw-r--r--PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h651
1 files changed, 651 insertions, 0 deletions
diff --git a/PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h b/PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h
new file mode 100644
index 00000000..0676f676
--- /dev/null
+++ b/PhysX_3.4/Include/vehicle/PxVehicleUtilControl.h
@@ -0,0 +1,651 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_VEHICLE_CONTROL_H
+#define PX_VEHICLE_CONTROL_H
+/** \addtogroup vehicle
+ @{
+*/
+#include "vehicle/PxVehicleSDK.h"
+#include "vehicle/PxVehicleDrive4W.h"
+#include "vehicle/PxVehicleDriveNW.h"
+#include "vehicle/PxVehicleDriveTank.h"
+
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+#if PX_CHECKED
+ void testValidAnalogValue(const PxF32 actualValue, const PxF32 minVal, const PxF32 maxVal, const char* errorString);
+#endif
+
+/**
+\brief Used to produce smooth vehicle driving control values from key inputs.
+@see PxVehicle4WSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicle4WSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+struct PxVehicleKeySmoothingData
+{
+public:
+
+ /**
+ \brief Rise rate of each analog value if digital value is 1
+ */
+ PxReal mRiseRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+
+ /**
+ \brief Fall rate of each analog value if digital value is 0
+ */
+ PxReal mFallRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleKeySmoothingData)& 0x0f));
+
+/**
+\brief Used to produce smooth analog vehicle control values from analog inputs.
+@see PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDrive4WSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+struct PxVehiclePadSmoothingData
+{
+public:
+
+ /**
+ \brief Rise rate of each analog value from previous value towards target if target>previous
+ */
+ PxReal mRiseRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+
+ /**
+ \brief Rise rate of each analog value from previous value towards target if target<previous
+ */
+ PxReal mFallRates[PxVehicleDriveDynData::eMAX_NB_ANALOG_INPUTS];
+};
+PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehiclePadSmoothingData)& 0x0f));
+
+/**
+\brief Used to produce smooth vehicle driving control values from analog and digital inputs.
+@see PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDrive4WSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+class PxVehicleDrive4WRawInputData
+{
+public:
+
+ PxVehicleDrive4WRawInputData()
+ {
+ for(PxU32 i=0;i<PxVehicleDrive4WControl::eMAX_NB_DRIVE4W_ANALOG_INPUTS;i++)
+ {
+ mRawDigitalInputs[i]=false;
+ mRawAnalogInputs[i]=0.0f;
+ }
+
+ mGearUp = false;
+ mGearDown = false;
+ }
+
+ virtual ~PxVehicleDrive4WRawInputData()
+ {
+ }
+
+ /**
+ \brief Record if the accel button has been pressed on keyboard.
+ \param[in] accelKeyPressed is true if the accelerator key has been pressed and false otherwise.
+ */
+ void setDigitalAccel(const bool accelKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL]=accelKeyPressed;}
+
+ /**
+ \brief Record if the brake button has been pressed on keyboard.
+ \param[in] brakeKeyPressed is true if the brake key has been pressed and false otherwise.
+ */
+ void setDigitalBrake(const bool brakeKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE]=brakeKeyPressed;}
+
+ /**
+ \brief Record if the handbrake button has been pressed on keyboard.
+ \param[in] handbrakeKeyPressed is true if the handbrake key has been pressed and false otherwise.
+ */
+ void setDigitalHandbrake(const bool handbrakeKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE]=handbrakeKeyPressed;}
+
+ /**
+ \brief Record if the left steer button has been pressed on keyboard.
+ \param[in] steerLeftKeyPressed is true if the steer-left key has been pressed and false otherwise.
+ */
+ void setDigitalSteerLeft(const bool steerLeftKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_LEFT]=steerLeftKeyPressed;}
+
+ /**
+ \brief Record if the right steer button has been pressed on keyboard.
+ \param[in] steerRightKeyPressed is true if the steer-right key has been pressed and false otherwise.
+ */
+ void setDigitalSteerRight(const bool steerRightKeyPressed) {mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT]=steerRightKeyPressed;}
+
+
+ /**
+ \brief Return if the accel button has been pressed on keyboard.
+ \return True if the accel button has been pressed, false otherwise.
+ */
+ bool getDigitalAccel() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL];}
+
+ /**
+ \brief Return if the brake button has been pressed on keyboard.
+ \return True if the brake button has been pressed, false otherwise.
+ */
+ bool getDigitalBrake() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE];}
+
+ /**
+ \brief Return if the handbrake button has been pressed on keyboard.
+ \return True if the handbrake button has been pressed, false otherwise.
+ */
+ bool getDigitalHandbrake() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE];}
+
+ /**
+ \brief Return if the left steer button has been pressed on keyboard.
+ \return True if the steer-left button has been pressed, false otherwise.
+ */
+ bool getDigitalSteerLeft() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_LEFT];}
+
+ /**
+ \brief Return if the right steer button has been pressed on keyboard.
+ \return True if the steer-right button has been pressed, false otherwise.
+ */
+ bool getDigitalSteerRight() const {return mRawDigitalInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT];}
+
+
+ /**
+ \brief Set the analog accel value from the gamepad
+ \param[in] accel is the analog accelerator pedal value in range(0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
+ */
+ void setAnalogAccel(const PxReal accel)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(accel, 0.0f, 1.0f, "Analog accel must be in range (0,1)");
+#endif
+ mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL]=accel;
+ }
+
+ /**
+ \brief Set the analog brake value from the gamepad
+ \param[in] brake is the analog brake pedal value in range(0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
+ */
+ void setAnalogBrake(const PxReal brake)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(brake, 0.0f, 1.0f, "Analog brake must be in range (0,1)");
+#endif
+ mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE]=brake;
+ }
+
+ /**
+ \brief Set the analog handbrake value from the gamepad
+ \param[in] handbrake is the analog handbrake value in range(0,1) where 1 represents the handbrake fully engaged and 0 represents the handbrake in its rest state.
+ */
+ void setAnalogHandbrake(const PxReal handbrake)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(handbrake, 0.0f, 1.0f, "Analog handbrake must be in range (0,1)");
+#endif
+ mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE]=handbrake;
+ }
+
+ /**
+ \brief Set the analog steer value from the gamepad
+ \param[in] steer is the analog steer value in range(-1,1) where -1 represents the steering wheel at left lock and +1 represents the steering wheel at right lock.
+ */
+ void setAnalogSteer(const PxReal steer)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(steer, -1.0f, 1.0f, "Analog steer must be in range (-1,1)");
+#endif
+ mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT]=steer;
+ }
+
+ /**
+ \brief Return the analog accel value from the gamepad
+ \return The analog accel value.
+ */
+ PxReal getAnalogAccel() const {return mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL];}
+
+ /**
+ \brief Return the analog brake value from the gamepad
+ \return The analog brake value.
+ */
+ PxReal getAnalogBrake() const {return mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE];}
+
+ /**
+ \brief Return the analog handbrake value from the gamepad
+ \return The analog handbrake value.
+ */
+ PxReal getAnalogHandbrake() const {return mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE];}
+
+ /**
+ \brief Return the analog steer value from the gamepad
+ */
+ PxReal getAnalogSteer() const {return mRawAnalogInputs[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT];}
+
+ /**
+ \brief Record if the gearup button has been pressed on keyboard or gamepad
+ \param[in] gearUpKeyPressed is true if the gear-up button has been pressed, false otherwise.
+ */
+ void setGearUp(const bool gearUpKeyPressed) {mGearUp=gearUpKeyPressed;}
+
+ /**
+ \brief Record if the geardown button has been pressed on keyboard or gamepad
+ \param[in] gearDownKeyPressed is true if the gear-down button has been pressed, false otherwise.
+ */
+ void setGearDown(const bool gearDownKeyPressed) {mGearDown=gearDownKeyPressed;}
+
+ /**
+ \brief Return if the gearup button has been pressed on keyboard or gamepad
+ \return The value of the gear-up button.
+ */
+ bool getGearUp() const {return mGearUp;}
+
+ /**
+ \brief Record if the geardown button has been pressed on keyboard or gamepad
+ \return The value of the gear-down button.
+ */
+ bool getGearDown() const {return mGearDown;}
+
+private:
+
+ bool mRawDigitalInputs[PxVehicleDrive4WControl::eMAX_NB_DRIVE4W_ANALOG_INPUTS];
+ PxReal mRawAnalogInputs[PxVehicleDrive4WControl::eMAX_NB_DRIVE4W_ANALOG_INPUTS];
+
+ bool mGearUp;
+ bool mGearDown;
+};
+
+/**
+\brief Used to smooth and set analog vehicle control values (accel,brake,handbrake,steer) from digital inputs (keyboard).
+ Also used to set boolean gearup, geardown values.
+ \param[in] keySmoothing describes the rise and fall rates of the corresponding analog values when keys are pressed on and off.
+ \param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+ \param[in] rawInputData is the state of all digital inputs that control the vehicle.
+ \param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+ \param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+ \param[in] focusVehicle is the vehicle that will be given analog and gearup/geardown control values arising from the digital inputs.
+ */
+void PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+ (const PxVehicleKeySmoothingData& keySmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDrive4WRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDrive4W& focusVehicle);
+
+/**
+\brief Used to smooth and set analog vehicle control values from analog inputs (gamepad).
+Also used to set boolean gearup, geardown values.
+\param[in] padSmoothing describes how quickly the control values applied to the vehicle blend from the current vehicle values towards the raw analog values from the gamepad.
+\param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+\param[in] rawInputData is the state of all gamepad analog inputs that will be used control the vehicle.
+\param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+\param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+\param[in] focusVehicle is the vehicle that will be given analog control values arising from the gamepad inputs.
+*/
+void PxVehicleDrive4WSmoothAnalogRawInputsAndSetAnalogInputs
+ (const PxVehiclePadSmoothingData& padSmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDrive4WRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDrive4W& focusVehicle);
+
+
+/**
+\brief Used to produce smooth vehicle driving control values from analog and digital inputs.
+@see PxVehicleDriveNWSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDriveNWSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+class PxVehicleDriveNWRawInputData : public PxVehicleDrive4WRawInputData
+{
+public:
+
+ PxVehicleDriveNWRawInputData() : PxVehicleDrive4WRawInputData(){}
+ ~PxVehicleDriveNWRawInputData(){}
+};
+
+/**
+\brief Used to smooth and set analog vehicle control values (accel,brake,handbrake,steer) from digital inputs (keyboard).
+ Also used to set boolean gearup, geardown values.
+ \param[in] keySmoothing describes the rise and fall rates of the corresponding analog values when keys are pressed on and off.
+ \param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+ \param[in] rawInputData is the state of all digital inputs that control the vehicle.
+ \param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+ \param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+ \param[in] focusVehicle is the vehicle that will be given analog and gearup/geardown control values arising from the digital inputs.
+*/
+void PxVehicleDriveNWSmoothDigitalRawInputsAndSetAnalogInputs
+ (const PxVehicleKeySmoothingData& keySmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDriveNWRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDriveNW& focusVehicle);
+
+/**
+\brief Used to smooth and set analog vehicle control values from analog inputs (gamepad).
+Also used to set boolean gearup, geardown values.
+\param[in] padSmoothing describes how quickly the control values applied to the vehicle blend from the current vehicle values towards the raw analog values from the gamepad.
+\param[in] steerVsForwardSpeedTable is a table of maximum allowed steer versus forward vehicle speed.
+\param[in] rawInputData is the state of all gamepad analog inputs that will be used control the vehicle.
+\param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+\param[in] isVehicleInAir describes if the vehicle is in the air or on the ground and is used to decide whether or not to apply steerVsForwardSpeedTable.
+\param[in] focusVehicle is the vehicle that will be given analog control values arising from the gamepad inputs.
+*/
+void PxVehicleDriveNWSmoothAnalogRawInputsAndSetAnalogInputs
+ (const PxVehiclePadSmoothingData& padSmoothing, const PxFixedSizeLookupTable<8>& steerVsForwardSpeedTable,
+ const PxVehicleDriveNWRawInputData& rawInputData,
+ const PxReal timestep,
+ const bool isVehicleInAir,
+ PxVehicleDriveNW& focusVehicle);
+
+
+/**
+\brief Used to produce smooth analog tank control values from analog and digital inputs.
+@see PxVehicleDriveTankSmoothDigitalRawInputsAndSetAnalogInputs, PxVehicleDriveTankSmoothAnalogRawInputsAndSetAnalogInputs
+*/
+class PxVehicleDriveTankRawInputData
+{
+public:
+
+ PxVehicleDriveTankRawInputData(const PxVehicleDriveTankControlModel::Enum mode)
+ : mMode(mode)
+ {
+ for(PxU32 i=0;i<PxVehicleDriveTankControl::eMAX_NB_DRIVETANK_ANALOG_INPUTS;i++)
+ {
+ mRawAnalogInputs[i]=0.0f;
+ mRawDigitalInputs[i]=false;
+ }
+
+ mGearUp=false;
+ mGearDown=false;
+ }
+
+ ~PxVehicleDriveTankRawInputData()
+ {
+ }
+
+ /**
+ \brief Return the drive model (eDRIVE_MODEL_SPECIAL or eDRIVE_MODEL_STANDARD)
+ \return The chosen tank drive model.
+ */
+ PxVehicleDriveTankControlModel::Enum getDriveModel() const
+ {
+ return mMode;
+ }
+
+ /**
+ \brief Set if the accel button has been pressed on the keyboard
+ \param[in] b is true if the digital accel button has been pressed, false otherwise.
+ */
+ void setDigitalAccel(const bool b) {mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL]=b;}
+
+ /**
+ \brief Set if the left thrust button has been pressed on the keyboard
+ \param[in] b is true if the digital left thrust button has been pressed, false otherwise.
+ */
+ void setDigitalLeftThrust(const bool b) {mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_LEFT]=b;}
+
+ /**
+ \brief Set if the right thrust button has been pressed on the keyboard
+ \param[in] b is true if the digital right thrust button has been pressed, false otherwise.
+ */
+ void setDigitalRightThrust(const bool b) {mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_RIGHT]=b;}
+
+ /**
+ \brief Set if the left brake button has been pressed on the keyboard
+ \param[in] b is true if the digital left brake button has been pressed, false otherwise.
+ */
+ void setDigitalLeftBrake(const bool b) {mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_LEFT]=b;}
+
+ /**
+ \brief Set if the right brake button has been pressed on the keyboard
+ \param[in] b is true if the digital right brake button has been pressed, false otherwise.
+ */
+ void setDigitalRightBrake(const bool b) {mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_RIGHT]=b;}
+
+ /**
+ \brief Return if the accel button has been pressed on the keyboard
+ \return True if the accel button has been pressed, false otherwise.
+ */
+ bool getDigitalAccel() const {return mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL];}
+
+ /**
+ \brief Return if the left thrust button has been pressed on the keyboard
+ \return True if the left thrust button has been pressed, false otherwise.
+ */
+ bool getDigitalLeftThrust() const {return mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_LEFT];}
+
+ /**
+ \brief Return if the right thrust button has been pressed on the keyboard
+ \return True if the right thrust button has been pressed, false otherwise.
+ */
+ bool getDigitalRightThrust() const {return mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_RIGHT];}
+
+ /**
+ \brief Return if the left brake button has been pressed on the keyboard
+ \return True if the left brake button has been pressed, false otherwise.
+ */
+ bool getDigitalLeftBrake() const {return mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_LEFT];}
+
+ /**
+ \brief Return if the right brake button has been pressed on the keyboard
+ \return True if the right brake button has been pressed, false otherwise.
+ */
+ bool getDigitalRightBrake() const {return mRawDigitalInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_RIGHT];}
+
+
+ /**
+ \brief Set the analog accel value from the gamepad
+ \param[in] accel is a value in range (0,1) where 1 represents the accelerator pedal fully pressed and 0 represents the pedal in its rest state.
+ In range (0,1).
+ */
+ void setAnalogAccel(const PxF32 accel)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(accel, 0.0f, 1.0f, "Tank analog accel must be in range (-1,1)");
+#endif
+ mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL]=accel;
+ }
+
+ /**
+ \brief Set the analog left thrust value from the gamepad
+ \param[in] leftThrust represents the state of the left stick.
+ \note In range (0,1) for standard mode (eSTANDARD), in range (-1,1) for special mode (eSPECIAL)
+ */
+ void setAnalogLeftThrust(const PxF32 leftThrust)
+ {
+#if PX_CHECKED
+ if(mMode == PxVehicleDriveTankControlModel::eSPECIAL)
+ {
+ testValidAnalogValue(leftThrust, -1.0f, 1.0f, "Tank left thrust must be in range (-1,1) in eSPECIAL mode.");
+ }
+ else
+ {
+ testValidAnalogValue(leftThrust, 0.0f, 1.0f, "Tank left thrust must be in range (0,1) in eSTANDARD mode.");
+ }
+#endif
+ mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_LEFT]=leftThrust;
+ }
+
+ /**
+ \brief Set the analog right thrust value from the gamepad
+ \param[in] rightThrust represents the state of the right stick.
+ \note In range (0,1) for standard mode (eSTANDARD), in range (-1,1) for special mode (eSPECIAL)
+ */
+ void setAnalogRightThrust(const PxF32 rightThrust)
+ {
+#if PX_CHECKED
+ if(mMode == PxVehicleDriveTankControlModel::eSPECIAL)
+ {
+ testValidAnalogValue(rightThrust, -1.0f, 1.0f, "Tank right thrust must be in range (-1,1) in eSPECIAL mode.");
+ }
+ else
+ {
+ testValidAnalogValue(rightThrust, 0.0f, 1.0f, "Tank right thrust must be in range (0,1) in eSTANDARD mode.");
+ }
+#endif
+ mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_RIGHT]=rightThrust;
+ }
+
+ /**
+ \brief Set the analog left brake value from the gamepad
+ \param[in] leftBrake is a value in range (0,1) where 1 represents the left brake pedal fully pressed and 0 represents the left brake pedal in its rest state.
+ \note In range (0,1).
+ */
+ void setAnalogLeftBrake(const PxF32 leftBrake)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(leftBrake, 0.0f, 1.0f, "Tank left brake must be in range (0,1).");
+#endif
+ mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_LEFT]=leftBrake;
+ }
+
+ /**
+ \brief Set the analog right brake value from the gamepad
+ \param[in] rightBrake is a value in range (0,1) where 1 represents the right brake pedal fully pressed and 0 represents the right brake pedal in its rest state.
+ \note In range (0,1).
+ */
+ void setAnalogRightBrake(const PxF32 rightBrake)
+ {
+#if PX_CHECKED
+ testValidAnalogValue(rightBrake, 0.0f, 1.0f, "Tank right brake must be in range (0,1).");
+#endif
+ mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_RIGHT]=rightBrake;
+ }
+
+ /**
+ \brief Return the analog accel value from the gamepad
+ \return The analog accel value.
+ */
+ PxF32 getAnalogAccel() const
+ {
+ return mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_ACCEL];
+ }
+
+ /**
+ \brief Return the analog left thrust value from the gamepad
+ \return The analog left thrust value.
+ */
+ PxF32 getAnalogLeftThrust() const
+ {
+ return mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_LEFT];
+ }
+
+ /**
+ \brief Return the analog right thrust value from the gamepad
+ \return The analog right thrust value.
+ */
+ PxF32 getAnalogRightThrust() const
+ {
+ return mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_THRUST_RIGHT];
+ }
+
+ /**
+ \brief Return the analog left brake value from the gamepad
+ \return The analog left brake value.
+ */
+ PxF32 getAnalogLeftBrake() const
+ {
+ return mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_LEFT];
+ }
+
+ /**
+ \brief Return the analog right brake value from the gamepad
+ \return The analog right brake value.
+ */
+ PxF32 getAnalogRightBrake() const
+ {
+ return mRawAnalogInputs[PxVehicleDriveTankControl::eANALOG_INPUT_BRAKE_RIGHT];
+ }
+
+ /**
+ \brief Record if the gear-up button has been pressed on keyboard or gamepad
+ \param[in] gearUp is true if the gear-up button has been pressed, false otherwise.
+ */
+ void setGearUp(const bool gearUp) {mGearUp=gearUp;}
+
+ /**
+ \brief Record if the gear-down button has been pressed on keyboard or gamepad
+ \param[in] gearDown is true if the gear-down button has been pressed, false otherwise.
+ */
+ void setGearDown(const bool gearDown) {mGearDown=gearDown;}
+
+ /**
+ \brief Return if the gear-up button has been pressed on keyboard or gamepad
+ \return True if the gear-up button has been pressed, false otherwise.
+ */
+ bool getGearUp() const {return mGearUp;}
+
+ /**
+ \brief Return if the gear-down button has been pressed on keyboard or gamepad
+ \return True if the gear-down button has been pressed, false otherwise.
+ */
+ bool getGearDown() const {return mGearDown;}
+
+private:
+
+ PxVehicleDriveTankControlModel::Enum mMode;
+
+ PxReal mRawAnalogInputs[PxVehicleDriveTankControl::eMAX_NB_DRIVETANK_ANALOG_INPUTS];
+ bool mRawDigitalInputs[PxVehicleDriveTankControl::eMAX_NB_DRIVETANK_ANALOG_INPUTS];
+
+ bool mGearUp;
+ bool mGearDown;
+};
+
+/**
+\brief Used to smooth and set analog tank control values from digital inputs (keyboard).
+Also used to set boolean gearup, geardown values.
+\param[in] keySmoothing describes the rise and fall rates of the corresponding analog values when keys are pressed on and off.
+\param[in] rawInputData is the state of all digital inputs that control the vehicle.
+\param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+\param[in] focusVehicle is the vehicle that will be given analog and gearup/geardown control values arising from the digital inputs.
+*/
+void PxVehicleDriveTankSmoothDigitalRawInputsAndSetAnalogInputs
+(const PxVehicleKeySmoothingData& keySmoothing,
+ const PxVehicleDriveTankRawInputData& rawInputData,
+ const PxReal timestep,
+ PxVehicleDriveTank& focusVehicle);
+
+
+/**
+\brief Used to smooth and set analog tank control values from analog inputs (gamepad).
+Also used to set boolean gearup, geardown values.
+\param[in] padSmoothing describes how quickly the control values applied to the vehicle blend from the current vehicle values towards the raw analog values from the gamepad.
+\param[in] rawInputData is the state of all gamepad analog inputs that will be used control the vehicle.
+\param[in] timestep is the time that has passed since the last call to PxVehicleDrive4WSmoothDigitalRawInputsAndSetAnalogInputs
+\param[in] focusVehicle is the vehicle that will be given analog control values arising from the gamepad inputs.
+*/
+void PxVehicleDriveTankSmoothAnalogRawInputsAndSetAnalogInputs
+(const PxVehiclePadSmoothingData& padSmoothing,
+ const PxVehicleDriveTankRawInputData& rawInputData,
+ const PxReal timestep,
+ PxVehicleDriveTank& focusVehicle);
+
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+/** @} */
+#endif //PX_VEHICLE_CONTROL_H