Panda3D
physxWheelShapeDesc.cxx
1 // Filename: physxWheelShapeDesc.cxx
2 // Created by: enn0x (09Nov09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "physxWheelShapeDesc.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: PhysxWheelShapeDesc::set_to_default
19 // Access: Published
20 // Description: (re)sets the structure to the default.
21 ////////////////////////////////////////////////////////////////////
24 
25  _desc.setToDefault();
26  set_name("");
27 
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: PhysxWheelShapeDesc::set_radius
33 // Access: Published
34 // Description: Radius of shape. Must be positive.
35 ////////////////////////////////////////////////////////////////////
37 set_radius(float radius) {
38 
39  _desc.radius = radius;
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PhysxWheelShapeDesc::get_radius
44 // Access: Published
45 // Description: Radius of shape.
46 ////////////////////////////////////////////////////////////////////
48 get_radius() const {
49 
50  return _desc.radius;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: PhysxWheelShapeDesc::set_suspension_travel
55 // Access: Published
56 // Description: Set the maximum extension distance of suspension
57 // along shape's -Y axis.
58 ////////////////////////////////////////////////////////////////////
60 set_suspension_travel(float suspensionTravel) {
61 
62  _desc.suspensionTravel = suspensionTravel;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: PhysxWheelShapeDesc::get_suspension_travel
67 // Access: Published
68 // Description:
69 ////////////////////////////////////////////////////////////////////
70 float PhysxWheelShapeDesc::
71 get_suspension_travel() const {
72 
73  return _desc.suspensionTravel;
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: PhysxWheelShapeDesc::set_inverse_wheel_mass
78 // Access: Published
79 // Description: Set the inverse mass of the wheel.
80 ////////////////////////////////////////////////////////////////////
82 set_inverse_wheel_mass(float inverseWheelMass) {
83 
84  _desc.inverseWheelMass = inverseWheelMass;
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: PhysxWheelShapeDesc::get_inverse_wheel_mass
89 // Access: Published
90 // Description:
91 ////////////////////////////////////////////////////////////////////
92 float PhysxWheelShapeDesc::
93 get_inverse_wheel_mass() const {
94 
95  return _desc.inverseWheelMass;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: PhysxWheelShapeDesc::set_motor_torque
100 // Access: Published
101 // Description: Set the sum engine torque on the wheel axle.
102 ////////////////////////////////////////////////////////////////////
104 set_motor_torque(float motorTorque) {
105 
106  _desc.motorTorque = motorTorque;
107 }
108 
109 ////////////////////////////////////////////////////////////////////
110 // Function: PhysxWheelShapeDesc::get_motor_torque
111 // Access: Published
112 // Description:
113 ////////////////////////////////////////////////////////////////////
114 float PhysxWheelShapeDesc::
115 get_motor_torque() const {
116 
117  return _desc.motorTorque;
118 }
119 
120 ////////////////////////////////////////////////////////////////////
121 // Function: PhysxWheelShapeDesc::set_brake_torque
122 // Access: Published
123 // Description: Set the amount of torque applied for braking.
124 ////////////////////////////////////////////////////////////////////
126 set_brake_torque(float brakeTorque) {
127 
128  _desc.brakeTorque = brakeTorque;
129 }
130 
131 ////////////////////////////////////////////////////////////////////
132 // Function: PhysxWheelShapeDesc::get_brake_torque
133 // Access: Published
134 // Description:
135 ////////////////////////////////////////////////////////////////////
136 float PhysxWheelShapeDesc::
137 get_brake_torque() const {
138 
139  return _desc.brakeTorque;
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function: PhysxWheelShapeDesc::set_steer_angle
144 // Access: Published
145 // Description: Set the steering angle, around shape Y axis.
146 // The steering angle is measured in degrees.
147 ////////////////////////////////////////////////////////////////////
149 set_steer_angle(float steerAngle) {
150 
151  _desc.steerAngle = NxMath::degToRad(steerAngle);
152 }
153 
154 ////////////////////////////////////////////////////////////////////
155 // Function: PhysxWheelShapeDesc::get_steer_angle
156 // Access: Published
157 // Description:
158 ////////////////////////////////////////////////////////////////////
159 float PhysxWheelShapeDesc::
160 get_steer_angle() const {
161 
162  return _desc.steerAngle;
163 }
164 
165 ////////////////////////////////////////////////////////////////////
166 // Function: PhysxWheelShapeDesc::set_wheel_flag
167 // Access: Published
168 // Description: Turn the specified wheel shape flag on or off.
169 ////////////////////////////////////////////////////////////////////
171 set_wheel_flag(PhysxWheelShapeFlag flag, bool value) {
172 
173  if (value == true) {
174  _desc.wheelFlags |= flag;
175  }
176  else {
177  _desc.wheelFlags &= ~(flag);
178  }
179 }
180 
181 ////////////////////////////////////////////////////////////////////
182 // Function: PhysxWheelShapeDesc::get_wheel_flag
183 // Access: Published
184 // Description: Returns the specified wheel shape flag.
185 ////////////////////////////////////////////////////////////////////
187 get_wheel_flag(const PhysxWheelShapeFlag flag) const {
188 
189  return (_desc.wheelFlags & flag) ? true : false;
190 }
191 
192 ////////////////////////////////////////////////////////////////////
193 // Function: PhysxWheelShapeDesc::set_suspension
194 // Access: Published
195 // Description: Set the data intended for car wheel suspension
196 // effects.
197 ////////////////////////////////////////////////////////////////////
200 
201  _desc.suspension = spring._desc;
202 }
203 
204 ////////////////////////////////////////////////////////////////////
205 // Function: PhysxWheelShapeDesc::get_suspension
206 // Access: Published
207 // Description:
208 ////////////////////////////////////////////////////////////////////
209 PhysxSpringDesc PhysxWheelShapeDesc::
210 get_suspension() const {
211 
212  PhysxSpringDesc value;
213  value._desc = _desc.suspension;
214  return value;
215 }
216 
void set_inverse_wheel_mass(float inverseWheelMass)
Set the inverse mass of the wheel.
void set_suspension_travel(float suspensionTravel)
Set the maximum extension distance of suspension along shape's -Y axis.
Describes a joint spring.
void set_to_default()
(re)sets the structure to the default.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:145
void set_brake_torque(float brakeTorque)
Set the amount of torque applied for braking.
static const LMatrix4f & y_to_z_up_mat()
Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system...
Definition: lmatrix.h:2557
void set_motor_torque(float motorTorque)
Set the sum engine torque on the wheel axle.
void set_radius(float radius)
Radius of shape.
float get_radius() const
Radius of shape.
void set_steer_angle(float steerAngle)
Set the steering angle, around shape Y axis.
void set_name(const char *name)
Sets a possible debug name.
bool get_wheel_flag(PhysxWheelShapeFlag flag) const
Returns the specified wheel shape flag.
void set_suspension(const PhysxSpringDesc &spring)
Set the data intended for car wheel suspension effects.
void set_wheel_flag(PhysxWheelShapeFlag flag, bool value)
Turn the specified wheel shape flag on or off.