Panda3D
 All Classes Functions Variables Enumerations
physxSoftBodyDesc.cxx
00001 // Filename: physxSoftBodyDesc.cxx
00002 // Created by:  enn0x (12Sep10)
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 "physxSoftBodyDesc.h"
00016 #include "physxSoftBodyMesh.h"
00017 #include "physxManager.h"
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: PhysxSoftBodyDesc::set_name
00021 //       Access: Published
00022 //  Description: 
00023 ////////////////////////////////////////////////////////////////////
00024 void PhysxSoftBodyDesc::
00025 set_name(const char *name) {
00026 
00027   _name = name ? name : "";
00028   _desc.name = _name.c_str();
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: PhysxSoftBodyDesc::set_global_pos
00033 //       Access: Published
00034 //  Description: 
00035 ////////////////////////////////////////////////////////////////////
00036 void PhysxSoftBodyDesc::
00037 set_global_pos(const LPoint3f &pos) {
00038 
00039   _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: PhysxSoftBodyDesc::set_global_mat
00044 //       Access: Published
00045 //  Description: 
00046 ////////////////////////////////////////////////////////////////////
00047 void PhysxSoftBodyDesc::
00048 set_global_mat(const LMatrix4f &mat) {
00049 
00050   _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: PhysxSoftBodyDesc::set_global_hpr
00055 //       Access: Published
00056 //  Description: 
00057 ////////////////////////////////////////////////////////////////////
00058 void PhysxSoftBodyDesc::
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: PhysxSoftBodyDesc::set_particle_radius
00073 //       Access: Published
00074 //  Description: 
00075 ////////////////////////////////////////////////////////////////////
00076 void PhysxSoftBodyDesc::
00077 set_particle_radius(float radius) {
00078 
00079   _desc.particleRadius = radius;
00080 }
00081 
00082 ////////////////////////////////////////////////////////////////////
00083 //     Function: PhysxSoftBodyDesc::set_relative_grid_spacing
00084 //       Access: Published
00085 //  Description: 
00086 ////////////////////////////////////////////////////////////////////
00087 void PhysxSoftBodyDesc::
00088 set_relative_grid_spacing(float spacing) {
00089 
00090   _desc.relativeGridSpacing = spacing;
00091 }
00092 
00093 ////////////////////////////////////////////////////////////////////
00094 //     Function: PhysxSoftBodyDesc::set_collision_response_coefficient
00095 //       Access: Published
00096 //  Description: 
00097 ////////////////////////////////////////////////////////////////////
00098 void PhysxSoftBodyDesc::
00099 set_collision_response_coefficient(float coef) {
00100 
00101   _desc.collisionResponseCoefficient = coef;
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: PhysxSoftBodyDesc::set_attachment_response_coefficient
00106 //       Access: Published
00107 //  Description: 
00108 ////////////////////////////////////////////////////////////////////
00109 void PhysxSoftBodyDesc::
00110 set_attachment_response_coefficient(float coef) {
00111 
00112   _desc.attachmentResponseCoefficient = coef;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: PhysxSoftBodyDesc::set_density
00117 //       Access: Published
00118 //  Description: 
00119 ////////////////////////////////////////////////////////////////////
00120 void PhysxSoftBodyDesc::
00121 set_density(float density) {
00122 
00123   _desc.density = density;
00124 }
00125 
00126 ////////////////////////////////////////////////////////////////////
00127 //     Function: PhysxSoftBodyDesc::set_volume_stiffness
00128 //       Access: Published
00129 //  Description: 
00130 ////////////////////////////////////////////////////////////////////
00131 void PhysxSoftBodyDesc::
00132 set_volume_stiffness(float stiffness) {
00133 
00134   _desc.volumeStiffness = stiffness;
00135 }
00136 
00137 ////////////////////////////////////////////////////////////////////
00138 //     Function: PhysxSoftBodyDesc::set_stretching_stiffness
00139 //       Access: Published
00140 //  Description: 
00141 ////////////////////////////////////////////////////////////////////
00142 void PhysxSoftBodyDesc::
00143 set_stretching_stiffness(float stiffness) {
00144 
00145   _desc.stretchingStiffness = stiffness;
00146 }
00147 
00148 ////////////////////////////////////////////////////////////////////
00149 //     Function: PhysxSoftBodyDesc::set_damping_coefficient
00150 //       Access: Published
00151 //  Description: 
00152 ////////////////////////////////////////////////////////////////////
00153 void PhysxSoftBodyDesc::
00154 set_damping_coefficient(float damping) {
00155 
00156   _desc.dampingCoefficient = damping;
00157 }
00158 
00159 ////////////////////////////////////////////////////////////////////
00160 //     Function: PhysxSoftBodyDesc::set_friction
00161 //       Access: Published
00162 //  Description: 
00163 ////////////////////////////////////////////////////////////////////
00164 void PhysxSoftBodyDesc::
00165 set_friction(float friction) {
00166 
00167   _desc.friction = friction;
00168 }
00169 
00170 ////////////////////////////////////////////////////////////////////
00171 //     Function: PhysxSoftBodyDesc::set_tear_factor
00172 //       Access: Published
00173 //  Description: 
00174 ////////////////////////////////////////////////////////////////////
00175 void PhysxSoftBodyDesc::
00176 set_tear_factor(float tearFactor) {
00177 
00178   _desc.tearFactor = tearFactor;
00179 }
00180 
00181 ////////////////////////////////////////////////////////////////////
00182 //     Function: PhysxSoftBodyDesc::set_flag
00183 //       Access: Published
00184 //  Description: Raise or lower individual SoftBodyFlag flags.
00185 ////////////////////////////////////////////////////////////////////
00186 void PhysxSoftBodyDesc::
00187 set_flag(PhysxSoftBodyFlag flag, bool value) {
00188 
00189   if (value == true) {
00190     _desc.flags |= flag;
00191   }
00192   else {
00193     _desc.flags &= ~(flag);
00194   }
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: PhysxSoftBodyDesc::set_solver_iterations
00199 //       Access: Published
00200 //  Description: Number of solver iterations.
00201 //               Small numbers make the simulation faster while 
00202 //               the soft body gets less stiff.
00203 ////////////////////////////////////////////////////////////////////
00204 void PhysxSoftBodyDesc::
00205 set_solver_iterations(unsigned int iterations) {
00206 
00207   _desc.solverIterations = iterations;
00208 }
00209 
00210 ////////////////////////////////////////////////////////////////////
00211 //     Function: PhysxSoftBodyDesc::set_soft_body_mesh
00212 //       Access: Published
00213 //  Description: 
00214 ////////////////////////////////////////////////////////////////////
00215 void PhysxSoftBodyDesc::
00216 set_soft_body_mesh(PhysxSoftBodyMesh *mesh) {
00217 
00218   _desc.softBodyMesh = mesh->ptr();
00219 }
00220 
00221 ////////////////////////////////////////////////////////////////////
00222 //     Function: PhysxSoftBodyDesc::get_name
00223 //       Access: Published
00224 //  Description: 
00225 ////////////////////////////////////////////////////////////////////
00226 const char *PhysxSoftBodyDesc::
00227 get_name() const {
00228 
00229   return _desc.name;
00230 }
00231 
00232 ////////////////////////////////////////////////////////////////////
00233 //     Function: PhysxSoftBodyDesc::get_global_pos
00234 //       Access: Published
00235 //  Description: 
00236 ////////////////////////////////////////////////////////////////////
00237 LPoint3f PhysxSoftBodyDesc::
00238 get_global_pos() const {
00239 
00240   return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: PhysxSoftBodyDesc::get_global_mat
00245 //       Access: Published
00246 //  Description: 
00247 ////////////////////////////////////////////////////////////////////
00248 LMatrix4f PhysxSoftBodyDesc::
00249 get_global_mat() const {
00250 
00251   return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
00252 }
00253 
00254 ////////////////////////////////////////////////////////////////////
00255 //     Function: PhysxSoftBodyDesc::get_particle_radius
00256 //       Access: Published
00257 //  Description: 
00258 ////////////////////////////////////////////////////////////////////
00259 float PhysxSoftBodyDesc::
00260 get_particle_radius() const {
00261 
00262   return _desc.particleRadius;
00263 }
00264 
00265 ////////////////////////////////////////////////////////////////////
00266 //     Function: PhysxSoftBodyDesc::get_relative_grid_spacing
00267 //       Access: Published
00268 //  Description: 
00269 ////////////////////////////////////////////////////////////////////
00270 float PhysxSoftBodyDesc::
00271 get_relative_grid_spacing() const {
00272 
00273   return _desc.relativeGridSpacing;
00274 }
00275 
00276 ////////////////////////////////////////////////////////////////////
00277 //     Function: PhysxSoftBodyDesc::get_collision_response_coefficient
00278 //       Access: Published
00279 //  Description: 
00280 ////////////////////////////////////////////////////////////////////
00281 float PhysxSoftBodyDesc::
00282 get_collision_response_coefficient() const {
00283 
00284   return _desc.collisionResponseCoefficient;
00285 }
00286 
00287 ////////////////////////////////////////////////////////////////////
00288 //     Function: PhysxSoftBodyDesc::get_attachment_response_coefficient
00289 //       Access: Published
00290 //  Description: 
00291 ////////////////////////////////////////////////////////////////////
00292 float PhysxSoftBodyDesc::
00293 get_attachment_response_coefficient() const {
00294 
00295   return _desc.attachmentResponseCoefficient;
00296 }
00297 
00298 ////////////////////////////////////////////////////////////////////
00299 //     Function: PhysxSoftBodyDesc::get_density
00300 //       Access: Published
00301 //  Description: 
00302 ////////////////////////////////////////////////////////////////////
00303 float PhysxSoftBodyDesc::
00304 get_density() const {
00305 
00306   return _desc.density;
00307 }
00308 
00309 ////////////////////////////////////////////////////////////////////
00310 //     Function: PhysxSoftBodyDesc::get_volume_stiffness
00311 //       Access: Published
00312 //  Description: 
00313 ////////////////////////////////////////////////////////////////////
00314 float PhysxSoftBodyDesc::
00315 get_volume_stiffness() const {
00316 
00317   return _desc.volumeStiffness;
00318 }
00319 
00320 ////////////////////////////////////////////////////////////////////
00321 //     Function: PhysxSoftBodyDesc::get_stretching_stiffness
00322 //       Access: Published
00323 //  Description: 
00324 ////////////////////////////////////////////////////////////////////
00325 float PhysxSoftBodyDesc::
00326 get_stretching_stiffness() const {
00327 
00328   return _desc.stretchingStiffness;
00329 }
00330 
00331 ////////////////////////////////////////////////////////////////////
00332 //     Function: PhysxSoftBodyDesc::get_damping_coefficient
00333 //       Access: Published
00334 //  Description: 
00335 ////////////////////////////////////////////////////////////////////
00336 float PhysxSoftBodyDesc::
00337 get_damping_coefficient() const {
00338 
00339   return _desc.dampingCoefficient;
00340 }
00341 
00342 ////////////////////////////////////////////////////////////////////
00343 //     Function: PhysxSoftBodyDesc::get_friction
00344 //       Access: Published
00345 //  Description: 
00346 ////////////////////////////////////////////////////////////////////
00347 float PhysxSoftBodyDesc::
00348 get_friction() const {
00349 
00350   return _desc.friction;
00351 }
00352 
00353 ////////////////////////////////////////////////////////////////////
00354 //     Function: PhysxSoftBodyDesc::get_tear_factor
00355 //       Access: Published
00356 //  Description: 
00357 ////////////////////////////////////////////////////////////////////
00358 float PhysxSoftBodyDesc::
00359 get_tear_factor() const {
00360 
00361   return _desc.tearFactor;
00362 }
00363 
00364 ////////////////////////////////////////////////////////////////////
00365 //     Function: PhysxSoftBodyDesc::get_flag
00366 //       Access: Published
00367 //  Description: 
00368 ////////////////////////////////////////////////////////////////////
00369 bool PhysxSoftBodyDesc::
00370 get_flag(PhysxSoftBodyFlag flag) const {
00371 
00372   return (_desc.flags & flag) ? true : false;
00373 }
00374 
00375 ////////////////////////////////////////////////////////////////////
00376 //     Function: PhysxSoftBodyDesc::get_solver_iterations
00377 //       Access: Published
00378 //  Description: 
00379 ////////////////////////////////////////////////////////////////////
00380 unsigned int PhysxSoftBodyDesc::
00381 get_solver_iterations() const {
00382 
00383   return _desc.solverIterations;
00384 }
00385 
00386 /*
00387 ////////////////////////////////////////////////////////////////////
00388 //     Function: PhysxSoftBodyDesc::get_mesh_numbers
00389 //       Access: Public
00390 //  Description: Used by PhysScene to query the sizes of arrays
00391 //               to allocate for the user buffers in PhysxSoftBodyNode.
00392 ////////////////////////////////////////////////////////////////////
00393 void PhysxSoftBodyDesc::
00394 get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) {
00395 
00396   NxSoftBodyMeshDesc meshDesc;
00397   _desc.clothMesh->saveToDesc(meshDesc);
00398 
00399   numVertices = meshDesc.numVertices;
00400   numTriangles = meshDesc.numTriangles;
00401 }
00402 */
00403 
 All Classes Functions Variables Enumerations