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 { 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 */
43 };};
44 
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 */
105  const btVector3& center,
106  const btVector3& radius,
107  int res);
108  /* Create from trimesh */
110  const btScalar* vertices,
111  const int* triangles,
112  int ntriangles,
113  bool randomizeConstraints = true);
114  /* Create from convex-hull */
116  const btVector3* vertices,
117  int nvertices,
118  bool randomizeConstraints = true);
119 
120 
121  /* Export TetGen compatible .smesh file */
122 // static void ExportAsSMeshFile( btSoftBody* psb,
123 // const char* filename);
124  /* Create from TetGen .ele, .face, .node files */
125 // static btSoftBody* CreateFromTetGenFile( btSoftBodyWorldInfo& worldInfo,
126 // const char* ele,
127 // const char* face,
128 // const char* node,
129 // bool bfacelinks,
130 // bool btetralinks,
131 // bool bfacesfromtetras);
132  /* Create from TetGen .ele, .face, .node data */
134  const char* ele,
135  const char* face,
136  const char* node,
137  bool bfacelinks,
138  bool btetralinks,
139  bool bfacesfromtetras);
140 
145  static void ReoptimizeLinkOrder(btSoftBody *psb );
146 };
147 
148 #endif //BT_SOFT_BODY_HELPERS_H
btSoftBodyHelpers::DrawClusterTree
static void DrawClusterTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:477
fDrawFlags::FaceTree
@ FaceTree
Definition: btSoftBodyHelpers.h:37
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btSoftBodyHelpers::CreateFromTriMesh
static btSoftBody * CreateFromTriMesh(btSoftBodyWorldInfo &worldInfo, const btScalar *vertices, const int *triangles, int ntriangles, bool randomizeConstraints=true)
Definition: btSoftBodyHelpers.cpp:1019
btSoftBodyHelpers::DrawNodeTree
static void DrawNodeTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:459
btSoftBodyHelpers::CreatePatch
static btSoftBody * CreatePatch(btSoftBodyWorldInfo &worldInfo, const btVector3 &corner00, const btVector3 &corner10, const btVector3 &corner01, const btVector3 &corner11, int resx, int resy, int fixeds, bool gendiags)
Definition: btSoftBodyHelpers.cpp:704
btSoftBodyHelpers::CreateRope
static btSoftBody * CreateRope(btSoftBodyWorldInfo &worldInfo, const btVector3 &from, const btVector3 &to, int res, int fixeds)
Definition: btSoftBodyHelpers.cpp:672
fDrawFlags::StdTetra
@ StdTetra
Definition: btSoftBodyHelpers.h:42
btSoftBodyHelpers::DrawFrame
static void DrawFrame(btSoftBody *psb, btIDebugDraw *idraw)
Definition: btSoftBodyHelpers.cpp:648
fDrawFlags::Notes
@ Notes
Definition: btSoftBodyHelpers.h:34
btSoftBodyWorldInfo
Definition: btSoftBody.h:43
btSoftBodyHelpers::CreatePatchUV
static btSoftBody * CreatePatchUV(btSoftBodyWorldInfo &worldInfo, const btVector3 &corner00, const btVector3 &corner10, const btVector3 &corner01, const btVector3 &corner11, int resx, int resy, int fixeds, bool gendiags, float *tex_coords=0)
Definition: btSoftBodyHelpers.cpp:781
fDrawFlags::Anchors
@ Anchors
Definition: btSoftBodyHelpers.h:33
fDrawFlags::Links
@ Links
Definition: btSoftBodyHelpers.h:28
btSoftBodyHelpers::CreateEllipsoid
static btSoftBody * CreateEllipsoid(btSoftBodyWorldInfo &worldInfo, const btVector3 &center, const btVector3 &radius, int res)
Definition: btSoftBodyHelpers.cpp:987
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:29
btSoftBodyHelpers::CreateFromTetGenData
static btSoftBody * CreateFromTetGenData(btSoftBodyWorldInfo &worldInfo, const char *ele, const char *face, const char *node, bool bfacelinks, bool btetralinks, bool bfacesfromtetras)
Definition: btSoftBodyHelpers.cpp:1117
fDrawFlags::Normals
@ Normals
Definition: btSoftBodyHelpers.h:31
fDrawFlags::_
_
Definition: btSoftBodyHelpers.h:26
fDrawFlags::Contacts
@ Contacts
Definition: btSoftBodyHelpers.h:32
fDrawFlags::Clusters
@ Clusters
Definition: btSoftBodyHelpers.h:35
fDrawFlags::Faces
@ Faces
Definition: btSoftBodyHelpers.h:29
fDrawFlags::Joints
@ Joints
Definition: btSoftBodyHelpers.h:39
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btSoftBodyHelpers::DrawInfos
static void DrawInfos(btSoftBody *psb, btIDebugDraw *idraw, bool masses, bool areas, bool stress)
Definition: btSoftBodyHelpers.cpp:433
btSoftBodyHelpers::ReoptimizeLinkOrder
static void ReoptimizeLinkOrder(btSoftBody *psb)
Sort the list of links to move link calculations that are dependent upon earlier ones as far as possi...
Definition: btSoftBodyHelpers.cpp:538
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:71
fDrawFlags::NodeTree
@ NodeTree
Definition: btSoftBodyHelpers.h:36
btSoftBodyHelpers::Draw
static void Draw(btSoftBody *psb, btIDebugDraw *idraw, int drawflags=fDrawFlags::Std)
Definition: btSoftBodyHelpers.cpp:161
fDrawFlags::ClusterTree
@ ClusterTree
Definition: btSoftBodyHelpers.h:38
fDrawFlags::Std
@ Std
Definition: btSoftBodyHelpers.h:41
btSoftBodyHelpers::CalculateUV
static float CalculateUV(int resx, int resy, int ix, int iy, int id)
Definition: btSoftBodyHelpers.cpp:943
btSoftBodyHelpers::DrawFaceTree
static void DrawFaceTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:468
btSoftBodyHelpers
Definition: btSoftBodyHelpers.h:45
btSoftBodyHelpers::CreateFromConvexHull
static btSoftBody * CreateFromConvexHull(btSoftBodyWorldInfo &worldInfo, const btVector3 *vertices, int nvertices, bool randomizeConstraints=true)
Definition: btSoftBodyHelpers.cpp:1066
fDrawFlags::Tetras
@ Tetras
Definition: btSoftBodyHelpers.h:30
fDrawFlags::Nodes
@ Nodes
Definition: btSoftBodyHelpers.h:27
btSoftBody.h
fDrawFlags
Definition: btSoftBodyHelpers.h:26