[1963] | 1 | /* |
---|
| 2 | Bullet Continuous Collision Detection and Physics Library |
---|
| 3 | Copyright (c) 2003-2008 Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
| 4 | |
---|
| 5 | This software is provided 'as-is', without any express or implied warranty. |
---|
| 6 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
| 7 | Permission is granted to anyone to use this software for any purpose, |
---|
| 8 | including commercial applications, and to alter it and redistribute it freely, |
---|
| 9 | subject to the following restrictions: |
---|
| 10 | |
---|
| 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. |
---|
| 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
| 13 | 3. This notice may not be removed or altered from any source distribution. |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #ifndef SOFT_BODY_HELPERS_H |
---|
| 17 | #define SOFT_BODY_HELPERS_H |
---|
| 18 | |
---|
| 19 | #include "btSoftBody.h" |
---|
| 20 | |
---|
| 21 | // |
---|
| 22 | // Helpers |
---|
| 23 | // |
---|
| 24 | |
---|
| 25 | /* fDrawFlags */ |
---|
| 26 | struct fDrawFlags { enum _ { |
---|
| 27 | Nodes = 0x0001, |
---|
| 28 | Links = 0x0002, |
---|
| 29 | Faces = 0x0004, |
---|
| 30 | Tetras = 0x0008, |
---|
| 31 | Normals = 0x0010, |
---|
| 32 | Contacts = 0x0020, |
---|
| 33 | Anchors = 0x0040, |
---|
| 34 | Notes = 0x0080, |
---|
| 35 | Clusters = 0x0100, |
---|
| 36 | NodeTree = 0x0200, |
---|
| 37 | FaceTree = 0x0400, |
---|
| 38 | ClusterTree = 0x0800, |
---|
| 39 | Joints = 0x1000, |
---|
| 40 | /* presets */ |
---|
| 41 | Std = Links+Faces+Tetras+Anchors+Notes+Joints, |
---|
| 42 | StdTetra = Std-Faces+Tetras, |
---|
| 43 | };}; |
---|
| 44 | |
---|
| 45 | struct btSoftBodyHelpers |
---|
| 46 | { |
---|
| 47 | /* Draw body */ |
---|
| 48 | static void Draw( btSoftBody* psb, |
---|
| 49 | btIDebugDraw* idraw, |
---|
| 50 | int drawflags=fDrawFlags::Std); |
---|
| 51 | /* Draw body infos */ |
---|
| 52 | static void DrawInfos( btSoftBody* psb, |
---|
| 53 | btIDebugDraw* idraw, |
---|
| 54 | bool masses, |
---|
| 55 | bool areas, |
---|
| 56 | bool stress); |
---|
| 57 | /* Draw node tree */ |
---|
| 58 | static void DrawNodeTree( btSoftBody* psb, |
---|
| 59 | btIDebugDraw* idraw, |
---|
| 60 | int mindepth=0, |
---|
| 61 | int maxdepth=-1); |
---|
| 62 | /* Draw face tree */ |
---|
| 63 | static void DrawFaceTree( btSoftBody* psb, |
---|
| 64 | btIDebugDraw* idraw, |
---|
| 65 | int mindepth=0, |
---|
| 66 | int maxdepth=-1); |
---|
| 67 | /* Draw cluster tree */ |
---|
| 68 | static void DrawClusterTree(btSoftBody* psb, |
---|
| 69 | btIDebugDraw* idraw, |
---|
| 70 | int mindepth=0, |
---|
| 71 | int maxdepth=-1); |
---|
| 72 | /* Draw rigid frame */ |
---|
| 73 | static void DrawFrame( btSoftBody* psb, |
---|
| 74 | btIDebugDraw* idraw); |
---|
| 75 | /* Create a rope */ |
---|
| 76 | static btSoftBody* CreateRope( btSoftBodyWorldInfo& worldInfo, |
---|
| 77 | const btVector3& from, |
---|
| 78 | const btVector3& to, |
---|
| 79 | int res, |
---|
| 80 | int fixeds); |
---|
| 81 | /* Create a patch */ |
---|
| 82 | static btSoftBody* CreatePatch(btSoftBodyWorldInfo& worldInfo, |
---|
| 83 | const btVector3& corner00, |
---|
| 84 | const btVector3& corner10, |
---|
| 85 | const btVector3& corner01, |
---|
| 86 | const btVector3& corner11, |
---|
| 87 | int resx, |
---|
| 88 | int resy, |
---|
| 89 | int fixeds, |
---|
| 90 | bool gendiags); |
---|
| 91 | /* Create a patch with UV Texture Coordinates */ |
---|
| 92 | static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo, |
---|
| 93 | const btVector3& corner00, |
---|
| 94 | const btVector3& corner10, |
---|
| 95 | const btVector3& corner01, |
---|
| 96 | const btVector3& corner11, |
---|
| 97 | int resx, |
---|
| 98 | int resy, |
---|
| 99 | int fixeds, |
---|
| 100 | bool gendiags, |
---|
| 101 | float* tex_coords=0); |
---|
| 102 | static float CalculateUV(int resx,int resy,int ix,int iy,int id); |
---|
| 103 | /* Create an ellipsoid */ |
---|
| 104 | static btSoftBody* CreateEllipsoid(btSoftBodyWorldInfo& worldInfo, |
---|
| 105 | const btVector3& center, |
---|
| 106 | const btVector3& radius, |
---|
| 107 | int res); |
---|
| 108 | /* Create from trimesh */ |
---|
| 109 | static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo, |
---|
| 110 | const btScalar* vertices, |
---|
| 111 | const int* triangles, |
---|
| 112 | int ntriangles); |
---|
| 113 | /* Create from convex-hull */ |
---|
| 114 | static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo, |
---|
| 115 | const btVector3* vertices, |
---|
| 116 | int nvertices); |
---|
| 117 | }; |
---|
| 118 | |
---|
| 119 | #endif //SOFT_BODY_HELPERS_H |
---|