Panda3D
|
00001 // Filename: physxSphericalJointDesc.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 "physxSphericalJointDesc.h" 00016 #include "physxManager.h" 00017 #include "physxSpringDesc.h" 00018 #include "physxJointLimitDesc.h" 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: PhysxSphericalJointDesc::set_projection_distance 00022 // Access: Published 00023 // Description: Set the distance above which to project joint. 00024 //////////////////////////////////////////////////////////////////// 00025 void PhysxSphericalJointDesc:: 00026 set_projection_distance(float distance) { 00027 00028 _desc.projectionDistance = distance; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: PhysxSphericalJointDesc::set_flag 00033 // Access: Published 00034 // Description: Sets or clears a single SphericalJointFlag flag. 00035 //////////////////////////////////////////////////////////////////// 00036 void PhysxSphericalJointDesc:: 00037 set_flag(PhysxSphericalJointFlag flag, bool value) { 00038 00039 if (value == true) { 00040 _desc.flags |= flag; 00041 } 00042 else { 00043 _desc.flags &= ~(flag); 00044 } 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: PhysxSphericalJointDesc::set_twist_spring 00049 // Access: Published 00050 // Description: Sets a spring that works against twisting. 00051 //////////////////////////////////////////////////////////////////// 00052 void PhysxSphericalJointDesc:: 00053 set_twist_spring(const PhysxSpringDesc &spring) { 00054 00055 _desc.twistSpring = spring._desc; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: PhysxSphericalJointDesc::set_swing_spring 00060 // Access: Published 00061 // Description: Sets a spring that works against swinging. 00062 //////////////////////////////////////////////////////////////////// 00063 void PhysxSphericalJointDesc:: 00064 set_swing_spring(const PhysxSpringDesc &spring) { 00065 00066 _desc.swingSpring = spring._desc; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: PhysxSphericalJointDesc::set_joint_spring 00071 // Access: Published 00072 // Description: Sets a spring that lets the joint get pulled apart. 00073 //////////////////////////////////////////////////////////////////// 00074 void PhysxSphericalJointDesc:: 00075 set_joint_spring(const PhysxSpringDesc &spring) { 00076 00077 _desc.jointSpring = spring._desc; 00078 } 00079 00080 //////////////////////////////////////////////////////////////////// 00081 // Function: PhysxSphericalJointDesc::set_swing_axis 00082 // Access: Published 00083 // Description: Set the swing limit axis defined in the joint 00084 // space of actor 0. 00085 //////////////////////////////////////////////////////////////////// 00086 void PhysxSphericalJointDesc:: 00087 set_swing_axis(const LVector3f &axis) { 00088 00089 nassertv( !axis.is_nan() ); 00090 _desc.swingAxis = PhysxManager::vec3_to_nxVec3(axis); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: PhysxSphericalJointDesc::set_projection_mode 00095 // Access: Published 00096 // Description: Use this to enable joint projection. 00097 // Default is PM_none. 00098 //////////////////////////////////////////////////////////////////// 00099 void PhysxSphericalJointDesc:: 00100 set_projection_mode(PhysxProjectionMode mode) { 00101 00102 _desc.projectionMode = (NxJointProjectionMode)mode; 00103 } 00104 00105 //////////////////////////////////////////////////////////////////// 00106 // Function: PhysxSphericalJointDesc::set_twist_limit_low 00107 // Access: Published 00108 // Description: Limits rotation around twist axis. 00109 //////////////////////////////////////////////////////////////////// 00110 void PhysxSphericalJointDesc:: 00111 set_twist_limit_low(const PhysxJointLimitDesc &low) { 00112 00113 _desc.twistLimit.low = low._desc; 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: PhysxSphericalJointDesc::set_twist_limit_high 00118 // Access: Published 00119 // Description: Limits rotation around twist axis. 00120 //////////////////////////////////////////////////////////////////// 00121 void PhysxSphericalJointDesc:: 00122 set_twist_limit_high(const PhysxJointLimitDesc &high) { 00123 00124 _desc.twistLimit.high = high._desc; 00125 } 00126 00127 //////////////////////////////////////////////////////////////////// 00128 // Function: PhysxSphericalJointDesc::set_swing_limit 00129 // Access: Published 00130 // Description: Limits swing of twist axis. 00131 //////////////////////////////////////////////////////////////////// 00132 void PhysxSphericalJointDesc:: 00133 set_swing_limit(const PhysxJointLimitDesc &limit) { 00134 00135 _desc.swingLimit = limit._desc; 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: PhysxSphericalJointDesc::get_projection_distance 00140 // Access: Published 00141 // Description: 00142 //////////////////////////////////////////////////////////////////// 00143 float PhysxSphericalJointDesc:: 00144 get_projection_distance() const { 00145 00146 return _desc.projectionDistance; 00147 } 00148 00149 //////////////////////////////////////////////////////////////////// 00150 // Function: PhysxSphericalJointDesc::get_flag 00151 // Access: Published 00152 // Description: 00153 //////////////////////////////////////////////////////////////////// 00154 bool PhysxSphericalJointDesc:: 00155 get_flag(PhysxSphericalJointFlag flag) const { 00156 00157 return (_desc.flags & flag) ? true : false; 00158 } 00159 00160 //////////////////////////////////////////////////////////////////// 00161 // Function: PhysxSphericalJointDesc::get_twist_spring 00162 // Access: Published 00163 // Description: 00164 //////////////////////////////////////////////////////////////////// 00165 PhysxSpringDesc PhysxSphericalJointDesc:: 00166 get_twist_spring() const { 00167 00168 PhysxSpringDesc value; 00169 value._desc = _desc.twistSpring; 00170 return value; 00171 } 00172 00173 //////////////////////////////////////////////////////////////////// 00174 // Function: PhysxSphericalJointDesc::get_swing_spring 00175 // Access: Published 00176 // Description: 00177 //////////////////////////////////////////////////////////////////// 00178 PhysxSpringDesc PhysxSphericalJointDesc:: 00179 get_swing_spring() const { 00180 00181 PhysxSpringDesc value; 00182 value._desc = _desc.swingSpring; 00183 return value; 00184 } 00185 00186 //////////////////////////////////////////////////////////////////// 00187 // Function: PhysxSphericalJointDesc::get_joint_spring 00188 // Access: Published 00189 // Description: 00190 //////////////////////////////////////////////////////////////////// 00191 PhysxSpringDesc PhysxSphericalJointDesc:: 00192 get_joint_spring() const { 00193 00194 PhysxSpringDesc value; 00195 value._desc = _desc.jointSpring; 00196 return value; 00197 } 00198 00199 //////////////////////////////////////////////////////////////////// 00200 // Function: PhysxSphericalJointDesc::get_swing_axis 00201 // Access: Published 00202 // Description: 00203 //////////////////////////////////////////////////////////////////// 00204 LVector3f PhysxSphericalJointDesc:: 00205 get_swing_axis() const { 00206 00207 return PhysxManager::nxVec3_to_vec3(_desc.swingAxis); 00208 } 00209 00210 //////////////////////////////////////////////////////////////////// 00211 // Function: PhysxSphericalJointDesc::get_projection_mode 00212 // Access: Published 00213 // Description: 00214 //////////////////////////////////////////////////////////////////// 00215 PhysxEnums::PhysxProjectionMode PhysxSphericalJointDesc:: 00216 get_projection_mode() const { 00217 00218 return (PhysxProjectionMode)_desc.projectionMode; 00219 } 00220 00221 //////////////////////////////////////////////////////////////////// 00222 // Function: PhysxSphericalJointDesc::get_twist_limit_low 00223 // Access: Published 00224 // Description: 00225 //////////////////////////////////////////////////////////////////// 00226 PhysxJointLimitDesc PhysxSphericalJointDesc:: 00227 get_twist_limit_low() const { 00228 00229 PhysxJointLimitDesc value; 00230 value._desc = _desc.twistLimit.low; 00231 return value; 00232 } 00233 00234 //////////////////////////////////////////////////////////////////// 00235 // Function: PhysxSphericalJointDesc::get_twist_limit_high 00236 // Access: Published 00237 // Description: 00238 //////////////////////////////////////////////////////////////////// 00239 PhysxJointLimitDesc PhysxSphericalJointDesc:: 00240 get_twist_limit_high() const { 00241 00242 PhysxJointLimitDesc value; 00243 value._desc = _desc.twistLimit.high; 00244 return value; 00245 } 00246 00247 //////////////////////////////////////////////////////////////////// 00248 // Function: PhysxSphericalJointDesc::get_swing_limit 00249 // Access: Published 00250 // Description: Limits swing of twist axis. 00251 //////////////////////////////////////////////////////////////////// 00252 PhysxJointLimitDesc PhysxSphericalJointDesc:: 00253 get_swing_limit() const { 00254 00255 PhysxJointLimitDesc value; 00256 value._desc = _desc.swingLimit; 00257 return value; 00258 } 00259