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