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
24class PhysxScene;
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 */
44class 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
82public:
83 INLINE NxMaterial *ptr() const { return _ptr; };
84
85 void link(NxMaterial *ptr);
86 void unlink();
87
88private:
89 NxMaterial *_ptr;
90
91public:
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
108private:
109 static TypeHandle _type_handle;
110};
111
112#include "physxMaterial.I"
113
114#endif // PHYSXMATERIAL_H
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition physxEnums.h:355
Descriptor class for materials.
void set_restitution_combine_mode(PhysxCombineMode mode)
Sets the restitution combine mode.
void set_dynamic_friction_v(float coef)
Sets the dynamic friction coefficient along the secondary (V) axis.
void load_from_desc(const PhysxMaterialDesc &materialDesc)
Loads the entire state of the material from a descriptor with a single call.
float get_restitution() const
Returns the coefficient of restitution.
float get_static_friction() const
Returns the coefficient of static friction.
PhysxScene * get_scene() const
Returns the scene that owns this material.
PhysxCombineMode get_restitution_combine_mode() const
Returns the restitution combine mode.
void set_dir_of_anisotropy(const LVector3f dir)
Sets the shape space direction (unit vector) of anisotropy.
void set_restitution(float rest)
Sets the coefficient of restitution.
bool get_flag(PhysxMaterialFlag flag) const
Returns the value of a single flag.
PhysxCombineMode get_friction_combine_mode() const
Returns the friction combine mode.
float get_static_friction_v() const
Returns the static friction coefficient for the V direction.
LVector3f get_dir_of_anisotropy() const
Returns the direction of anisotropy value.
float get_dynamic_friction_v() const
Returns the dynamic friction coefficient for the V direction.
void set_dynamic_friction(float coef)
Sets the coefficient of dynamic friction.
void set_static_friction_v(float coef)
Sets the static friction coefficient along the secondary (V) axis.
void save_to_desc(PhysxMaterialDesc &materialDesc) const
Saves the state of the material object to a descriptor.
void set_static_friction(float coef)
Sets the coefficient of static friction.
float get_dynamic_friction() const
Returns the DynamicFriction value.
unsigned short get_material_index() const
Returns the material index for this material.
void set_friction_combine_mode(PhysxCombineMode mode)
Sets the friction combine mode.
void set_flag(PhysxMaterialFlag flag, bool value)
Sets the value of a single flag.
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition physxScene.h:69
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...