Bullet Collision Detection & Physics Library
btSoftBodyHelpers.h
Go to the documentation of this file.
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 BT_SOFT_BODY_HELPERS_H
17 #define BT_SOFT_BODY_HELPERS_H
18 
19 #include "btSoftBody.h"
20 
21 //
22 // Helpers
23 //
24 
25 /* fDrawFlags */
26 struct fDrawFlags
27 {
28  enum _
29  {
30  Nodes = 0x0001,
31  Links = 0x0002,
32  Faces = 0x0004,
33  Tetras = 0x0008,
34  Normals = 0x0010,
35  Contacts = 0x0020,
36  Anchors = 0x0040,
37  Notes = 0x0080,
38  Clusters = 0x0100,
39  NodeTree = 0x0200,
40  FaceTree = 0x0400,
41  ClusterTree = 0x0800,
42  Joints = 0x1000,
43  /* presets */
46  };
47 };
48 
50 {
51  /* Draw body */
52  static void Draw(btSoftBody* psb,
53  btIDebugDraw* idraw,
54  int drawflags = fDrawFlags::Std);
55  /* Draw body infos */
56  static void DrawInfos(btSoftBody* psb,
57  btIDebugDraw* idraw,
58  bool masses,
59  bool areas,
60  bool stress);
61  /* Draw node tree */
62  static void DrawNodeTree(btSoftBody* psb,
63  btIDebugDraw* idraw,
64  int mindepth = 0,
65  int maxdepth = -1);
66  /* Draw face tree */
67  static void DrawFaceTree(btSoftBody* psb,
68  btIDebugDraw* idraw,
69  int mindepth = 0,
70  int maxdepth = -1);
71  /* Draw cluster tree */
72  static void DrawClusterTree(btSoftBody* psb,
73  btIDebugDraw* idraw,
74  int mindepth = 0,
75  int maxdepth = -1);
76  /* Draw rigid frame */
77  static void DrawFrame(btSoftBody* psb,
78  btIDebugDraw* idraw);
79  /* Create a rope */
80  static btSoftBody* CreateRope(btSoftBodyWorldInfo& worldInfo,
81  const btVector3& from,
82  const btVector3& to,
83  int res,
84  int fixeds);
85  /* Create a patch */
86  static btSoftBody* CreatePatch(btSoftBodyWorldInfo& worldInfo,
87  const btVector3& corner00,
88  const btVector3& corner10,
89  const btVector3& corner01,
90  const btVector3& corner11,
91  int resx,
92  int resy,
93  int fixeds,
94  bool gendiags);
95  /* Create a patch with UV Texture Coordinates */
96  static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
97  const btVector3& corner00,
98  const btVector3& corner10,
99  const btVector3& corner01,
100  const btVector3& corner11,
101  int resx,
102  int resy,
103  int fixeds,
104  bool gendiags,
105  float* tex_coords = 0);
106  static float CalculateUV(int resx, int resy, int ix, int iy, int id);
107  /* Create an ellipsoid */
108  static btSoftBody* CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,
109  const btVector3& center,
110  const btVector3& radius,
111  int res);
112  /* Create from trimesh */
113  static btSoftBody* CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,
114  const btScalar* vertices,
115  const int* triangles,
116  int ntriangles,
117  bool randomizeConstraints = true);
118  /* Create from convex-hull */
119  static btSoftBody* CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo,
120  const btVector3* vertices,
121  int nvertices,
122  bool randomizeConstraints = true);
123 
124  /* Export TetGen compatible .smesh file */
125  // static void ExportAsSMeshFile( btSoftBody* psb,
126  // const char* filename);
127  /* Create from TetGen .ele, .face, .node files */
128  // static btSoftBody* CreateFromTetGenFile( btSoftBodyWorldInfo& worldInfo,
129  // const char* ele,
130  // const char* face,
131  // const char* node,
132  // bool bfacelinks,
133  // bool btetralinks,
134  // bool bfacesfromtetras);
135  /* Create from TetGen .ele, .face, .node data */
136  static btSoftBody* CreateFromTetGenData(btSoftBodyWorldInfo& worldInfo,
137  const char* ele,
138  const char* face,
139  const char* node,
140  bool bfacelinks,
141  bool btetralinks,
142  bool bfacesfromtetras);
143 
148  static void ReoptimizeLinkOrder(btSoftBody* psb);
149 };
150 
151 #endif //BT_SOFT_BODY_HELPERS_H
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:26
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:70
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294