Panda3D
physxCloth.h
1 // Filename: physxCloth.h
2 // Created by: enn0x (30Mar10)
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 PHYSXCLOTH_H
16 #define PHYSXCLOTH_H
17 
18 #include "pandabase.h"
19 #include "luse.h"
20 
21 #include "physxObject.h"
22 #include "physxObjectCollection.h"
23 #include "physxEnums.h"
24 #include "physx_includes.h"
25 
26 class PhysxScene;
27 class PhysxGroupsMask;
28 class PhysxClothNode;
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : PhysxCloth
32 // Description :
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDAPHYSX PhysxCloth : public PhysxObject, public PhysxEnums {
35 
36 PUBLISHED:
37  INLINE PhysxCloth();
38  INLINE ~PhysxCloth();
39 
40  PhysxScene *get_scene() const;
41  PhysxClothNode *get_cloth_node() const;
42  PhysxClothNode *create_cloth_node(const char *name);
43 
44  void set_name(const char *name);
45  void set_group(unsigned int group);
46  void set_groups_mask(const PhysxGroupsMask &mask);
47  void set_flag(PhysxClothFlag flag, bool value);
48  void set_thickness(float thickness);
49 
50  const char *get_name() const;
51  unsigned int get_num_particles();
52  unsigned int get_group() const;
53  PhysxGroupsMask get_groups_mask() const;
54  bool get_flag(PhysxClothFlag flag) const;
55  float get_thickness() const;
56  float get_density() const;
57  float get_relative_grid_spacing() const;
58 
59  // Attachment
60  void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos);
61  void free_vertex(unsigned int vertexId);
62  void attach_to_shape(PhysxShape *shape);
63  void attach_to_colliding_shapes();
64  void detach_from_shape(PhysxShape *shape);
65  void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos);
66  PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const;
67  PhysxShape *get_vertex_attachment_shape(unsigned int vertexId) const;
68  LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const;
69 
70  // Sleeping
71  bool is_sleeping() const;
72  void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL);
73  void put_to_sleep();
74  void set_sleep_linear_velocity(float threshold);
75  float get_sleep_linear_velocity() const;
76 
77  // Forces
78  void set_external_acceleration(LVector3f const &acceleration);
79  LVector3f get_external_acceleration() const;
80 
81  void set_wind_acceleration(LVector3f const &acceleration);
82  LVector3f get_wind_acceleration() const;
83 
84  void add_force_at_vertex(LVector3f const &force, int vertexId,
85  PhysxForceMode mode=FM_force);
86  void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius,
87  PhysxForceMode mode=FM_force);
88  void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius,
89  PhysxForceMode mode=FM_force);
90 
91  INLINE void ls() const;
92  INLINE void ls(ostream &out, int indent_level=0) const;
93 
94 public:
95  void update();
96 
97 ////////////////////////////////////////////////////////////////////
98 PUBLISHED:
99  void release();
100 
101 public:
102  INLINE NxCloth *ptr() const { return _ptr; };
103 
104  void link(NxCloth *ptr);
105  void unlink();
106 
107 private:
108  NxCloth *_ptr;
109  PT(PhysxClothNode) _node;
110  string _name;
111 
112 ////////////////////////////////////////////////////////////////////
113 public:
114  static TypeHandle get_class_type() {
115  return _type_handle;
116  }
117  static void init_type() {
118  PhysxObject::init_type();
119  register_type(_type_handle, "PhysxCloth",
120  PhysxObject::get_class_type());
121  }
122  virtual TypeHandle get_type() const {
123  return get_class_type();
124  }
125  virtual TypeHandle force_init_type() {
126  init_type();
127  return get_class_type();
128  }
129 
130 private:
131  static TypeHandle _type_handle;
132 };
133 
134 #include "physxCloth.I"
135 
136 #endif // PHYSXCLOTH_H
Abstract base class for shapes.
Definition: physxShape.h:41
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A scene is a collection of bodies, constraints, and effectors which can interact. ...
Definition: physxScene.h:73
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
Renderable geometry which represents a cloth mesh.
128-bit bitmask class.