Panda3D
|
00001 // Filename: physxPulleyJointDesc.cxx 00002 // Created by: enn0x (28Sep09) 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 "physxPulleyJointDesc.h" 00016 #include "physxMotorDesc.h" 00017 #include "physxManager.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: PhysxPulleyJointDesc::set_distance 00021 // Access: Published 00022 // Description: Sets the rest length of the rope connecting the 00023 // two objects. 00024 //////////////////////////////////////////////////////////////////// 00025 void PhysxPulleyJointDesc:: 00026 set_distance(float distance) { 00027 00028 _desc.distance = distance; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: PhysxPulleyJointDesc::set_stiffness 00033 // Access: Published 00034 // Description: Sets how stiff the constraint is, between 0 and 1 00035 // (stiffest) 00036 //////////////////////////////////////////////////////////////////// 00037 void PhysxPulleyJointDesc:: 00038 set_stiffness(float stiffness) { 00039 00040 _desc.stiffness = stiffness; 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: PhysxPulleyJointDesc::set_ratio 00045 // Access: Published 00046 // Description: Sets the transmission ratio. 00047 //////////////////////////////////////////////////////////////////// 00048 void PhysxPulleyJointDesc:: 00049 set_ratio(float ratio) { 00050 00051 _desc.ratio = ratio; 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function: PhysxPulleyJointDesc::set_flag 00056 // Access: Published 00057 // Description: Sets or clears a single PulleyJointFlag flag. 00058 //////////////////////////////////////////////////////////////////// 00059 void PhysxPulleyJointDesc:: 00060 set_flag(PhysxPulleyJointFlag flag, bool value) { 00061 00062 if (value == true) { 00063 _desc.flags |= flag; 00064 } 00065 else { 00066 _desc.flags &= ~(flag); 00067 } 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: PhysxPulleyJointDesc::set_pulley 00072 // Access: Published 00073 // Description: Sets the suspension points of two bodies in world 00074 // space. 00075 //////////////////////////////////////////////////////////////////// 00076 void PhysxPulleyJointDesc:: 00077 set_pulley(unsigned int idx, const LPoint3f pos) { 00078 00079 nassertv_always(idx < 2); 00080 _desc.pulley[idx] = PhysxManager::point3_to_nxVec3(pos); 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: PhysxPulleyJointDesc::set_motor 00085 // Access: Published 00086 // Description: Sets an optional joint motor. 00087 //////////////////////////////////////////////////////////////////// 00088 void PhysxPulleyJointDesc:: 00089 set_motor(const PhysxMotorDesc &motor) { 00090 00091 _desc.motor = motor._desc; 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: PhysxPulleyJointDesc::get_distance 00096 // Access: Published 00097 // Description: 00098 //////////////////////////////////////////////////////////////////// 00099 float PhysxPulleyJointDesc:: 00100 get_distance() const { 00101 00102 return _desc.distance; 00103 } 00104 00105 //////////////////////////////////////////////////////////////////// 00106 // Function: PhysxPulleyJointDesc::get_stiffness 00107 // Access: Published 00108 // Description: 00109 //////////////////////////////////////////////////////////////////// 00110 float PhysxPulleyJointDesc:: 00111 get_stiffness() const { 00112 00113 return _desc.stiffness; 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: PhysxPulleyJointDesc::get_ratio 00118 // Access: Published 00119 // Description: 00120 //////////////////////////////////////////////////////////////////// 00121 float PhysxPulleyJointDesc:: 00122 get_ratio() const { 00123 00124 return _desc.ratio; 00125 } 00126 00127 //////////////////////////////////////////////////////////////////// 00128 // Function: PhysxPulleyJointDesc::get_flag 00129 // Access: Published 00130 // Description: 00131 //////////////////////////////////////////////////////////////////// 00132 bool PhysxPulleyJointDesc:: 00133 get_flag(PhysxPulleyJointFlag flag) const { 00134 00135 return (_desc.flags & flag) ? true : false; 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: PhysxPulleyJointDesc::get_pulley 00140 // Access: Published 00141 // Description: 00142 //////////////////////////////////////////////////////////////////// 00143 LPoint3f PhysxPulleyJointDesc:: 00144 get_pulley(unsigned int idx) const { 00145 00146 nassertr_always(idx < 2, LPoint3f::zero()); 00147 return PhysxManager::nxVec3_to_point3(_desc.pulley[idx]); 00148 } 00149 00150 //////////////////////////////////////////////////////////////////// 00151 // Function: PhysxPulleyJointDesc::get_motor 00152 // Access: Published 00153 // Description: 00154 //////////////////////////////////////////////////////////////////// 00155 PhysxMotorDesc PhysxPulleyJointDesc:: 00156 get_motor() const { 00157 00158 PhysxMotorDesc value; 00159 value._desc = _desc.motor; 00160 return value; 00161 } 00162