00001 // Filename: physxMaterialDesc.cxx 00002 // Created by: enn0x (21Sep09) 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 "physxMaterialDesc.h" 00016 #include "physxManager.h" 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: PhysxMaterialDesc::set_restitution 00020 // Access: Published 00021 // Description: Sets the coefficient of restitution -- 0 makes the 00022 // object bounce as little as possible, higher values 00023 // up to 1.0 result in more bounce. Note that values 00024 // close to or above 1 may cause stability problems 00025 // and/or increasing energy. Range: [0,1] 00026 // Default: 0.0 00027 //////////////////////////////////////////////////////////////////// 00028 void PhysxMaterialDesc:: 00029 set_restitution(float restitution) { 00030 00031 _desc.restitution = restitution; 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: PhysxMaterialDesc::set_static_friction 00036 // Access: Published 00037 // Description: Sets the coefficient of static friction -- should 00038 // be in [0, +inf]. 00039 // If the flag MF_anisotropic is set, then this value 00040 // is used for the primary direction of anisotropy 00041 // (U axis). 00042 //////////////////////////////////////////////////////////////////// 00043 void PhysxMaterialDesc:: 00044 set_static_friction(float coef) { 00045 00046 _desc.staticFriction = coef; 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: PhysxMaterialDesc::set_dynamic_friction 00051 // Access: Published 00052 // Description: Sets the coefficient of dynamic friction -- should 00053 // be in [0, +inf]. If set to greater than 00054 // staticFriction, the effective value of staticFriction 00055 // will be increased to match. 00056 // If the flag MF_anisotropic is set, then this value 00057 // is used for the primary direction of anisotropy 00058 // (U axis). 00059 //////////////////////////////////////////////////////////////////// 00060 void PhysxMaterialDesc:: 00061 set_dynamic_friction(float coef) { 00062 00063 _desc.dynamicFriction = coef; 00064 } 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Function: PhysxMaterialDesc::set_static_friction_v 00068 // Access: Published 00069 // Description: Sets the anisotropic static friction coefficient 00070 // for along the secondary (V) axis of anisotropy. 00071 // This is only used if the flag MF_anisotropic is 00072 // set. 00073 //////////////////////////////////////////////////////////////////// 00074 void PhysxMaterialDesc:: 00075 set_static_friction_v(float coef) { 00076 00077 _desc.staticFrictionV = coef; 00078 } 00079 00080 //////////////////////////////////////////////////////////////////// 00081 // Function: PhysxMaterialDesc::set_dynamic_friction_v 00082 // Access: Published 00083 // Description: Sets the anisotropic dynamic friction coefficient 00084 // for along the secondary (V) axis of anisotropy. 00085 // This is only used if the flag MF_anisotropic is 00086 // set. 00087 //////////////////////////////////////////////////////////////////// 00088 void PhysxMaterialDesc:: 00089 set_dynamic_friction_v(float coef) { 00090 00091 _desc.dynamicFrictionV = coef; 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: PhysxMaterialDesc::set_flag 00096 // Access: Published 00097 // Description: Sets flags which control the behavior of a 00098 // material. 00099 //////////////////////////////////////////////////////////////////// 00100 void PhysxMaterialDesc:: 00101 set_flag(PhysxMaterialFlag flag, bool value) { 00102 00103 if (value == true) { 00104 _desc.flags |= flag; 00105 } 00106 else { 00107 _desc.flags &= ~(flag); 00108 } 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: PhysxMaterialDesc::set_dir_of_anisotropy 00113 // Access: Published 00114 // Description: Sets the shape space direction (unit vector) of 00115 // anisotropy. 00116 // This is only used if the flag MF_anisotropic is 00117 // set. 00118 //////////////////////////////////////////////////////////////////// 00119 void PhysxMaterialDesc:: 00120 set_dir_of_anisotropy(const LVector3f dir) { 00121 00122 _desc.dirOfAnisotropy = PhysxManager::vec3_to_nxVec3(dir); 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: PhysxMaterialDesc::set_friction_combine_mode 00127 // Access: Published 00128 // Description: Sets the friction combine mode. 00129 // - CM_average : Average: (a + b)/2. 00130 // - CM_min : Minimum: min(a,b). 00131 // - CM_multiply : Multiply: a*b. 00132 // - CM_max : Maximum: max(a,b). 00133 //////////////////////////////////////////////////////////////////// 00134 void PhysxMaterialDesc:: 00135 set_friction_combine_mode(PhysxCombineMode mode) { 00136 00137 _desc.frictionCombineMode = (NxCombineMode)mode; 00138 } 00139 00140 //////////////////////////////////////////////////////////////////// 00141 // Function: PhysxMaterialDesc::set_restitution_combine_mode 00142 // Access: Published 00143 // Description: Sets the restitution combine mode. 00144 // - CM_average : Average: (a + b)/2. 00145 // - CM_min : Minimum: min(a,b). 00146 // - CM_multiply : Multiply: a*b. 00147 // - CM_max : Maximum: max(a,b). 00148 //////////////////////////////////////////////////////////////////// 00149 void PhysxMaterialDesc:: 00150 set_restitution_combine_mode(PhysxCombineMode mode) { 00151 00152 _desc.restitutionCombineMode = (NxCombineMode)mode; 00153 } 00154 00155 //////////////////////////////////////////////////////////////////// 00156 // Function: PhysxMaterialDesc::get_restitution 00157 // Access: Published 00158 // Description: Returns the coefficient of restitution. 00159 //////////////////////////////////////////////////////////////////// 00160 float PhysxMaterialDesc:: 00161 get_restitution() const { 00162 00163 return _desc.restitution; 00164 } 00165 00166 //////////////////////////////////////////////////////////////////// 00167 // Function: PhysxMaterialDesc::get_static_friction 00168 // Access: Published 00169 // Description: Retruns the coefficient of static friction. 00170 //////////////////////////////////////////////////////////////////// 00171 float PhysxMaterialDesc:: 00172 get_static_friction() const { 00173 00174 return _desc.staticFriction; 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: PhysxMaterialDesc::get_dynamic_friction 00179 // Access: Published 00180 // Description: Returns the coefficient of dynamic friction. 00181 //////////////////////////////////////////////////////////////////// 00182 float PhysxMaterialDesc:: 00183 get_dynamic_friction() const { 00184 00185 return _desc.dynamicFriction; 00186 } 00187 00188 //////////////////////////////////////////////////////////////////// 00189 // Function: PhysxMaterialDesc::get_static_friction_v 00190 // Access: Published 00191 // Description: Returns the anisotropic static friction coefficient 00192 // for along the secondary (V) axis of anisotropy. 00193 //////////////////////////////////////////////////////////////////// 00194 float PhysxMaterialDesc:: 00195 get_static_friction_v() const { 00196 00197 return _desc.staticFrictionV; 00198 } 00199 00200 //////////////////////////////////////////////////////////////////// 00201 // Function: PhysxMaterialDesc::get_dynamic_friction_v 00202 // Access: Published 00203 // Description: Returns the anisotropic dynamic friction 00204 // coefficient for along the secondary (V) axis of 00205 // anisotropy. 00206 //////////////////////////////////////////////////////////////////// 00207 float PhysxMaterialDesc:: 00208 get_dynamic_friction_v() const { 00209 00210 return _desc.dynamicFrictionV; 00211 } 00212 00213 //////////////////////////////////////////////////////////////////// 00214 // Function: PhysxMaterialDesc::get_flag 00215 // Access: Published 00216 // Description: Returns flags which control the behavior of a 00217 // material. 00218 //////////////////////////////////////////////////////////////////// 00219 bool PhysxMaterialDesc:: 00220 get_flag(PhysxMaterialFlag flag) const { 00221 00222 return (_desc.flags & flag) ? true : false; 00223 } 00224 00225 //////////////////////////////////////////////////////////////////// 00226 // Function: PhysxMaterialDesc::get_dir_of_anisotropy 00227 // Access: Published 00228 // Description: Returns the shape space direction (unit vector) of 00229 // anisotropy. 00230 //////////////////////////////////////////////////////////////////// 00231 LVector3f PhysxMaterialDesc:: 00232 get_dir_of_anisotropy() const { 00233 00234 return PhysxManager::nxVec3_to_vec3(_desc.dirOfAnisotropy); 00235 } 00236 00237 //////////////////////////////////////////////////////////////////// 00238 // Function: PhysxMaterialDesc::get_friction_combine_mode 00239 // Access: Published 00240 // Description: Returns the friction combine mode. 00241 //////////////////////////////////////////////////////////////////// 00242 PhysxEnums::PhysxCombineMode PhysxMaterialDesc:: 00243 get_friction_combine_mode() const { 00244 00245 return (PhysxCombineMode)_desc.frictionCombineMode; 00246 } 00247 00248 //////////////////////////////////////////////////////////////////// 00249 // Function: PhysxMaterialDesc::get_restitution_combine_mode 00250 // Access: Published 00251 // Description: Returns the restitution combine mode. 00252 //////////////////////////////////////////////////////////////////// 00253 PhysxEnums::PhysxCombineMode PhysxMaterialDesc:: 00254 get_restitution_combine_mode() const { 00255 00256 return (PhysxCombineMode)_desc.restitutionCombineMode; 00257 } 00258