Bullet Collision Detection & Physics Library: btSoftBodyHelpers.h Source File

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 */
44 Std = Links + Faces + Tetras + Anchors + Notes + Joints,
45 StdTetra = Std - Faces + Tetras
46 };
47 };
48
49 struct btSoftBodyHelpers
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
fDrawFlags::Anchors
Definition: btSoftBodyHelpers.h:36
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:794
fDrawFlags::Contacts
Definition: btSoftBodyHelpers.h:35
btSoftBodyHelpers::CreateEllipsoid
static btSoftBody * CreateEllipsoid(btSoftBodyWorldInfo &worldInfo, const btVector3 &center, const btVector3 &radius, int res)
Definition: btSoftBodyHelpers.cpp:1003
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:717
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:1128
btSoftBodyHelpers::DrawFaceTree
static void DrawFaceTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:469
fDrawFlags::_
_
Definition: btSoftBodyHelpers.h:28
fDrawFlags::Nodes
Definition: btSoftBodyHelpers.h:30
btSoftBodyHelpers::Draw
static void Draw(btSoftBody *psb, btIDebugDraw *idraw, int drawflags=fDrawFlags::Std)
Definition: btSoftBodyHelpers.cpp:166
btSoftBodyHelpers::CreateFromConvexHull
static btSoftBody * CreateFromConvexHull(btSoftBodyWorldInfo &worldInfo, const btVector3 *vertices, int nvertices, bool randomizeConstraints=true)
Definition: btSoftBodyHelpers.cpp:1081
fDrawFlags
Definition: btSoftBodyHelpers.h:26
btSoftBody.h
fDrawFlags::Joints
Definition: btSoftBodyHelpers.h:42
btSoftBodyHelpers::CreateRope
static btSoftBody * CreateRope(btSoftBodyWorldInfo &worldInfo, const btVector3 &from, const btVector3 &to, int res, int fixeds)
Definition: btSoftBodyHelpers.cpp:685
fDrawFlags::NodeTree
Definition: btSoftBodyHelpers.h:39
btSoftBodyHelpers::DrawInfos
static void DrawInfos(btSoftBody *psb, btIDebugDraw *idraw, bool masses, bool areas, bool stress)
Definition: btSoftBodyHelpers.cpp:434
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:26
btSoftBodyHelpers::DrawNodeTree
static void DrawNodeTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:460
fDrawFlags::Std
Definition: btSoftBodyHelpers.h:44
btSoftBodyHelpers::DrawClusterTree
static void DrawClusterTree(btSoftBody *psb, btIDebugDraw *idraw, int mindepth=0, int maxdepth=-1)
Definition: btSoftBodyHelpers.cpp:478
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
fDrawFlags::FaceTree
Definition: btSoftBodyHelpers.h:40
btSoftBodyHelpers::CalculateUV
static float CalculateUV(int resx, int resy, int ix, int iy, int id)
Definition: btSoftBodyHelpers.cpp:956
fDrawFlags::Faces
Definition: btSoftBodyHelpers.h:32
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:537
btSoftBodyHelpers::CreateFromTriMesh
static btSoftBody * CreateFromTriMesh(btSoftBodyWorldInfo &worldInfo, const btScalar *vertices, const int *triangles, int ntriangles, bool randomizeConstraints=true)
Definition: btSoftBodyHelpers.cpp:1034
fDrawFlags::Normals
Definition: btSoftBodyHelpers.h:34
fDrawFlags::ClusterTree
Definition: btSoftBodyHelpers.h:41
btSoftBodyWorldInfo
Definition: btSoftBody.h:43
fDrawFlags::Links
Definition: btSoftBodyHelpers.h:31
fDrawFlags::Clusters
Definition: btSoftBodyHelpers.h:38
btSoftBodyHelpers
Definition: btSoftBodyHelpers.h:49
btSoftBody
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
Definition: btSoftBody.h:70
fDrawFlags::Notes
Definition: btSoftBodyHelpers.h:37
fDrawFlags::Tetras
Definition: btSoftBodyHelpers.h:33
btSoftBodyHelpers::DrawFrame
static void DrawFrame(btSoftBody *psb, btIDebugDraw *idraw)
Definition: btSoftBodyHelpers.cpp:661
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
fDrawFlags::StdTetra
Definition: btSoftBodyHelpers.h:45