Panda3D
physxMaterial.h
1 // Filename: physxMaterial.h
2 // Created by: enn0x (21Sep09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PHYSXMATERIAL_H
16 #define PHYSXMATERIAL_H
17 
18 #include "pandabase.h"
19 #include "luse.h"
20 
21 #include "physxObject.h"
22 #include "physxEnums.h"
23 #include "physx_includes.h"
24 
25 class PhysxScene;
26 class PhysxMaterialDesc;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : PhysxMaterial
30 // Description : A class for describing a shape's surface
31 // properties.
32 //
33 // You can create a material which has different
34 // friction coefficients depending on the direction
35 // that a body in contact is trying to move in. This
36 // is called anisotropic friction.
37 //
38 // Anisotropic friction is useful for modeling things
39 // like sledges, skis etc
40 //
41 // When you create an anisotropic material you specify
42 // the default friction parameters and also friction
43 // parameters for the V axis. The friction parameters
44 // for the V axis are applied to motion along the
45 // direction of anisotropy (dirOfAnisotropy).
46 //
47 // Default material: You can change the properties of
48 // the default material by querying for material
49 // index 0.
50 ////////////////////////////////////////////////////////////////////
51 class EXPCL_PANDAPHYSX PhysxMaterial : public PhysxObject, public PhysxEnums {
52 
53 PUBLISHED:
54  INLINE PhysxMaterial();
55  INLINE ~PhysxMaterial();
56 
57  PhysxScene *get_scene() const;
58  unsigned short get_material_index() const;
59 
60  void load_from_desc(const PhysxMaterialDesc &materialDesc);
61  void save_to_desc(PhysxMaterialDesc &materialDesc) const;
62 
63  void set_dynamic_friction(float coef);
64  void set_static_friction(float coef);
65  void set_restitution(float rest);
66  void set_dynamic_friction_v(float coef);
67  void set_static_friction_v(float coef);
68  void set_dir_of_anisotropy(const LVector3f dir);
69  void set_flag(PhysxMaterialFlag flag, bool value);
70  void set_friction_combine_mode(PhysxCombineMode mode);
71  void set_restitution_combine_mode(PhysxCombineMode mode);
72 
73  float get_dynamic_friction() const;
74  float get_static_friction() const;
75  float get_restitution() const;
76  float get_dynamic_friction_v() const;
77  float get_static_friction_v() const;
78  LVector3f get_dir_of_anisotropy() const;
79  bool get_flag(PhysxMaterialFlag flag) const;
80  PhysxCombineMode get_friction_combine_mode() const;
81  PhysxCombineMode get_restitution_combine_mode() const;
82 
83  INLINE void ls() const;
84  INLINE void ls(ostream &out, int indent_level=0) const;
85 
86 ////////////////////////////////////////////////////////////////////
87 PUBLISHED:
88  void release();
89 
90 public:
91  INLINE NxMaterial *ptr() const { return _ptr; };
92 
93  void link(NxMaterial *ptr);
94  void unlink();
95 
96 private:
97  NxMaterial *_ptr;
98 
99 ////////////////////////////////////////////////////////////////////
100 public:
101  static TypeHandle get_class_type() {
102  return _type_handle;
103  }
104  static void init_type() {
105  PhysxObject::init_type();
106  register_type(_type_handle, "PhysxMaterial",
107  PhysxObject::get_class_type());
108  }
109  virtual TypeHandle get_type() const {
110  return get_class_type();
111  }
112  virtual TypeHandle force_init_type() {
113  init_type();
114  return get_class_type();
115  }
116 
117 private:
118  static TypeHandle _type_handle;
119 };
120 
121 #include "physxMaterial.I"
122 
123 #endif // PHYSXMATERIAL_H
Descriptor class for materials.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
A scene is a collection of bodies, constraints, and effectors which can interact. ...
Definition: physxScene.h:73
A class for describing a shape's surface properties.
Definition: physxMaterial.h:51
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition: physxEnums.h:357
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85