Panda3D
|
00001 // Filename: physxSoftBodyNode.h 00002 // Created by: enn0x (13Sep10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PHYSXSOFTBODYNODE_H 00016 #define PHYSXSOFTBODYNODE_H 00017 00018 #include "pandabase.h" 00019 #include "pointerTo.h" 00020 #include "geomNode.h" 00021 #include "transformState.h" 00022 #include "geom.h" 00023 #include "geomVertexData.h" 00024 #include "geomTriangles.h" 00025 #include "filename.h" 00026 00027 #include "physx_includes.h" 00028 00029 class PhysxSoftBody; 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Class : PhysxSoftBodyNode 00033 // Description : Renderable geometry which represents a soft body 00034 // mesh. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDAPHYSX PhysxSoftBodyNode : public GeomNode { 00037 00038 PUBLISHED: 00039 INLINE PhysxSoftBodyNode(const char *name); 00040 INLINE ~PhysxSoftBodyNode(); 00041 00042 void set_from_geom(const Geom *geom); 00043 00044 public: 00045 void allocate(PhysxSoftBody *cloth); 00046 void update(); 00047 00048 private: 00049 00050 struct TetraLink { 00051 int tetraNr; 00052 NxVec3 barycentricCoords; 00053 }; 00054 00055 void update_bounds(); 00056 void build_tetra_links(); 00057 bool update_tetra_links(); 00058 void update_normals(); 00059 void remove_tris_related_to_vertex(const int vertexIndex); 00060 NxVec3 compute_bary_coords(NxVec3 vertex, NxVec3 p0, NxVec3 p1, NxVec3 p2, NxVec3 p3) const; 00061 00062 pvector<TetraLink> _tetraLinks; 00063 pvector<bool> _drainedTriVertices; 00064 pvector<LVecBase3f> _normals; 00065 00066 NxBounds3 _bounds; 00067 NxMeshData _mesh; 00068 00069 PT(GeomVertexData) _vdata; 00070 PT(Geom) _geom; 00071 PT(GeomTriangles) _prim; 00072 00073 PT(PhysxSoftBody) _softbody; 00074 00075 //////////////////////////////////////////////////////////////////// 00076 public: 00077 static TypeHandle get_class_type() { 00078 return _type_handle; 00079 } 00080 static void init_type() { 00081 GeomNode::init_type(); 00082 register_type(_type_handle, "PhysxSoftBodyNode", 00083 GeomNode::get_class_type()); 00084 } 00085 virtual TypeHandle get_type() const { 00086 return get_class_type(); 00087 } 00088 virtual TypeHandle force_init_type() { 00089 init_type(); 00090 return get_class_type(); 00091 } 00092 00093 private: 00094 static TypeHandle _type_handle; 00095 }; 00096 00097 #include "physxSoftBodyNode.I" 00098 00099 #endif // PHYSXSOFTBODYNODE_H