Panda3D
physxMaterialDesc.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxMaterialDesc.cxx
10  * @author enn0x
11  * @date 2009-09-21
12  */
13 
14 #include "physxMaterialDesc.h"
15 #include "physxManager.h"
16 
17 /**
18  * Sets the coefficient of restitution -- 0 makes the object bounce as little
19  * as possible, higher values up to 1.0 result in more bounce. Note that
20  * values close to or above 1 may cause stability problems and/or increasing
21  * energy. Range: [0,1] Default: 0.0
22  */
24 set_restitution(float restitution) {
25 
26  _desc.restitution = restitution;
27 }
28 
29 /**
30  * Sets the coefficient of static friction -- should be in [0, +inf]. If the
31  * flag MF_anisotropic is set, then this value is used for the primary
32  * direction of anisotropy (U axis).
33  */
35 set_static_friction(float coef) {
36 
37  _desc.staticFriction = coef;
38 }
39 
40 /**
41  * Sets the coefficient of dynamic friction -- should be in [0, +inf]. If set
42  * to greater than staticFriction, the effective value of staticFriction will
43  * be increased to match. If the flag MF_anisotropic is set, then this value
44  * is used for the primary direction of anisotropy (U axis).
45  */
47 set_dynamic_friction(float coef) {
48 
49  _desc.dynamicFriction = coef;
50 }
51 
52 /**
53  * Sets the anisotropic static friction coefficient for along the secondary
54  * (V) axis of anisotropy. This is only used if the flag MF_anisotropic is
55  * set.
56  */
58 set_static_friction_v(float coef) {
59 
60  _desc.staticFrictionV = coef;
61 }
62 
63 /**
64  * Sets the anisotropic dynamic friction coefficient for along the secondary
65  * (V) axis of anisotropy. This is only used if the flag MF_anisotropic is
66  * set.
67  */
70 
71  _desc.dynamicFrictionV = coef;
72 }
73 
74 /**
75  * Sets flags which control the behavior of a material.
76  */
78 set_flag(PhysxMaterialFlag flag, bool value) {
79 
80  if (value == true) {
81  _desc.flags |= flag;
82  }
83  else {
84  _desc.flags &= ~(flag);
85  }
86 }
87 
88 /**
89  * Sets the shape space direction (unit vector) of anisotropy. This is only
90  * used if the flag MF_anisotropic is set.
91  */
93 set_dir_of_anisotropy(const LVector3f dir) {
94 
95  _desc.dirOfAnisotropy = PhysxManager::vec3_to_nxVec3(dir);
96 }
97 
98 /**
99  * Sets the friction combine mode. - CM_average : Average: (a + b)/2. -
100  * CM_min : Minimum: min(a,b). - CM_multiply : Multiply: a*b. - CM_max :
101  * Maximum: max(a,b).
102  */
104 set_friction_combine_mode(PhysxCombineMode mode) {
105 
106  _desc.frictionCombineMode = (NxCombineMode)mode;
107 }
108 
109 /**
110  * Sets the restitution combine mode. - CM_average : Average: (a + b)/2. -
111  * CM_min : Minimum: min(a,b). - CM_multiply : Multiply: a*b. - CM_max :
112  * Maximum: max(a,b).
113  */
115 set_restitution_combine_mode(PhysxCombineMode mode) {
116 
117  _desc.restitutionCombineMode = (NxCombineMode)mode;
118 }
119 
120 /**
121  * Returns the coefficient of restitution.
122  */
125 
126  return _desc.restitution;
127 }
128 
129 /**
130  * Retruns the coefficient of static friction.
131  */
134 
135  return _desc.staticFriction;
136 }
137 
138 /**
139  * Returns the coefficient of dynamic friction.
140  */
143 
144  return _desc.dynamicFriction;
145 }
146 
147 /**
148  * Returns the anisotropic static friction coefficient for along the secondary
149  * (V) axis of anisotropy.
150  */
153 
154  return _desc.staticFrictionV;
155 }
156 
157 /**
158  * Returns the anisotropic dynamic friction coefficient for along the
159  * secondary (V) axis of anisotropy.
160  */
163 
164  return _desc.dynamicFrictionV;
165 }
166 
167 /**
168  * Returns flags which control the behavior of a material.
169  */
171 get_flag(PhysxMaterialFlag flag) const {
172 
173  return (_desc.flags & flag) ? true : false;
174 }
175 
176 /**
177  * Returns the shape space direction (unit vector) of anisotropy.
178  */
179 LVector3f PhysxMaterialDesc::
181 
182  return PhysxManager::nxVec3_to_vec3(_desc.dirOfAnisotropy);
183 }
184 
185 /**
186  * Returns the friction combine mode.
187  */
188 PhysxEnums::PhysxCombineMode PhysxMaterialDesc::
190 
191  return (PhysxCombineMode)_desc.frictionCombineMode;
192 }
193 
194 /**
195  * Returns the restitution combine mode.
196  */
197 PhysxEnums::PhysxCombineMode PhysxMaterialDesc::
199 
200  return (PhysxCombineMode)_desc.restitutionCombineMode;
201 }
float get_static_friction_v() const
Returns the anisotropic static friction coefficient for along the secondary (V) axis of anisotropy.
void set_dynamic_friction_v(float coef)
Sets the anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy.
void set_flag(PhysxMaterialFlag flag, bool value)
Sets flags which control the behavior of a material.
float get_restitution() const
Returns the coefficient of restitution.
PhysxCombineMode get_restitution_combine_mode() const
Returns the restitution combine mode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LVector3f get_dir_of_anisotropy() const
Returns the shape space direction (unit vector) of anisotropy.
bool get_flag(PhysxMaterialFlag flag) const
Returns flags which control the behavior of a material.
void set_dynamic_friction(float coef)
Sets the coefficient of dynamic friction – should be in [0, +inf].
void set_dir_of_anisotropy(const LVector3f dir)
Sets the shape space direction (unit vector) of anisotropy.
void set_restitution(float rest)
Sets the coefficient of restitution – 0 makes the object bounce as little as possible,...
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
float get_dynamic_friction() const
Returns the coefficient of dynamic friction.
float get_dynamic_friction_v() const
Returns the anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy.
void set_friction_combine_mode(PhysxCombineMode mode)
Sets the friction combine mode.
void set_static_friction(float coef)
Sets the coefficient of static friction – should be in [0, +inf].
float get_static_friction() const
Retruns the coefficient of static friction.
PhysxCombineMode get_friction_combine_mode() const
Returns the friction combine mode.
void set_restitution_combine_mode(PhysxCombineMode mode)
Sets the restitution combine mode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_static_friction_v(float coef)
Sets the anisotropic static friction coefficient for along the secondary (V) axis of anisotropy.