00001 // Filename: physxClothDesc.cxx 00002 // Created by: enn0x (30Mar10) 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 "physxClothDesc.h" 00016 #include "physxClothMesh.h" 00017 #include "physxManager.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: PhysxClothDesc::set_name 00021 // Access: Published 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 void PhysxClothDesc:: 00025 set_name(const char *name) { 00026 00027 _name = name ? name : ""; 00028 _desc.name = _name.c_str(); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: PhysxClothDesc::set_global_pos 00033 // Access: Published 00034 // Description: 00035 //////////////////////////////////////////////////////////////////// 00036 void PhysxClothDesc:: 00037 set_global_pos(const LPoint3f &pos) { 00038 00039 _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos); 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: PhysxClothDesc::set_global_mat 00044 // Access: Published 00045 // Description: 00046 //////////////////////////////////////////////////////////////////// 00047 void PhysxClothDesc:: 00048 set_global_mat(const LMatrix4f &mat) { 00049 00050 _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat); 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: PhysxClothDesc::set_global_hpr 00055 // Access: Published 00056 // Description: 00057 //////////////////////////////////////////////////////////////////// 00058 void PhysxClothDesc:: 00059 set_global_hpr(float h, float p, float r) { 00060 00061 LQuaternionf q; 00062 LMatrix3f rot; 00063 NxMat34 m; 00064 00065 q.set_hpr(LVector3f(h, p, r)); 00066 q.extract_to_matrix(rot); 00067 00068 _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: PhysxClothDesc::set_thickness 00073 // Access: Published 00074 // Description: 00075 //////////////////////////////////////////////////////////////////// 00076 void PhysxClothDesc:: 00077 set_thickness(float thickness) { 00078 00079 _desc.thickness = thickness; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: PhysxClothDesc::set_density 00084 // Access: Published 00085 // Description: 00086 //////////////////////////////////////////////////////////////////// 00087 void PhysxClothDesc:: 00088 set_density(float density) { 00089 00090 _desc.density = density; 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: PhysxClothDesc::set_bending_stiffness 00095 // Access: Published 00096 // Description: 00097 //////////////////////////////////////////////////////////////////// 00098 void PhysxClothDesc:: 00099 set_bending_stiffness(float stiffness) { 00100 00101 _desc.bendingStiffness = stiffness; 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: PhysxClothDesc::set_stretching_stiffness 00106 // Access: Published 00107 // Description: 00108 //////////////////////////////////////////////////////////////////// 00109 void PhysxClothDesc:: 00110 set_stretching_stiffness(float stiffness) { 00111 00112 _desc.stretchingStiffness = stiffness; 00113 } 00114 00115 //////////////////////////////////////////////////////////////////// 00116 // Function: PhysxClothDesc::set_damping_coefficient 00117 // Access: Published 00118 // Description: 00119 //////////////////////////////////////////////////////////////////// 00120 void PhysxClothDesc:: 00121 set_damping_coefficient(float damping) { 00122 00123 _desc.dampingCoefficient = damping; 00124 } 00125 00126 //////////////////////////////////////////////////////////////////// 00127 // Function: PhysxClothDesc::set_friction 00128 // Access: Published 00129 // Description: 00130 //////////////////////////////////////////////////////////////////// 00131 void PhysxClothDesc:: 00132 set_friction(float friction) { 00133 00134 _desc.friction = friction; 00135 } 00136 00137 //////////////////////////////////////////////////////////////////// 00138 // Function: PhysxClothDesc::set_pressure 00139 // Access: Published 00140 // Description: 00141 //////////////////////////////////////////////////////////////////// 00142 void PhysxClothDesc:: 00143 set_pressure(float pressure) { 00144 00145 _desc.pressure = pressure; 00146 } 00147 00148 //////////////////////////////////////////////////////////////////// 00149 // Function: PhysxClothDesc::set_tear_factor 00150 // Access: Published 00151 // Description: 00152 //////////////////////////////////////////////////////////////////// 00153 void PhysxClothDesc:: 00154 set_tear_factor(float tearFactor) { 00155 00156 _desc.tearFactor = tearFactor; 00157 } 00158 00159 //////////////////////////////////////////////////////////////////// 00160 // Function: PhysxClothDesc::set_flag 00161 // Access: Published 00162 // Description: Raise or lower individual ClothFlag flags. 00163 //////////////////////////////////////////////////////////////////// 00164 void PhysxClothDesc:: 00165 set_flag(PhysxClothFlag flag, bool value) { 00166 00167 if (value == true) { 00168 _desc.flags |= flag; 00169 } 00170 else { 00171 _desc.flags &= ~(flag); 00172 } 00173 } 00174 00175 //////////////////////////////////////////////////////////////////// 00176 // Function: PhysxClothDesc::set_solver_iterations 00177 // Access: Published 00178 // Description: Number of solver iterations. 00179 // Small numbers make the simulation faster while 00180 // the cloth gets less stiff. 00181 //////////////////////////////////////////////////////////////////// 00182 void PhysxClothDesc:: 00183 set_solver_iterations(unsigned int iterations) { 00184 00185 _desc.solverIterations = iterations; 00186 } 00187 00188 //////////////////////////////////////////////////////////////////// 00189 // Function: PhysxClothDesc::set_cloth_mesh 00190 // Access: Published 00191 // Description: 00192 //////////////////////////////////////////////////////////////////// 00193 void PhysxClothDesc:: 00194 set_cloth_mesh(PhysxClothMesh *mesh) { 00195 00196 _desc.clothMesh = mesh->ptr(); 00197 } 00198 00199 //////////////////////////////////////////////////////////////////// 00200 // Function: PhysxClothDesc::get_name 00201 // Access: Published 00202 // Description: 00203 //////////////////////////////////////////////////////////////////// 00204 const char *PhysxClothDesc:: 00205 get_name() const { 00206 00207 return _desc.name; 00208 } 00209 00210 //////////////////////////////////////////////////////////////////// 00211 // Function: PhysxClothDesc::get_global_pos 00212 // Access: Published 00213 // Description: 00214 //////////////////////////////////////////////////////////////////// 00215 LPoint3f PhysxClothDesc:: 00216 get_global_pos() const { 00217 00218 return PhysxManager::nxVec3_to_point3(_desc.globalPose.t); 00219 } 00220 00221 //////////////////////////////////////////////////////////////////// 00222 // Function: PhysxClothDesc::get_global_mat 00223 // Access: Published 00224 // Description: 00225 //////////////////////////////////////////////////////////////////// 00226 LMatrix4f PhysxClothDesc:: 00227 get_global_mat() const { 00228 00229 return PhysxManager::nxMat34_to_mat4(_desc.globalPose); 00230 } 00231 00232 //////////////////////////////////////////////////////////////////// 00233 // Function: PhysxClothDesc::get_thickness 00234 // Access: Published 00235 // Description: 00236 //////////////////////////////////////////////////////////////////// 00237 float PhysxClothDesc:: 00238 get_thickness() const { 00239 00240 return _desc.thickness; 00241 } 00242 00243 //////////////////////////////////////////////////////////////////// 00244 // Function: PhysxClothDesc::get_density 00245 // Access: Published 00246 // Description: 00247 //////////////////////////////////////////////////////////////////// 00248 float PhysxClothDesc:: 00249 get_density() const { 00250 00251 return _desc.density; 00252 } 00253 00254 //////////////////////////////////////////////////////////////////// 00255 // Function: PhysxClothDesc::get_bending_stiffness 00256 // Access: Published 00257 // Description: 00258 //////////////////////////////////////////////////////////////////// 00259 float PhysxClothDesc:: 00260 get_bending_stiffness() const { 00261 00262 return _desc.bendingStiffness; 00263 } 00264 00265 //////////////////////////////////////////////////////////////////// 00266 // Function: PhysxClothDesc::get_stretching_stiffness 00267 // Access: Published 00268 // Description: 00269 //////////////////////////////////////////////////////////////////// 00270 float PhysxClothDesc:: 00271 get_stretching_stiffness() const { 00272 00273 return _desc.stretchingStiffness; 00274 } 00275 00276 //////////////////////////////////////////////////////////////////// 00277 // Function: PhysxClothDesc::get_damping_coefficient 00278 // Access: Published 00279 // Description: 00280 //////////////////////////////////////////////////////////////////// 00281 float PhysxClothDesc:: 00282 get_damping_coefficient() const { 00283 00284 return _desc.dampingCoefficient; 00285 } 00286 00287 //////////////////////////////////////////////////////////////////// 00288 // Function: PhysxClothDesc::get_friction 00289 // Access: Published 00290 // Description: 00291 //////////////////////////////////////////////////////////////////// 00292 float PhysxClothDesc:: 00293 get_friction() const { 00294 00295 return _desc.friction; 00296 } 00297 00298 //////////////////////////////////////////////////////////////////// 00299 // Function: PhysxClothDesc::get_pressure 00300 // Access: Published 00301 // Description: 00302 //////////////////////////////////////////////////////////////////// 00303 float PhysxClothDesc:: 00304 get_pressure() const { 00305 00306 return _desc.pressure; 00307 } 00308 00309 //////////////////////////////////////////////////////////////////// 00310 // Function: PhysxClothDesc::get_tear_factor 00311 // Access: Published 00312 // Description: 00313 //////////////////////////////////////////////////////////////////// 00314 float PhysxClothDesc:: 00315 get_tear_factor() const { 00316 00317 return _desc.tearFactor; 00318 } 00319 00320 //////////////////////////////////////////////////////////////////// 00321 // Function: PhysxClothDesc::get_flag 00322 // Access: Published 00323 // Description: 00324 //////////////////////////////////////////////////////////////////// 00325 bool PhysxClothDesc:: 00326 get_flag(PhysxClothFlag flag) const { 00327 00328 return (_desc.flags & flag) ? true : false; 00329 } 00330 00331 //////////////////////////////////////////////////////////////////// 00332 // Function: PhysxClothDesc::get_solver_iterations 00333 // Access: Published 00334 // Description: 00335 //////////////////////////////////////////////////////////////////// 00336 unsigned int PhysxClothDesc:: 00337 get_solver_iterations() const { 00338 00339 return _desc.solverIterations; 00340 } 00341 00342 /* 00343 //////////////////////////////////////////////////////////////////// 00344 // Function: PhysxClothDesc::get_mesh_numbers 00345 // Access: Public 00346 // Description: Used by PhysScene to query the sizes of arrays 00347 // to allocate for the user buffers in PhysxClothNode. 00348 //////////////////////////////////////////////////////////////////// 00349 void PhysxClothDesc:: 00350 get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) { 00351 00352 NxClothMeshDesc meshDesc; 00353 _desc.clothMesh->saveToDesc(meshDesc); 00354 00355 numVertices = meshDesc.numVertices; 00356 numTriangles = meshDesc.numTriangles; 00357 } 00358 */ 00359