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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
/* Starshatter: The Open Source Project
Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
AUTHOR: John DiCamillo
OVERVIEW
========
Various heavenly bodies
*/
#ifndef StarSystem_h
#define StarSystem_h
#include <starshatter/definition.h>
#include "Types.h"
#include "Solid.h"
#include "Bitmap.h"
#include "Geometry.h"
#include "Text.h"
#include "List.h"
// +--------------------------------------------------------------------+
class StarSystem;
class Orbital;
class OrbitalBody;
class OrbitalRegion;
class TerrainRegion;
class Graphic;
class Light;
class Scene;
// +--------------------------------------------------------------------+
class StarSystem
{
public:
static const char* TYPENAME() { return "StarSystem"; }
StarSystem(const char* name, Point loc, int iff=0, int s=4);
virtual ~StarSystem();
int operator == (const StarSystem& s) const { return name == s.name; }
// operations:
virtual void Load();
virtual void Create();
virtual void Destroy();
virtual void Activate(Scene& scene);
virtual void Deactivate();
virtual void ExecFrame();
// accessors:
const char* Name() const { return name; }
const char* Govt() const { return govt; }
const char* Description() const { return description; }
int Affiliation() const { return affiliation; }
int Sequence() const { return seq; }
Point Location() const { return loc; }
int NumStars() const { return sky_stars; }
int NumDust() const { return sky_dust; }
Color Ambient() const;
List<OrbitalBody>& Bodies() { return bodies; }
List<OrbitalRegion>& Regions() { return regions; }
List<OrbitalRegion>& AllRegions() { return all_regions; }
OrbitalRegion* ActiveRegion() { return active_region; }
Orbital* FindOrbital(const char* name);
OrbitalRegion* FindRegion(const char* name);
void SetActiveRegion(OrbitalRegion* rgn);
static void SetBaseTime(long double t, bool absolute=false);
static long double GetBaseTime();
static long double Stardate() { return stardate; }
static void CalcStardate();
double Radius() const { return radius; }
void SetSunlight(Color color, double brightness=1);
void SetBacklight(Color color, double brightness=1);
void RestoreTrueSunColor();
bool HasLinkTo(StarSystem* s) const;
const Text& GetDataPath() const { return datapath; }
protected:
void ParseStar(TermStruct* val);
void ParsePlanet(TermStruct* val);
void ParseMoon(TermStruct* val);
void ParseRegion(TermStruct* val);
void ParseTerrain(TermStruct* val);
void ParseLayer(TerrainRegion* rgn, TermStruct* val);
void CreateBody(OrbitalBody& body);
Point TerrainTransform(const Point& loc);
char filename[64];
Text name;
Text govt;
Text description;
Text datapath;
int affiliation;
int seq;
Point loc;
static long double stardate;
double radius;
bool instantiated;
int sky_stars;
int sky_dust;
Text sky_poly_stars;
Text sky_nebula;
Text sky_haze;
double sky_uscale;
double sky_vscale;
Color ambient;
Color sun_color;
double sun_brightness;
double sun_scale;
List<Light> sun_lights;
List<Light> back_lights;
Graphic* point_stars;
Solid* poly_stars;
Solid* nebula;
Solid* haze;
List<OrbitalBody> bodies;
List<OrbitalRegion> regions;
List<OrbitalRegion> all_regions;
Orbital* center;
OrbitalRegion* active_region;
Point tvpn, tvup, tvrt;
};
// +--------------------------------------------------------------------+
class Star
{
public:
static const char* TYPENAME() { return "Star"; }
Star(const char* n, const Point& l, int s) : name(n), loc(l), seq(s) { }
virtual ~Star() { }
enum SPECTRAL_CLASS { BLACK_HOLE, WHITE_DWARF, RED_GIANT,
O, B, A, F, G, K, M };
int operator == (const Star& s) const { return name == s.name; }
// accessors:
const char* Name() const { return name; }
const Point& Location() const { return loc; }
int Sequence() const { return seq; }
Color GetColor() const;
int GetSize() const;
static Color GetColor(int spectral_class);
static int GetSize(int spectral_class);
protected:
Text name;
Point loc;
int seq;
};
// +--------------------------------------------------------------------+
class Orbital
{
friend class StarSystem;
public:
static const char* TYPENAME() { return "Orbital"; }
enum OrbitalType { NOTHING, STAR, PLANET, MOON, REGION, TERRAIN };
Orbital(StarSystem* sys, const char* n, OrbitalType t, double m, double r, double o, Orbital* p=0);
virtual ~Orbital();
int operator == (const Orbital& o) const { return type == o.type && name == o.name && system == o.system; }
int operator < (const Orbital& o) const { return loc.length() < o.loc.length(); }
int operator <= (const Orbital& o) const { return loc.length() <= o.loc.length(); }
// operations:
virtual void Update();
Point PredictLocation(double delta_t);
// accessors:
const char* Name() const { return name; }
OrbitalType Type() const { return type; }
int SubType() const { return subtype; }
const char* Description() const { return description; }
double Mass() const { return mass; }
double Radius() const { return radius; }
double Rotation() const { return rotation; }
double RotationPhase()const { return theta; }
double Orbit() const { return orbit; }
bool Retrograde() const { return retro; }
double Phase() const { return phase; }
double Period() const { return period; }
Point Location() const { return loc; }
Graphic* Rep() const { return rep; }
const Bitmap& GetMapIcon() const { return map_icon; }
void SetMapIcon(const Bitmap& img);
StarSystem* System() const { return system; }
Orbital* Primary() const { return primary; }
ListIter<OrbitalRegion> Regions() { return regions; }
protected:
Text name;
OrbitalType type;
int subtype;
Text description;
double mass;
double radius;
double rotation;
double theta;
double orbit;
double phase;
double period;
double velocity;
Point loc;
bool retro;
Graphic* rep;
Bitmap map_icon;
StarSystem* system;
Orbital* primary;
List<OrbitalRegion> regions;
};
// +--------------------------------------------------------------------+
class OrbitalBody : public Orbital
{
friend class StarSystem;
public:
static const char* TYPENAME() { return "OrbitalBody"; }
OrbitalBody(StarSystem* sys, const char* n, OrbitalType t, double m, double r, double o, Orbital* prime=0);
virtual ~OrbitalBody();
// operations:
virtual void Update();
// accessors:
ListIter<OrbitalBody> Satellites() { return satellites; }
double Tilt() const { return tilt; }
double RingMin() const { return ring_min; }
double RingMax() const { return ring_max; }
double LightIntensity() const { return light; }
Color LightColor() const { return color; }
bool Luminous() const { return luminous; }
protected:
Text map_name;
Text tex_name;
Text tex_high_res;
Text tex_ring;
Text tex_glow;
Text tex_glow_high_res;
Text tex_gloss;
double tscale;
double light;
double ring_min;
double ring_max;
double tilt;
Light* light_rep;
Light* back_light;
Color color;
Color back;
Color atmosphere;
bool luminous;
List<OrbitalBody> satellites;
};
// +--------------------------------------------------------------------+
class OrbitalRegion : public Orbital
{
friend class StarSystem;
public:
static const char* TYPENAME() { return "OrbitalRegion"; }
OrbitalRegion(StarSystem* sys, const char* n, double m, double r, double o, Orbital* prime=0);
virtual ~OrbitalRegion();
double GridSpace() const { return grid; }
double Inclination() const { return inclination; }
int Asteroids() const { return asteroids; }
List<Text>& Links() { return links; }
protected:
double grid;
double inclination;
int asteroids;
List<Text> links;
};
#endif // StarSystem_h
|