Panda3D

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
46 PUBLISHED:
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
79 PUBLISHED:
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
A class for describing a shape's surface properties.
Definition: physxMaterial.h:44
PhysxObject
Definition: physxObject.h:28
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