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