Panda3D
 All Classes Functions Variables Enumerations
physxSoftBodyNode.h
1 // Filename: physxSoftBodyNode.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 PHYSXSOFTBODYNODE_H
16 #define PHYSXSOFTBODYNODE_H
17 
18 #include "pandabase.h"
19 #include "pointerTo.h"
20 #include "geomNode.h"
21 #include "transformState.h"
22 #include "geom.h"
23 #include "geomVertexData.h"
24 #include "geomTriangles.h"
25 #include "filename.h"
26 
27 #include "physx_includes.h"
28 
29 class PhysxSoftBody;
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : PhysxSoftBodyNode
33 // Description : Renderable geometry which represents a soft body
34 // mesh.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDAPHYSX PhysxSoftBodyNode : public GeomNode {
37 
38 PUBLISHED:
39  INLINE PhysxSoftBodyNode(const char *name);
40  INLINE ~PhysxSoftBodyNode();
41 
42  void set_from_geom(const Geom *geom);
43 
44 public:
45  void allocate(PhysxSoftBody *cloth);
46  void update();
47 
48 private:
49 
50  struct TetraLink {
51  int tetraNr;
52  NxVec3 barycentricCoords;
53  };
54 
55  void update_bounds();
56  void build_tetra_links();
57  bool update_tetra_links();
58  void update_normals();
59  void remove_tris_related_to_vertex(const int vertexIndex);
60  NxVec3 compute_bary_coords(NxVec3 vertex, NxVec3 p0, NxVec3 p1, NxVec3 p2, NxVec3 p3) const;
61 
62  pvector<TetraLink> _tetraLinks;
63  pvector<bool> _drainedTriVertices;
64  pvector<LVecBase3f> _normals;
65 
66  NxBounds3 _bounds;
67  NxMeshData _mesh;
68 
69  PT(GeomVertexData) _vdata;
70  PT(Geom) _geom;
71  PT(GeomTriangles) _prim;
72 
73  PT(PhysxSoftBody) _softbody;
74 
75 ////////////////////////////////////////////////////////////////////
76 public:
77  static TypeHandle get_class_type() {
78  return _type_handle;
79  }
80  static void init_type() {
81  GeomNode::init_type();
82  register_type(_type_handle, "PhysxSoftBodyNode",
83  GeomNode::get_class_type());
84  }
85  virtual TypeHandle get_type() const {
86  return get_class_type();
87  }
88  virtual TypeHandle force_init_type() {
89  init_type();
90  return get_class_type();
91  }
92 
93 private:
94  static TypeHandle _type_handle;
95 };
96 
97 #include "physxSoftBodyNode.I"
98 
99 #endif // PHYSXSOFTBODYNODE_H
Renderable geometry which represents a soft body mesh.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition: geom.h:58
Defines a series of disconnected triangles.
Definition: geomTriangles.h:25
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37