-
Notifications
You must be signed in to change notification settings - Fork 0
/
-
85 lines (65 loc) · 1.36 KB
/
-
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
#ifndef UPDATE_H
#define UPDATE_H
#include <iostream>
#include <vector>
#include <GL/gl.h>
#include "../include/matrix.h"
namespace gravwars {
const double PI = 3.14159;
typedef Vector3 Vertex3;
class Entity {
public:
Vertex3 pos;
int glIndex;
};
class DirectedEntity : public Entity {
public:
Vector3 forwards;
Vector3 up;
Vector3 right; //negative x
void rotate( double theta, const Vector3& axis );
};
class Planet : public Entity {
public:
double radius;
double mass;
float r, g, b;
};
class Ship : public DirectedEntity {
private:
Vector3 rotSensitivity;
Vector accel, vel;
Vector3 rotateRate; // corresponds to pitch, yaw, and roll in that order
public:
Ship();
double mass;
void thrustOn();
void thrustOff();
void upOn();
void upOff();
void downOn();
void downOff();
void leftOn();
void leftOff();
void rightOn();
void rightOff();
void moveTime( double dtime );
};
// singleton class
class Space {
private:
static int glIndexCounter;
public:
static vector<Ship> ships;
static vector<Planet> planets;
static Vector3 max; //bounding planes of space
static Vector3 min;
static int nextIndex();
static void addPlanet( double x, double y, double z,
double radius, double mass,
float r, float g, float b );
static void init();
static void destroy();
};
} // namespace
#endif