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