Panda3D

Loading...
Searching...
No Matches
physxMaterial.h
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 physxMaterial.h
10 * @author enn0x
11 * @date 2009-09-21
12 */
13
14#ifndef PHYSXMATERIAL_H
15#define PHYSXMATERIAL_H
16
17#include "pandabase.h"
18#include "luse.h"
19
20#include "physxObject.h"
21#include "physxEnums.h"
22#include "physx_includes.h"
23
24 class PhysxScene;
25 class PhysxMaterialDesc;
26
27/**
28 * A class for describing a shape's surface properties.
29 *
30 * You can create a material which has different friction coefficients
31 * depending on the direction that a body in contact is trying to move in.
32 * This is called anisotropic friction.
33 *
34 * Anisotropic friction is useful for modeling things like sledges, skis etc
35 *
36 * When you create an anisotropic material you specify the default friction
37 * parameters and also friction parameters for the V axis. The friction
38 * parameters for the V axis are applied to motion along the direction of
39 * anisotropy (dirOfAnisotropy).
40 *
41 * Default material: You can change the properties of the default material by
42 * querying for material index 0.
43 */
44 class EXPCL_PANDAPHYSX PhysxMaterial : public PhysxObject, public PhysxEnums {
45
46PUBLISHED:
47 INLINE PhysxMaterial();
48 INLINE ~PhysxMaterial();
49
50 PhysxScene *get_scene() const;
51 unsigned short get_material_index() const;
52
53 void load_from_desc(const PhysxMaterialDesc &materialDesc);
54 void save_to_desc(PhysxMaterialDesc &materialDesc) const;
55
56 void set_dynamic_friction(float coef);
57 void set_static_friction(float coef);
58 void set_restitution(float rest);
59 void set_dynamic_friction_v(float coef);
60 void set_static_friction_v(float coef);
61 void set_dir_of_anisotropy(const LVector3f dir);
62 void set_flag(PhysxMaterialFlag flag, bool value);
63 void set_friction_combine_mode(PhysxCombineMode mode);
64 void set_restitution_combine_mode(PhysxCombineMode mode);
65
66 float get_dynamic_friction() const;
67 float get_static_friction() const;
68 float get_restitution() const;
69 float get_dynamic_friction_v() const;
70 float get_static_friction_v() const;
71 LVector3f get_dir_of_anisotropy() const;
72 bool get_flag(PhysxMaterialFlag flag) const;
73 PhysxCombineMode get_friction_combine_mode() const;
74 PhysxCombineMode get_restitution_combine_mode() const;
75
76 INLINE void ls() const;
77 INLINE void ls(std::ostream &out, int indent_level=0) const;
78
79PUBLISHED:
80 void release();
81
82 public:
83 INLINE NxMaterial *ptr() const { return _ptr; };
84
85 void link(NxMaterial *ptr);
86 void unlink();
87
88 private:
89 NxMaterial *_ptr;
90
91 public:
92 static TypeHandle get_class_type() {
93 return _type_handle;
94 }
95 static void init_type() {
96 PhysxObject::init_type();
97 register_type(_type_handle, "PhysxMaterial",
98 PhysxObject::get_class_type());
99 }
100 virtual TypeHandle get_type() const {
101 return get_class_type();
102 }
103 virtual TypeHandle force_init_type() {
104 init_type();
105 return get_class_type();
106 }
107
108 private:
109 static TypeHandle _type_handle;
110};
111
112#include "physxMaterial.I"
113
114#endif // PHYSXMATERIAL_H
PhysxEnums
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition physxEnums.h:355
PhysxMaterialDesc
Descriptor class for materials.
Definition physxMaterialDesc.h:25
PhysxMaterial::set_restitution_combine_mode
void set_restitution_combine_mode(PhysxCombineMode mode)
Sets the restitution combine mode.
Definition physxMaterial.cxx:301
PhysxMaterial::set_dynamic_friction_v
void set_dynamic_friction_v(float coef)
Sets the dynamic friction coefficient along the secondary (V) axis.
Definition physxMaterial.cxx:207
PhysxMaterial::load_from_desc
void load_from_desc(const PhysxMaterialDesc &materialDesc)
Loads the entire state of the material from a descriptor with a single call.
Definition physxMaterial.cxx:94
PhysxMaterial::get_restitution
float get_restitution() const
Returns the coefficient of restitution.
Definition physxMaterial.cxx:126
PhysxMaterial::get_static_friction
float get_static_friction() const
Returns the coefficient of static friction.
Definition physxMaterial.cxx:149
PhysxMaterial::get_scene
PhysxScene * get_scene() const
Returns the scene that owns this material.
Definition physxMaterial.cxx:66
PhysxMaterial::get_restitution_combine_mode
PhysxCombineMode get_restitution_combine_mode() const
Returns the restitution combine mode.
Definition physxMaterial.cxx:311
PhysxMaterial::set_dir_of_anisotropy
void set_dir_of_anisotropy(const LVector3f dir)
Sets the shape space direction (unit vector) of anisotropy.
Definition physxMaterial.cxx:257
PhysxMaterial::set_restitution
void set_restitution(float rest)
Sets the coefficient of restitution.
Definition physxMaterial.cxx:116
PhysxMaterial::get_flag
bool get_flag(PhysxMaterialFlag flag) const
Returns the value of a single flag.
Definition physxMaterial.cxx:246
PhysxMaterial::get_friction_combine_mode
PhysxCombineMode get_friction_combine_mode() const
Returns the friction combine mode.
Definition physxMaterial.cxx:289
PhysxMaterial::get_static_friction_v
float get_static_friction_v() const
Returns the static friction coefficient for the V direction.
Definition physxMaterial.cxx:195
PhysxMaterial::get_dir_of_anisotropy
LVector3f get_dir_of_anisotropy() const
Returns the direction of anisotropy value.
Definition physxMaterial.cxx:267
PhysxMaterial::get_dynamic_friction_v
float get_dynamic_friction_v() const
Returns the dynamic friction coefficient for the V direction.
Definition physxMaterial.cxx:217
PhysxMaterial::set_dynamic_friction
void set_dynamic_friction(float coef)
Sets the coefficient of dynamic friction.
Definition physxMaterial.cxx:163
PhysxMaterial::set_static_friction_v
void set_static_friction_v(float coef)
Sets the static friction coefficient along the secondary (V) axis.
Definition physxMaterial.cxx:185
PhysxMaterial::save_to_desc
void save_to_desc(PhysxMaterialDesc &materialDesc) const
Saves the state of the material object to a descriptor.
Definition physxMaterial.cxx:104
PhysxMaterial::set_static_friction
void set_static_friction(float coef)
Sets the coefficient of static friction.
Definition physxMaterial.cxx:139
PhysxMaterial::get_dynamic_friction
float get_dynamic_friction() const
Returns the DynamicFriction value.
Definition physxMaterial.cxx:173
PhysxMaterial::get_material_index
unsigned short get_material_index() const
Returns the material index for this material.
Definition physxMaterial.cxx:83
PhysxMaterial::set_friction_combine_mode
void set_friction_combine_mode(PhysxCombineMode mode)
Sets the friction combine mode.
Definition physxMaterial.cxx:279
PhysxMaterial::set_flag
void set_flag(PhysxMaterialFlag flag, bool value)
Sets the value of a single flag.
Definition physxMaterial.cxx:227
PhysxScene
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition physxScene.h:69
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxEnums.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxMaterial.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxObject.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physx_includes.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22