-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUniverse.h
executable file
·104 lines (83 loc) · 2.61 KB
/
Universe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include "opengl.h"
#include <set>
#include <string>
#include "Camera.h"
#include "config.h"
#include "Light.h"
#include "Object.h"
#include "Planet.h"
#include "Event.h"
#include <memory>
#include <BulletDynamics/btBulletDynamicsCommon.h>
#define perspective() gluPerspective(FOV,GLdouble(glutGet(GLUT_WINDOW_WIDTH)/\
glutGet(GLUT_WINDOW_HEIGHT)),NEAREST,FAREST)
/// The whole Universe
class Universe {
private:
/// Set of Object the Universe has to draw
std::set<std::unique_ptr<Object>> objects;
/// Main Light
Light mainLight;
// Physical part of the universe
btBroadphaseInterface* broadphase;
btDefaultCollisionConfiguration* collisionConfiguration;
btCollisionDispatcher* dispatcher;
btSequentialImpulseConstraintSolver* solver;
btDiscreteDynamicsWorld* dynamicsWorld;
public:
/**
* Enum used with the refresh function, to know what is needed to be
* recomputed
*/
typedef enum
{
NONE = 0, /**< no flags **/
LEVEL = 1 /**< recalculate object mesh levels **/
} universeRefreshFlags;
/**
* Construct with default Camera and the \ref mainLight as a
* carefully chosen position
*
* \todo Why this position for \ref Universe.mainLight?
*/
Universe();
const std::set<std::unique_ptr<Object>>& getObjects();
/**
* Add a new planet, with the given name, to the \ref objects
*
* \param name The name of the planet to create
*
* \return The previous size of \ref objects
*/
size_t addPlanet(const std::string& name);
/**
* Add a new planet, with the given name and position, to the
* \ref objects
*
* \param name The name of the planet to create
* \param pos The position of the planet to create
*
* \return The previous size of \ref objects
*/
size_t addPlanet(const std::string& name, btVector3 pos);
void addRigidBody(btRigidBody* rigidBody);
void removeRigidBody(btRigidBody* rigidBody);
void event(const std::unique_ptr<Event>& event);
/**
* Reset the perspective, draw the camera and the \ref objects
*
* \param flags The type of refresh to do
*/
void calculateLevel(const Camera& camera);
/**
* Handle physic inside the Universe, mainyl forwarded to
* \ref camera
*
* \param physicDelta Delta of physic to compute
*/
void physics(const double& dt);
/// Draw every Object of \ref objects
void draw() const;
~Universe();
};