3 Bullet Continuous Collision Detection and Physics Library
4 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
6 This software is provided 'as-is', without any express or implied warranty.
7 In no event will the authors be held liable for any damages arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it freely,
10 subject to the following restrictions:
12 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.
13 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14 3. This notice may not be removed or altered from any source distribution.
17 ///btSoftBody implementation by Nathanael Presson
23 #include "Win32DemoApplication.h"
24 #define PlatformDemoApplication Win32DemoApplication
26 #include "GlutDemoApplication.h"
27 #define PlatformDemoApplication GlutDemoApplication
29 #include "LinearMath/btAlignedObjectArray.h"
30 #include "BulletSoftBody/btSoftBody.h"
33 class btBroadphaseInterface;
34 class btCollisionShape;
35 class btOverlappingPairCache;
36 class btCollisionDispatcher;
37 class btConstraintSolver;
38 struct btCollisionAlgorithmCreateFunc;
39 class btDefaultCollisionConfiguration;
41 ///collisions between two btSoftBody's
42 class btSoftSoftCollisionAlgorithm;
44 ///collisions between a btSoftBody and a btRigidBody
45 class btSoftRididCollisionAlgorithm;
46 class btSoftRigidDynamicsWorld;
49 ///CcdPhysicsDemo shows basic stacking using Bullet physics, and allows toggle of Ccd (using key '1')
50 class SoftDemo : public PlatformDemoApplication
54 btAlignedObjectArray<btSoftSoftCollisionAlgorithm*> m_SoftSoftCollisionAlgorithms;
56 btAlignedObjectArray<btSoftRididCollisionAlgorithm*> m_SoftRigidCollisionAlgorithms;
58 btSoftBodyWorldInfo m_softBodyWorldInfo;
67 int m_lastmousepos[2];
69 btSoftBody::sRayCast m_results;
70 btSoftBody::Node* m_node;
75 //keep the collision shapes, for deletion/cleanup
76 btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
78 btBroadphaseInterface* m_broadphase;
80 btCollisionDispatcher* m_dispatcher;
83 btConstraintSolver* m_solver;
85 btCollisionAlgorithmCreateFunc* m_boxBoxCF;
87 btDefaultCollisionConfiguration* m_collisionConfiguration;
96 SoftDemo() : m_drag(false)
106 virtual void clientMoveAndDisplay();
108 virtual void displayCallback();
110 void createStack( btCollisionShape* boxShape, float halfCubeSize, int size, float zPos );
112 static DemoApplication* Create()
114 SoftDemo* demo = new SoftDemo;
120 virtual void setDrawClusters(bool drawClusters);
122 virtual const btSoftRigidDynamicsWorld* getSoftDynamicsWorld() const
124 ///just make it a btSoftRigidDynamicsWorld please
125 ///or we will add type checking
126 return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
129 virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
131 ///just make it a btSoftRigidDynamicsWorld please
132 ///or we will add type checking
133 return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
137 void clientResetScene();
139 void keyboardCallback(unsigned char key, int x, int y);
140 void mouseFunc(int button, int state, int x, int y);
141 void mouseMotionFunc(int x,int y);
145 #define MACRO_SOFT_DEMO(a) class SoftDemo##a : public SoftDemo\
148 static DemoApplication* Create()\
150 SoftDemo* demo = new SoftDemo##a;\
151 extern int current_demo;\
154 demo->initPhysics();\
160 MACRO_SOFT_DEMO(0) //Init_Cloth
161 MACRO_SOFT_DEMO(1) //Init_Pressure
162 MACRO_SOFT_DEMO(2)//Init_Volume
163 MACRO_SOFT_DEMO(3)//Init_Ropes
164 MACRO_SOFT_DEMO(4)//Init_Ropes_Attach
165 MACRO_SOFT_DEMO(5)//Init_ClothAttach
166 MACRO_SOFT_DEMO(6)//Init_Sticks
167 MACRO_SOFT_DEMO(7)//Init_Collide
168 MACRO_SOFT_DEMO(8)//Init_Collide2
169 MACRO_SOFT_DEMO(9)//Init_Collide3
170 MACRO_SOFT_DEMO(10)//Init_Impact
171 MACRO_SOFT_DEMO(11)//Init_Aero
172 MACRO_SOFT_DEMO(12)//Init_Friction
173 MACRO_SOFT_DEMO(13)//Init_Torus
174 MACRO_SOFT_DEMO(14)//Init_TorusMatch
175 MACRO_SOFT_DEMO(15)//Init_Bunny
176 MACRO_SOFT_DEMO(16)//Init_BunnyMatch
177 MACRO_SOFT_DEMO(17)//Init_Cutting1
178 MACRO_SOFT_DEMO(18)//Init_ClusterDeform
179 MACRO_SOFT_DEMO(19)//Init_ClusterCollide1
180 MACRO_SOFT_DEMO(20)//Init_ClusterCollide2
181 MACRO_SOFT_DEMO(21)//Init_ClusterSocket
182 MACRO_SOFT_DEMO(22)//Init_ClusterHinge
183 MACRO_SOFT_DEMO(23)//Init_ClusterCombine
184 MACRO_SOFT_DEMO(24)//Init_ClusterCar
185 MACRO_SOFT_DEMO(25)//Init_ClusterRobot
186 MACRO_SOFT_DEMO(26)//Init_ClusterStackSoft
187 MACRO_SOFT_DEMO(27)//Init_ClusterStackMixed
188 MACRO_SOFT_DEMO(28)//Init_TetraCube
189 MACRO_SOFT_DEMO(29)//Init_TetraBunny
192 #endif //CCD_PHYSICS_DEMO_H