00001 // Filename: physxBodyDesc.cxx 00002 // Created by: enn0x (05Sep09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "physxBodyDesc.h" 00016 00017 //////////////////////////////////////////////////////////////////// 00018 // Function: PhysxBodyDesc::set_mass 00019 // Access: Published 00020 // Description: Set the mass of body. 00021 //////////////////////////////////////////////////////////////////// 00022 void PhysxBodyDesc:: 00023 set_mass(float mass) { 00024 00025 _desc.mass = mass; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: PhysxBodyDesc::get_mass 00030 // Access: Published 00031 // Description: Get the mass of body. 00032 //////////////////////////////////////////////////////////////////// 00033 float PhysxBodyDesc:: 00034 get_mass() const { 00035 00036 return _desc.mass; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: PhysxBodyDesc::set_linear_damping 00041 // Access: Published 00042 // Description: Set the linear damping applied to the body. 00043 //////////////////////////////////////////////////////////////////// 00044 void PhysxBodyDesc:: 00045 set_linear_damping(float damping) { 00046 00047 _desc.linearDamping = damping; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: PhysxBodyDesc::get_linear_damping 00052 // Access: Published 00053 // Description: Get the linear damping applied to the body. 00054 //////////////////////////////////////////////////////////////////// 00055 float PhysxBodyDesc:: 00056 get_linear_damping() const { 00057 00058 return _desc.linearDamping; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: PhysxBodyDesc::set_angular_damping 00063 // Access: Published 00064 // Description: Set the angular damping applied to the body. 00065 //////////////////////////////////////////////////////////////////// 00066 void PhysxBodyDesc:: 00067 set_angular_damping(float damping) { 00068 00069 _desc.angularDamping = damping; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: PhysxBodyDesc::get_angular_damping 00074 // Access: Published 00075 // Description: Get the angular damping applied to the body. 00076 //////////////////////////////////////////////////////////////////// 00077 float PhysxBodyDesc:: 00078 get_angular_damping() const { 00079 00080 return _desc.angularDamping; 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: PhysxBodyDesc::set_linear_velocity 00085 // Access: Published 00086 // Description: Set the linear Velocity of the body. 00087 //////////////////////////////////////////////////////////////////// 00088 void PhysxBodyDesc:: 00089 set_linear_velocity(const LVector3f &velocity) { 00090 00091 _desc.linearVelocity = PhysxManager::vec3_to_nxVec3(velocity); 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: PhysxBodyDesc::get_linear_velocity 00096 // Access: Published 00097 // Description: Get the linear Velocity of the body. 00098 //////////////////////////////////////////////////////////////////// 00099 LVector3f PhysxBodyDesc:: 00100 get_linear_velocity() const { 00101 00102 return PhysxManager::nxVec3_to_vec3(_desc.linearVelocity); 00103 } 00104 00105 //////////////////////////////////////////////////////////////////// 00106 // Function: PhysxBodyDesc::set_angular_velocity 00107 // Access: Published 00108 // Description: Set the angular velocity of the body. 00109 //////////////////////////////////////////////////////////////////// 00110 void PhysxBodyDesc:: 00111 set_angular_velocity(const LVector3f &velocity) { 00112 00113 _desc.angularVelocity = PhysxManager::vec3_to_nxVec3(velocity); 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: PhysxBodyDesc::get_angular_velocity 00118 // Access: Published 00119 // Description: Get the angular velocity of the body. 00120 //////////////////////////////////////////////////////////////////// 00121 LVector3f PhysxBodyDesc:: 00122 get_angular_velocity() const { 00123 00124 return PhysxManager::nxVec3_to_vec3(_desc.angularVelocity); 00125 } 00126 00127 //////////////////////////////////////////////////////////////////// 00128 // Function: PhysxBodyDesc::set_max_angular_velocity 00129 // Access: Published 00130 // Description: Set the maximum allowed angular velocity for this 00131 // body. 00132 //////////////////////////////////////////////////////////////////// 00133 void PhysxBodyDesc:: 00134 set_max_angular_velocity(float maximum) { 00135 00136 _desc.maxAngularVelocity = maximum; 00137 } 00138 00139 //////////////////////////////////////////////////////////////////// 00140 // Function: PhysxBodyDesc::get_max_angular_velocity 00141 // Access: Published 00142 // Description: Get the maximum allowed angular velocity for this 00143 // body. 00144 //////////////////////////////////////////////////////////////////// 00145 float PhysxBodyDesc:: 00146 get_max_angular_velocity() const { 00147 00148 return _desc.maxAngularVelocity; 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: PhysxBodyDesc::set_sleep_linear_velocity 00153 // Access: Published 00154 // Description: Set the maximum linear velocity at which the body 00155 // can go to sleep. 00156 //////////////////////////////////////////////////////////////////// 00157 void PhysxBodyDesc:: 00158 set_sleep_linear_velocity(float velocity) { 00159 00160 _desc.sleepLinearVelocity = velocity; 00161 } 00162 00163 //////////////////////////////////////////////////////////////////// 00164 // Function: PhysxBodyDesc::get_sleep_linear_velocity 00165 // Access: Published 00166 // Description: Get the maximum linear velocity at which the body 00167 // can go to sleep. 00168 //////////////////////////////////////////////////////////////////// 00169 float PhysxBodyDesc:: 00170 get_sleep_linear_velocity() const { 00171 00172 return _desc.sleepLinearVelocity; 00173 } 00174 00175 //////////////////////////////////////////////////////////////////// 00176 // Function: PhysxBodyDesc::set_sleep_angular_velocity 00177 // Access: Published 00178 // Description: Set the maximum angular velocity at which body 00179 // can go to sleep. 00180 //////////////////////////////////////////////////////////////////// 00181 void PhysxBodyDesc:: 00182 set_sleep_angular_velocity(float velocity) { 00183 00184 _desc.sleepAngularVelocity = velocity; 00185 } 00186 00187 //////////////////////////////////////////////////////////////////// 00188 // Function: PhysxBodyDesc::get_sleep_angular_velocity 00189 // Access: Published 00190 // Description: Get the maximum angular velocity at which body 00191 // can go to sleep. 00192 //////////////////////////////////////////////////////////////////// 00193 float PhysxBodyDesc:: 00194 get_sleep_angular_velocity() const { 00195 00196 return _desc.sleepAngularVelocity; 00197 } 00198 00199 //////////////////////////////////////////////////////////////////// 00200 // Function: PhysxBodyDesc::set_solver_iteration_count 00201 // Access: Published 00202 // Description: Set the number of solver iterations performed 00203 // when processing joint/contacts connected to this 00204 // body. 00205 //////////////////////////////////////////////////////////////////// 00206 void PhysxBodyDesc:: 00207 set_solver_iteration_count(unsigned int count) { 00208 00209 _desc.solverIterationCount = count; 00210 } 00211 00212 //////////////////////////////////////////////////////////////////// 00213 // Function: PhysxBodyDesc::get_solver_iteration_count 00214 // Access: Published 00215 // Description: Get the number of solver iterations performed 00216 // when processing joint/contacts connected to this 00217 // body. 00218 //////////////////////////////////////////////////////////////////// 00219 unsigned int PhysxBodyDesc:: 00220 get_solver_iteration_count() const { 00221 00222 return _desc.solverIterationCount; 00223 } 00224 00225 //////////////////////////////////////////////////////////////////// 00226 // Function: PhysxBodyDesc::set_sleep_energy_threshold 00227 // Access: Published 00228 // Description: Set the threshold for the energy-based sleeping 00229 // algorithm. Only used when the BF_energy_sleep_test 00230 // flag is set. 00231 //////////////////////////////////////////////////////////////////// 00232 void PhysxBodyDesc:: 00233 set_sleep_energy_threshold(float threshold) { 00234 00235 _desc.sleepEnergyThreshold = threshold; 00236 } 00237 00238 //////////////////////////////////////////////////////////////////// 00239 // Function: PhysxBodyDesc::get_sleep_energy_threshold 00240 // Access: Published 00241 // Description: Get the threshold for the energy-based sleeping 00242 // algorithm. Only used when the BF_energy_sleep_test 00243 // flag is set. 00244 //////////////////////////////////////////////////////////////////// 00245 float PhysxBodyDesc:: 00246 get_sleep_energy_threshold() const { 00247 00248 return _desc.sleepEnergyThreshold; 00249 } 00250 00251 //////////////////////////////////////////////////////////////////// 00252 // Function: PhysxBodyDesc::set_sleep_damping 00253 // Access: Published 00254 // Description: Set the damping factor for bodies that are about 00255 // to sleep. 00256 //////////////////////////////////////////////////////////////////// 00257 void PhysxBodyDesc:: 00258 set_sleep_damping(float damping) { 00259 00260 _desc.sleepDamping = damping; 00261 } 00262 00263 //////////////////////////////////////////////////////////////////// 00264 // Function: PhysxBodyDesc::get_sleep_damping 00265 // Access: Published 00266 // Description: Get the damping factor for bodies that are about 00267 // to sleep. 00268 //////////////////////////////////////////////////////////////////// 00269 float PhysxBodyDesc:: 00270 get_sleep_damping() const { 00271 00272 return _desc.sleepDamping; 00273 } 00274 00275 //////////////////////////////////////////////////////////////////// 00276 // Function: PhysxBodyDesc::set_mass_local_mat 00277 // Access: Published 00278 // Description: Set the position and orientation of the center 00279 // of mass. 00280 //////////////////////////////////////////////////////////////////// 00281 void PhysxBodyDesc:: 00282 set_mass_local_mat(const LMatrix4f mat) { 00283 00284 _desc.massLocalPose = PhysxManager::mat4_to_nxMat34(mat); 00285 } 00286 00287 //////////////////////////////////////////////////////////////////// 00288 // Function: PhysxBodyDesc::get_mass_local_mat 00289 // Access: Published 00290 // Description: Get the position and orientation of the center 00291 // of mass. 00292 //////////////////////////////////////////////////////////////////// 00293 LMatrix4f PhysxBodyDesc:: 00294 get_mass_local_mat() const { 00295 00296 return PhysxManager::nxMat34_to_mat4(_desc.massLocalPose); 00297 } 00298 00299 //////////////////////////////////////////////////////////////////// 00300 // Function: PhysxBodyDesc::set_mass_space_inertia 00301 // Access: Published 00302 // Description: Set the diagonal mass space inertia tensor in 00303 // bodies mass frame. 00304 //////////////////////////////////////////////////////////////////// 00305 void PhysxBodyDesc:: 00306 set_mass_space_inertia(const LVector3f inertia) { 00307 00308 _desc.massSpaceInertia = PhysxManager::vec3_to_nxVec3(inertia); 00309 } 00310 00311 //////////////////////////////////////////////////////////////////// 00312 // Function: PhysxBodyDesc::get_mass_space_inertia 00313 // Access: Published 00314 // Description: Get the diagonal mass space inertia tensor in 00315 // bodies mass frame. 00316 //////////////////////////////////////////////////////////////////// 00317 LVector3f PhysxBodyDesc:: 00318 get_mass_space_inertia() const { 00319 00320 return PhysxManager::nxVec3_to_vec3(_desc.massSpaceInertia); 00321 } 00322 00323 //////////////////////////////////////////////////////////////////// 00324 // Function: PhysxBodyDesc::set_flag 00325 // Access: Published 00326 // Description: Raise or lower individual body flags. 00327 //////////////////////////////////////////////////////////////////// 00328 void PhysxBodyDesc:: 00329 set_flag(const PhysxBodyFlag flag, bool value) { 00330 00331 if (value == true) { 00332 _desc.flags |= flag; 00333 } 00334 else { 00335 _desc.flags &= ~(flag); 00336 } 00337 } 00338 00339 //////////////////////////////////////////////////////////////////// 00340 // Function: PhysxBodyDesc::get_flag 00341 // Access: Published 00342 // Description: Returns the specified body flag. 00343 //////////////////////////////////////////////////////////////////// 00344 bool PhysxBodyDesc:: 00345 get_flag(const PhysxBodyFlag flag) const { 00346 00347 return (_desc.flags & flag) ? true : false; 00348 } 00349 00350 //////////////////////////////////////////////////////////////////// 00351 // Function: PhysxBodyDesc::set_ccd_motion_threshold 00352 // Access: Published 00353 // Description: When CCD is globally enabled, it is still not 00354 // performed if the motion distance of all points on 00355 // the body is below this threshold. 00356 //////////////////////////////////////////////////////////////////// 00357 void PhysxBodyDesc:: 00358 set_ccd_motion_threshold(float threshold) { 00359 00360 _desc.CCDMotionThreshold = threshold; 00361 } 00362 00363 //////////////////////////////////////////////////////////////////// 00364 // Function: PhysxBodyDesc::get_ccd_motion_threshold 00365 // Access: Published 00366 // Description: 00367 //////////////////////////////////////////////////////////////////// 00368 float PhysxBodyDesc:: 00369 get_ccd_motion_threshold() const { 00370 00371 return _desc.CCDMotionThreshold; 00372 } 00373 00374 //////////////////////////////////////////////////////////////////// 00375 // Function: PhysxBodyDesc::set_wake_up_counter 00376 // Access: Published 00377 // Description: Set the body's initial wake up counter. 00378 //////////////////////////////////////////////////////////////////// 00379 void PhysxBodyDesc:: 00380 set_wake_up_counter(float value) { 00381 00382 _desc.wakeUpCounter = value; 00383 } 00384 00385 //////////////////////////////////////////////////////////////////// 00386 // Function: PhysxBodyDesc::get_wake_up_counter 00387 // Access: Published 00388 // Description: 00389 //////////////////////////////////////////////////////////////////// 00390 float PhysxBodyDesc:: 00391 get_wake_up_counter() const { 00392 00393 return _desc.wakeUpCounter; 00394 } 00395 00396 //////////////////////////////////////////////////////////////////// 00397 // Function: PhysxBodyDesc::set_contact_report_threshold 00398 // Access: Published 00399 // Description: Set The force threshold for contact reports. 00400 //////////////////////////////////////////////////////////////////// 00401 void PhysxBodyDesc:: 00402 set_contact_report_threshold(float threshold) { 00403 00404 _desc.contactReportThreshold = threshold; 00405 } 00406 00407 //////////////////////////////////////////////////////////////////// 00408 // Function: PhysxBodyDesc::get_contact_report_threshold 00409 // Access: Published 00410 // Description: 00411 //////////////////////////////////////////////////////////////////// 00412 float PhysxBodyDesc:: 00413 get_contact_report_threshold() const { 00414 00415 return _desc.contactReportThreshold; 00416 } 00417