-
Notifications
You must be signed in to change notification settings - Fork 0
/
body.h
92 lines (76 loc) · 2.59 KB
/
body.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
#ifndef BODY_H
#define BODY_H
#include "renderable/sphere.h"
#include "renderable/ring.h"
#include "renderable/orbit.h"
#include "renderable/axis.h"
#include "renderable/pointobject.h"
#include "renderable/textbillboard.h"
#include "renderable/flare.h"
#include <QString>
#include <QList>
namespace RenderMode {
enum Mode { Opaque, Translucent, Picking, LightSource };
}
struct Rotation {
double period;
double axialTilt;
// double meridianAngle;
};
class Body: public QObject, protected QOpenGLFunctions
{
public:
Body(const QString &name, QObject *parent = 0);
~Body();
void setTime(double time/*seconds past epoch*/);
Eigen::Affine3d referenceFrame() const {return m_referenceFrame;}
void setReferenceFrame(const Eigen::Affine3d &frame) {m_referenceFrame = frame;}
void render(const Eigen::Affine3d &view, const Eigen::Affine3d &projection, RenderMode::Mode mode);
int objectId() const {return m_objectId;}
QString name() const {return m_name;}
float radius() const {return m_radius;}
float boundingRadius() const {return m_boundingRadius;}
Body* root() const {return m_root;}
QList<Body*> satellites() const {return m_satellites;}
Eigen::Vector3d center() const {return m_referenceFrame*Eigen::Vector3d::Zero();}
void setOnScreenRadius(int radius) {m_onScreenRadius = radius;}
void setOnScreenDistanceToParent(int distance) {m_onScreenDistanceToParent = distance;}
static bool showAxis() {return ShowAxis;}
static void setShowAxis(bool showAxis) {ShowAxis = showAxis;}
static bool showOrbit() {return ShowOrbit;}
static void setShowOrbit(bool showOrbit) {ShowOrbit = showOrbit;}
static void setPointSizeThreshold(float pointSizeThreshold) {
PointSizeThreshold = pointSizeThreshold;
PointObject::setPointSize(PointSizeThreshold);
}
protected:
GLuint loadTexture(const QString &image);
static int ObjectID;
static bool ShowAxis;
static bool ShowOrbit;
static float PointSizeThreshold;
QString m_name;
int m_objectId;
float m_radius;
float m_boundingRadius;
bool m_isLightSource;
Sphere *m_sphere;
Ring *m_ring;
Orbit *m_orbit;
Axis *m_axis;
PointObject *m_pointObject;
int m_onScreenRadius;
int m_onScreenDistanceToParent;
TextBillboard *m_text;
Flare *m_flare;
Rotation m_rotation;
Body *m_root;
QList<Body*> m_satellites;
GLuint m_texture;
GLuint m_nightTexture;
GLuint m_ringTexture;
Eigen::Affine3d m_referenceFrame;
Eigen::Affine3d m_orbitFrame;
Eigen::Affine3d m_laplaceFrame;
};
#endif // BODY_H