Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Demos / ConcaveDemo / ConcaveDemo.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 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 #ifndef CONCAVE_DEMO_H
16 #define CONCAVE_DEMO_H
17
18 #ifdef _WINDOWS
19 #include "Win32DemoApplication.h"
20 #define PlatformDemoApplication Win32DemoApplication
21 #else
22 #include "GlutDemoApplication.h"
23 #define PlatformDemoApplication GlutDemoApplication
24 #endif
25
26 #include "LinearMath/btAlignedObjectArray.h"
27
28 class btBroadphaseInterface;
29 class btCollisionShape;
30 class btOverlappingPairCache;
31 class btCollisionDispatcher;
32 class btConstraintSolver;
33 struct btCollisionAlgorithmCreateFunc;
34 class btDefaultCollisionConfiguration;
35 class btTriangleIndexVertexArray;
36
37 ///ConcaveDemo shows usage of static concave triangle meshes
38 ///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
39 class ConcaveDemo : public PlatformDemoApplication
40 {
41
42         //keep the collision shapes, for deletion/cleanup
43         btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
44
45         btTriangleIndexVertexArray* m_indexVertexArrays;
46
47         btBroadphaseInterface*  m_broadphase;
48
49         btCollisionDispatcher*  m_dispatcher;
50
51         btConstraintSolver*     m_solver;
52
53         btDefaultCollisionConfiguration* m_collisionConfiguration;
54
55         bool    m_animatedMesh;
56
57         public:
58
59         ConcaveDemo() : m_animatedMesh(true)
60         {
61
62         }
63         void    initPhysics();
64
65         void    exitPhysics();
66
67         virtual ~ConcaveDemo()
68         {
69                 exitPhysics();
70         }
71
72         virtual void clientMoveAndDisplay();
73
74         virtual void displayCallback();
75         
76         //to show refit works
77         void    setVertexPositions(float waveheight, float offset);
78         
79         virtual void keyboardCallback(unsigned char key, int x, int y);
80         
81         static DemoApplication* Create()
82         {
83                 ConcaveDemo* demo = new ConcaveDemo();
84                 demo->myinit();
85                 demo->initPhysics();
86                 return demo;
87         };
88 };
89
90 #endif //CONCAVE_DEMO_H
91