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 */
23 void PhysxMaterialDesc::
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 */
34 void PhysxMaterialDesc::
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 */
46 void PhysxMaterialDesc::
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 */
57 void PhysxMaterialDesc::
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 */
68 void PhysxMaterialDesc::
69 set_dynamic_friction_v(float coef) {
70
71 _desc.dynamicFrictionV = coef;
72 }
73
74 /**
75 * Sets flags which control the behavior of a material.
76 */
77 void PhysxMaterialDesc::
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 */
92 void PhysxMaterialDesc::
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 */
103 void PhysxMaterialDesc::
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 */
114 void PhysxMaterialDesc::
115 set_restitution_combine_mode(PhysxCombineMode mode) {
116
117 _desc.restitutionCombineMode = (NxCombineMode)mode;
118 }
119
120 /**
121 * Returns the coefficient of restitution.
122 */
123 float PhysxMaterialDesc::
124 get_restitution() const {
125
126 return _desc.restitution;
127 }
128
129 /**
130 * Retruns the coefficient of static friction.
131 */
132 float PhysxMaterialDesc::
133 get_static_friction() const {
134
135 return _desc.staticFriction;
136 }
137
138 /**
139 * Returns the coefficient of dynamic friction.
140 */
141 float PhysxMaterialDesc::
142 get_dynamic_friction() const {
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 */
151 float PhysxMaterialDesc::
152 get_static_friction_v() const {
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 */
161 float PhysxMaterialDesc::
162 get_dynamic_friction_v() const {
163
164 return _desc.dynamicFrictionV;
165 }
166
167 /**
168 * Returns flags which control the behavior of a material.
169 */
170 bool PhysxMaterialDesc::
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::
180 get_dir_of_anisotropy() const {
181
182 return PhysxManager::nxVec3_to_vec3(_desc.dirOfAnisotropy);
183 }
184
185 /**
186 * Returns the friction combine mode.
187 */
188 PhysxEnums::PhysxCombineMode PhysxMaterialDesc::
189 get_friction_combine_mode() const {
190
191 return (PhysxCombineMode)_desc.frictionCombineMode;
192 }
193
194 /**
195 * Returns the restitution combine mode.
196 */
197 PhysxEnums::PhysxCombineMode PhysxMaterialDesc::
198 get_restitution_combine_mode() const {
199
200 return (PhysxCombineMode)_desc.restitutionCombineMode;
201 }
PhysxManager::vec3_to_nxVec3
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
PhysxManager::nxVec3_to_vec3
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
PhysxMaterialDesc::set_dynamic_friction_v
void set_dynamic_friction_v(float coef)
Sets the anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy.
Definition: physxMaterialDesc.cxx:69
PhysxMaterialDesc::set_dynamic_friction
void set_dynamic_friction(float coef)
Sets the coefficient of dynamic friction – should be in [0, +inf].
Definition: physxMaterialDesc.cxx:47
PhysxMaterialDesc::get_restitution
float get_restitution() const
Returns the coefficient of restitution.
Definition: physxMaterialDesc.cxx:124
PhysxMaterialDesc::set_restitution
void set_restitution(float rest)
Sets the coefficient of restitution – 0 makes the object bounce as little as possible,...
Definition: physxMaterialDesc.cxx:24
PhysxMaterialDesc::set_friction_combine_mode
void set_friction_combine_mode(PhysxCombineMode mode)
Sets the friction combine mode.
Definition: physxMaterialDesc.cxx:104
PhysxMaterialDesc::get_dynamic_friction_v
float get_dynamic_friction_v() const
Returns the anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy.
Definition: physxMaterialDesc.cxx:162
PhysxMaterialDesc::set_restitution_combine_mode
void set_restitution_combine_mode(PhysxCombineMode mode)
Sets the restitution combine mode.
Definition: physxMaterialDesc.cxx:115
PhysxMaterialDesc::get_dynamic_friction
float get_dynamic_friction() const
Returns the coefficient of dynamic friction.
Definition: physxMaterialDesc.cxx:142
PhysxMaterialDesc::set_static_friction
void set_static_friction(float coef)
Sets the coefficient of static friction – should be in [0, +inf].
Definition: physxMaterialDesc.cxx:35
PhysxMaterialDesc::get_static_friction
float get_static_friction() const
Retruns the coefficient of static friction.
Definition: physxMaterialDesc.cxx:133
PhysxMaterialDesc::set_flag
void set_flag(PhysxMaterialFlag flag, bool value)
Sets flags which control the behavior of a material.
Definition: physxMaterialDesc.cxx:78
PhysxMaterialDesc::set_dir_of_anisotropy
void set_dir_of_anisotropy(const LVector3f dir)
Sets the shape space direction (unit vector) of anisotropy.
Definition: physxMaterialDesc.cxx:93
PhysxMaterialDesc::get_friction_combine_mode
PhysxCombineMode get_friction_combine_mode() const
Returns the friction combine mode.
Definition: physxMaterialDesc.cxx:189
PhysxMaterialDesc::get_dir_of_anisotropy
LVector3f get_dir_of_anisotropy() const
Returns the shape space direction (unit vector) of anisotropy.
Definition: physxMaterialDesc.cxx:180
PhysxMaterialDesc::get_restitution_combine_mode
PhysxCombineMode get_restitution_combine_mode() const
Returns the restitution combine mode.
Definition: physxMaterialDesc.cxx:198
PhysxMaterialDesc::get_static_friction_v
float get_static_friction_v() const
Returns the anisotropic static friction coefficient for along the secondary (V) axis of anisotropy.
Definition: physxMaterialDesc.cxx:152
PhysxMaterialDesc::set_static_friction_v
void set_static_friction_v(float coef)
Sets the anisotropic static friction coefficient for along the secondary (V) axis of anisotropy.
Definition: physxMaterialDesc.cxx:58
PhysxMaterialDesc::get_flag
bool get_flag(PhysxMaterialFlag flag) const
Returns flags which control the behavior of a material.
Definition: physxMaterialDesc.cxx:171
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxMaterialDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.