Panda3D
physxSoftBody.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 physxSoftBody.h
10  * @author enn0x
11  * @date 2010-09-13
12  */
13 
14 #ifndef PHYSXSOFTBODY_H
15 #define PHYSXSOFTBODY_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 PhysxSoftBodyNode;
28 
29 /**
30  *
31  */
32 class EXPCL_PANDAPHYSX PhysxSoftBody : public PhysxObject, public PhysxEnums {
33 
34 PUBLISHED:
35  INLINE PhysxSoftBody();
36  INLINE ~PhysxSoftBody();
37 
38  PhysxScene *get_scene() const;
39  PhysxSoftBodyNode *get_soft_body_node() const;
40  PhysxSoftBodyNode *create_soft_body_node(const char *name);
41 
42  void set_name(const char *name);
43  void set_flag(PhysxSoftBodyFlag flag, bool value);
44  void set_groups_mask(const PhysxGroupsMask &mask);
45  void set_group(unsigned int group);
46  void set_solver_iterations(unsigned int iterations);
47  void set_particle_radius(float radius);
48 #if NX_SDK_VERSION_NUMBER > 281
49  void set_self_collision_thickness(float thickness);
50  void set_hard_stretch_limitation_factor(float factor);
51 #endif
52  void set_volume_stiffness(float stiffness);
53  void set_stretching_stiffness(float stiffness);
54  void set_damping_coefficient(float coef);
55  void set_friction(float friction);
56  void set_tear_factor(float factor);
57  void set_attachment_tear_factor(float factor);
58 
59  const char *get_name() const;
60  bool get_flag(PhysxSoftBodyFlag flag) const;
61  PhysxGroupsMask get_groups_mask() const;
62  unsigned int get_group() const;
63  unsigned int get_num_particles();
64  unsigned int get_solver_iterations() const;
65  float get_particle_radius() const;
66  float get_density() const;
67  float get_relative_grid_spacing() const;
68 #if NX_SDK_VERSION_NUMBER > 281
69  float get_self_collision_thickness() const;
70  float get_hard_stretch_limitation_factor() const;
71 #endif
72  float get_volume_stiffness() const;
73  float get_stretching_stiffness() const;
74  float get_damping_coefficient() const;
75  float get_friction() const;
76  float get_tear_factor() const;
77  float get_attachment_tear_factor() const;
78 
79 /*
80  // Attachment
81  void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos);
82  void free_vertex(unsigned int vertexId);
83  void attach_to_shape(PhysxShape *shape);
84  void attach_to_colliding_shapes();
85  void detach_from_shape(PhysxShape *shape);
86  void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos);
87  PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const;
88  PhysxShape *get_vertex_attachment_shape(unsigned int vertexId) const;
89  LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const;
90 */
91 
92  // Sleeping
93  bool is_sleeping() const;
94  void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL);
95  void put_to_sleep();
96  void set_sleep_linear_velocity(float threshold);
97  float get_sleep_linear_velocity() const;
98 
99 /*
100  // Forces
101  void set_external_acceleration(LVector3f const &acceleration);
102  LVector3f get_external_acceleration() const;
103 
104  void set_wind_acceleration(LVector3f const &acceleration);
105  LVector3f get_wind_acceleration() const;
106 
107  void add_force_at_vertex(LVector3f const &force, int vertexId,
108  PhysxForceMode mode=FM_force);
109  void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius,
110  PhysxForceMode mode=FM_force);
111  void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius,
112  PhysxForceMode mode=FM_force);
113 */
114 
115 
116 /*
117 virtual void getWorldBounds (NxBounds3 &bounds) const =0
118 virtual void attachToShape (const NxShape *shape, NxU32 attachmentFlags)=0
119 virtual void attachToCollidingShapes (NxU32 attachmentFlags)=0
120 virtual void detachFromShape (const NxShape *shape)=0
121 virtual void attachVertexToShape (NxU32 vertexId, const NxShape *shape, const NxVec3 &localPos, NxU32 attachmentFlags)=0
122 virtual void attachVertexToGlobalPosition (const NxU32 vertexId, const NxVec3 &pos)=0
123 virtual void freeVertex (const NxU32 vertexId)=0
124 virtual bool tearVertex (const NxU32 vertexId, const NxVec3 &normal)=0
125 virtual bool raycast (const NxRay &worldRay, NxVec3 &hit, NxU32 &vertexId)=0
126 virtual void setMeshData (NxMeshData &meshData)=0
127 virtual NxMeshData getMeshData ()=0
128 virtual void setSplitPairData (NxSoftBodySplitPairData &splitPairData)=0
129 virtual NxSoftBodySplitPairData getSplitPairData ()=0
130 virtual void setValidBounds (const NxBounds3 &validBounds)=0
131 virtual void getValidBounds (NxBounds3 &validBounds) const =0
132 virtual void setPosition (const NxVec3 &position, NxU32 vertexId)=0
133 virtual void setPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0
134 virtual NxVec3 getPosition (NxU32 vertexId) const =0
135 virtual void getPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0
136 virtual void setVelocity (const NxVec3 &velocity, NxU32 vertexId)=0
137 virtual void setVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0
138 virtual NxVec3 getVelocity (NxU32 vertexId) const =0
139 virtual void getVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0
140 virtual void setConstrainPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0
141 virtual void setConstrainNormals (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0
142 virtual void setConstrainCoefficients (const NxSoftBodyConstrainCoefficients *coefficients, NxU32 byteStride=sizeof(NxSoftBodyConstrainCoefficients))=0
143 virtual NxU32 queryShapePointers ()=0
144 virtual NxU32 getStateByteSize ()=0
145 virtual void getShapePointers (NxShape **shapePointers, NxU32 *flags)=0
146 virtual void setShapePointers (NxShape **shapePointers, unsigned int numShapes)=0
147 virtual void saveStateToStream (NxStream &stream, bool permute=false)=0
148 virtual void loadStateFromStream (NxStream &stream)=0
149 virtual void setCollisionResponseCoefficient (NxReal coefficient)=0
150 virtual NxReal getCollisionResponseCoefficient () const =0
151 virtual void setAttachmentResponseCoefficient (NxReal coefficient)=0
152 virtual NxReal getAttachmentResponseCoefficient () const =0
153 virtual void setFromFluidResponseCoefficient (NxReal coefficient)=0
154 virtual NxReal getFromFluidResponseCoefficient () const =0
155 virtual void setToFluidResponseCoefficient (NxReal coefficient)=0
156 virtual NxReal getToFluidResponseCoefficient () const =0
157 virtual void setExternalAcceleration (NxVec3 acceleration)=0
158 virtual NxVec3 getExternalAcceleration () const =0
159 virtual void setMinAdhereVelocity (NxReal velocity)=0
160 virtual NxReal getMinAdhereVelocity () const =0
161 virtual void addForceAtVertex (const NxVec3 &force, NxU32 vertexId, NxForceMode mode=NX_FORCE)=0
162 virtual void addForceAtPos (const NxVec3 &position, NxReal magnitude, NxReal radius, NxForceMode mode=NX_FORCE)=0
163 virtual void addDirectedForceAtPos (const NxVec3 &position, const NxVec3 &force, NxReal radius, NxForceMode mode=NX_FORCE)=0
164 virtual bool overlapAABBTetrahedra (const NxBounds3 &bounds, NxU32 &nb, const NxU32 *&indices) const =0
165 virtual NxCompartment * getCompartment () const =0
166 virtual NxForceFieldMaterial getForceFieldMaterial () const =0
167 virtual void setForceFieldMaterial (NxForceFieldMaterial)=0
168 */
169 
170  INLINE void ls() const;
171  INLINE void ls(std::ostream &out, int indent_level=0) const;
172 
173 public:
174  void update();
175 
176 PUBLISHED:
177  void release();
178 
179 public:
180  INLINE NxSoftBody *ptr() const { return _ptr; };
181 
182  void link(NxSoftBody *ptr);
183  void unlink();
184 
185 private:
186  NxSoftBody *_ptr;
187  PT(PhysxSoftBodyNode) _node;
188  std::string _name;
189 
190 public:
191  static TypeHandle get_class_type() {
192  return _type_handle;
193  }
194  static void init_type() {
195  PhysxObject::init_type();
196  register_type(_type_handle, "PhysxSoftBody",
197  PhysxObject::get_class_type());
198  }
199  virtual TypeHandle get_type() const {
200  return get_class_type();
201  }
202  virtual TypeHandle force_init_type() {
203  init_type();
204  return get_class_type();
205  }
206 
207 private:
208  static TypeHandle _type_handle;
209 };
210 
211 #include "physxSoftBody.I"
212 
213 #endif // PHYSXSOFTBODY_H
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(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition: physxEnums.h:355
Renderable geometry which represents a soft body mesh.
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.
128-bit bitmask class.