Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Demos / SerializeDemo / SerializeDemo.h
1
2 /*
3 Bullet Continuous Collision Detection and Physics Library
4 Copyright (c) 2003-2010 Erwin Coumans  http://continuousphysics.com/Bullet/
5
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:
11
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.
15 */
16 #ifndef SERIALIZE_DEMO_H
17 #define SERIALIZE_DEMO_H
18
19 #ifdef _WINDOWS
20 #include "Win32DemoApplication.h"
21 #define PlatformDemoApplication Win32DemoApplication
22 #else
23 #include "GlutDemoApplication.h"
24 #define PlatformDemoApplication GlutDemoApplication
25 #endif
26
27 #include "LinearMath/btAlignedObjectArray.h"
28
29 class btBroadphaseInterface;
30 class btCollisionShape;
31 class btOverlappingPairCache;
32 class btCollisionDispatcher;
33 class btConstraintSolver;
34 struct btCollisionAlgorithmCreateFunc;
35 class btDefaultCollisionConfiguration;
36
37 ///SerializeDemo shows how to use save and load binary .bullet physics files (work-in-progress)
38 class SerializeDemo : public PlatformDemoApplication
39 {
40
41         //keep the collision shapes, for deletion/cleanup
42         btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
43
44         btBroadphaseInterface*  m_broadphase;
45
46         btCollisionDispatcher*  m_dispatcher;
47
48         btConstraintSolver*     m_solver;
49
50         btDefaultCollisionConfiguration* m_collisionConfiguration;
51
52         class btBulletWorldImporter*            m_fileLoader;
53         const char*             m_fileName;
54         int                             m_verboseMode;
55
56         public:
57
58         SerializeDemo();
59         virtual ~SerializeDemo();
60
61         void    initPhysics();
62
63         void    setupEmptyDynamicsWorld();
64
65         void    exitPhysics();
66
67         virtual void keyboardCallback(unsigned char key, int x, int y);
68
69         virtual void clientMoveAndDisplay();
70
71         virtual void displayCallback();
72         
73         void    setFileName(const char* name)
74         {
75                 m_fileName = name;
76         }
77         const char* getFileName() const
78         {
79                 return m_fileName;
80         }
81
82         void    setVerboseMode(int mode)
83         {
84                 m_verboseMode = mode;
85         }
86         int     getVerboseMode() const
87         {
88                 return m_verboseMode;
89         }
90
91         static DemoApplication* Create()
92         {
93                 SerializeDemo* demo = new SerializeDemo;
94                 demo->myinit();
95                 demo->initPhysics();
96                 return demo;
97         }
98
99         
100 };
101
102 #endif //SERIALIZE_DEMO_H
103