source: proiecte/SIMEO/SimeoDemo/BasicDemo.h @ 168

Last change on this file since 168 was 168, checked in by (none), 14 years ago

Simeo: added initial proof of concept code.

File size: 3.1 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15#ifndef BASIC_DEMO_H
16#define BASIC_DEMO_H
17
18#include "GlutDemoApplication.h"
19#include <LinearMath/btAlignedObjectArray.h>
20#include "Agent.h"
21#include "Sensor.h"
22#include <utility>
23
24using namespace std;
25
26class btBroadphaseInterface;
27class btCollisionShape;
28class btOverlappingPairCache;
29class btCollisionDispatcher;
30class btConstraintSolver;
31struct btCollisionAlgorithmCreateFunc;
32class btDefaultCollisionConfiguration;
33
34///BasicDemo is good starting point for learning the code base and porting.
35class BasicDemo : public GlutDemoApplication
36{
37
38        //keep the collision shapes, for deletion/cleanup
39        btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
40       
41        btBroadphaseInterface*  m_broadphase;
42
43        btCollisionDispatcher*  m_dispatcher;
44
45        btConstraintSolver*     m_solver;
46
47        btDefaultCollisionConfiguration* m_collisionConfiguration;
48
49        public:
50        btAlignedObjectArray<btTypedConstraint*>        m_joints;
51        btAlignedObjectArray<Agent*>    m_agents;
52        btAlignedObjectArray<pair<int, Sensor*> > m_sensors;
53        btAlignedObjectArray<btAlignedObjectArray<int> > m_matrix;
54       
55        BasicDemo()
56        {
57        }
58        virtual ~BasicDemo()
59        {
60                exitPhysics();
61        }
62       
63        void    initPhysics();
64       
65        btScalar computeVelocity(btScalar currentAngle, btScalar targetAngle);
66        btRigidBody* localCreateRigidBody (btScalar mass, const btTransform& startTransform, btCollisionShape* shape);
67        btRigidBody* createObject(btCollisionShape* colShape, btVector3 position, btScalar mass);
68        btRigidBody* createObject(btCollisionShape* colShape, btTransform transform, btScalar mass);   
69       
70        void createHinge(bool enable);
71        void createMagicCarpet(int n, int m);
72        void createSwarm3D(int n, int m, int p);
73        void createSimulation2D(int n, int m);
74        void createSimulation3D(int n, int m, int p);
75
76        void updateSensors();
77        void updateActuators();
78        void updateAgents();
79       
80        void    exitPhysics();
81
82        void    debug();
83       
84        virtual void keyboardCallback(unsigned char key, int x, int y);
85       
86        virtual void clientMoveAndDisplay();
87
88        virtual void displayCallback();
89       
90        static DemoApplication* Create()
91        {
92                BasicDemo* demo = new BasicDemo;
93                demo->myinit();
94                demo->initPhysics();
95                return demo;
96        }
97};
98
99#endif //BASIC_DEMO_H
100
Note: See TracBrowser for help on using the repository browser.