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_UTILSSETUP_H |
14 | #define PX_VEHICLE_UTILSSETUP_H |
15 | /** \addtogroup vehicle |
16 | @{ |
17 | */ |
18 | #include "foundation/PxSimpleTypes.h" |
19 | #include "vehicle/PxVehicleSDK.h" |
20 | |
21 | #ifndef PX_DOXYGEN |
22 | namespace physx |
23 | { |
24 | #endif |
25 | |
26 | class PxVehicleWheelsSimData; |
27 | class PxVehicleWheelsDynData; |
28 | class PxVehicleDriveSimData4W; |
29 | class PxVehicleWheels; |
30 | |
31 | |
32 | /** |
33 | \brief Reconfigure a PxVehicle4W instance as a three-wheeled car with tadpole config (2 front wheels, 1 rear wheel) |
34 | |
35 | \note The rear-left wheel is removed and the rear-right wheel is positioned at the centre of the rear axle. |
36 | The suspension of the rear-right wheel is modified to support the entire mass of the front car while preserving its natural frequency and damping ratio. |
37 | |
38 | \param[in, out] wheelsSimData is the data describing the wheels/suspensions/tires of the vehicle. |
39 | \param[in, out] wheelsDynData is the data describing the dynamic state of the wheels of the vehicle. |
40 | \param[in, out] driveSimData is the data describing the drive model of the vehicle. |
41 | */ |
42 | void PxVehicle4WEnable3WTadpoleMode(PxVehicleWheelsSimData& wheelsSimData, PxVehicleWheelsDynData& wheelsDynData, PxVehicleDriveSimData4W& driveSimData); |
43 | |
44 | /** |
45 | \brief Reconfigure a PxVehicle4W instance as a three-wheeled car with delta config (1 front wheel, 2 rear wheels) |
46 | |
47 | \note The front-left wheel is removed and the front-right wheel is positioned at the centre of the front axle. |
48 | The suspension of the front-right wheel is modified to support the entire mass of the front car while preserving its natural frequency and damping ratio. |
49 | |
50 | \param[in, out] wheelsSimData is the data describing the wheels/suspensions/tires of the vehicle. |
51 | \param[in, out] wheelsDynData is the data describing the dynamic state of the wheels of the vehicle. |
52 | \param[in, out] driveSimData is the data describing the drive model of the vehicle. |
53 | */ |
54 | void PxVehicle4WEnable3WDeltaMode(PxVehicleWheelsSimData& wheelsSimData, PxVehicleWheelsDynData& wheelsDynData, PxVehicleDriveSimData4W& driveSimData); |
55 | |
56 | /** |
57 | \brief Compute the sprung masses of the suspension springs given given (i) the number of sprung masses, |
58 | (ii) coordinates of the sprung masses, (iii) the center of mass offset of the rigid body, (iv) the |
59 | total mass of the rigid body, and (v) the direction of gravity (0 for x-axis, 1 for y-axis, 2 for z-axis). |
60 | |
61 | \param[in] nbSprungMasses is the number of sprung masses of the vehicle. This value corresponds to the number of wheels on the vehicle. |
62 | \param[in] sprungMassCoordinates are the coordinates of the sprung masses relative to the actor. The array sprungMassCoordinates must be of |
63 | length nbSprungMasses or greater. |
64 | \param[in] centreOfMass is the coordinate of the center of mass of the rigid body relative to the actor. This value corresponds to |
65 | the value set by PxRigidBody::setCMassLocalPose. |
66 | \param[in] totalMass is the total mass of all the sprung masses. This value corresponds to the value set by PxRigidBody::setMass. |
67 | \param[in] gravityDirection is an integer describing the direction of gravitational acceleration. A value of 0 corresponds to (-1,0,0), |
68 | a value of 1 corresponds to (0,-1,0) and a value of 2 corresponds to (0,0,-1). |
69 | \param[out] sprungMasses are the masses to set in the associated suspension data with PxVehicleSuspensionData::mSprungMass. The sprungMasses array must be of length |
70 | nbSprungMasses or greater. Each element in the sprungMasses array corresponds to the suspension located at the same array element in sprungMassCoordinates. |
71 | The center of mass of the masses in sprungMasses with the coordinates in sprungMassCoordinates satisfy the specified centerOfMass. |
72 | */ |
73 | void PxVehicleComputeSprungMasses(const PxU32 nbSprungMasses, const PxVec3* sprungMassCoordinates, const PxVec3& centreOfMass, const PxReal totalMass, const PxU32 gravityDirection, PxReal* sprungMasses); |
74 | |
75 | |
76 | /** |
77 | \brief Reconfigure the vehicle to reflect a new center of mass local pose that has been applied to the actor. The function requires |
78 | (i) the center of mass local pose that was last used to configure the vehicle and the vehicle's actor, (ii) the new center of mass local pose that |
79 | has been applied to the vehicle's actor and will now be applied to the vehicle, and (iii) the direction of gravity (0 for x-axis, 1 for y-axis, 2 for z-axis) |
80 | |
81 | \param[in] oldCMassLocalPose is the center of mass local pose that was last used to configure the vehicle. |
82 | \param[in] newCMassLocalPose is the center of mass local pose that will be used to configure the vehicle so that it matches the vehicle's actor. |
83 | \param[in] gravityDirection is an integer describing the direction of gravitational acceleration. A value of 0 corresponds to (0,0,-1), |
84 | a value of 1 corresponds to (0,-1,0) and a value of 2 corresponds to (0,0,-1). |
85 | \param[in,out] vehicle is the vehicle to be updated with a new center of mass local pose. |
86 | |
87 | \note This function does not update the center of mass of the vehicle actor. That needs to updated separately with PxRigidBody::setCMassLocalPose |
88 | |
89 | \note The suspension sprung masses are updated so that the natural frequency and damping ratio of the springs are preserved. This involves altering the |
90 | stiffness and damping rate of the suspension springs. |
91 | */ |
92 | void PxVehicleUpdateCMassLocalPose(const PxTransform& oldCMassLocalPose, const PxTransform& newCMassLocalPose, const PxU32 gravityDirection, PxVehicleWheels* vehicle); |
93 | |
94 | /** |
95 | \brief Used by PxVehicleCopyDynamicsData |
96 | @see PxVehicleCopyDynamicsData |
97 | */ |
98 | class PxVehicleCopyDynamicsMap |
99 | { |
100 | public: |
101 | |
102 | PxVehicleCopyDynamicsMap() |
103 | { |
104 | for(PxU32 i = 0; i < PX_MAX_NB_WHEELS; i++) |
105 | { |
106 | sourceWheelIds[i] = PX_MAX_U8; |
107 | targetWheelIds[i] = PX_MAX_U8; |
108 | } |
109 | } |
110 | |
111 | PxU8 sourceWheelIds[PX_MAX_NB_WHEELS]; |
112 | PxU8 targetWheelIds[PX_MAX_NB_WHEELS]; |
113 | }; |
114 | |
115 | /** |
116 | \brief Copy dynamics data from src to trg, including wheel rotation speed, wheel rotation angle, engine rotation speed etc. |
117 | |
118 | \param[in] wheelMap - describes the mapping between the wheels in src and the wheels in trg. |
119 | |
120 | \param[in] src - according to the wheel mapping stored in wheelMap, the dynamics data in src wheels are copied to the corresponding wheels in trg. |
121 | |
122 | \param[out] trg - according to wheel mapping stored in wheelMap, the wheels in trg are given the dynamics data of the corresponding wheels in src. |
123 | |
124 | \note wheelMap must specify a unique mapping between the wheels in src and the wheels in trg. |
125 | |
126 | \note In the event that src has fewer wheels than trg, wheelMap must specify a unique mapping between each src wheel to a trg wheel. |
127 | |
128 | \note In the event that src has more wheels than trg, wheelMap must specify a unique mapping to each trg wheel from a src wheel. |
129 | |
130 | \note In the event that src has fewer wheels than trg, the trg wheels that are not mapped to a src wheel are given the average wheel rotation |
131 | speed of all enabled src wheels. |
132 | |
133 | \note src and trg must be the same vehicle type. |
134 | */ |
135 | void PxVehicleCopyDynamicsData(const PxVehicleCopyDynamicsMap& wheelMap, const PxVehicleWheels& src, PxVehicleWheels* trg); |
136 | |
137 | |
138 | #ifndef PX_DOXYGEN |
139 | } // namespace physx |
140 | #endif |
141 | |
142 | /** @} */ |
143 | #endif //PX_VEHICLE_UTILSSETUP_H |
144 | |