Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
StarSystem.h
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: StarSystem.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Various heavenly bodies
13
*/
14
15
#ifndef StarSystem_h
16
#define StarSystem_h
17
18
#include "
Types.h
"
19
#include "
Solid.h
"
20
#include "
Bitmap.h
"
21
#include "
Geometry.h
"
22
#include "
Text.h
"
23
#include "
term.h
"
24
#include "
List.h
"
25
26
// +--------------------------------------------------------------------+
27
28
class
StarSystem
;
29
class
Orbital
;
30
class
OrbitalBody
;
31
class
OrbitalRegion
;
32
class
TerrainRegion
;
33
34
class
Graphic
;
35
class
Light
;
36
class
Scene
;
37
38
// +--------------------------------------------------------------------+
39
40
class
StarSystem
41
{
42
public
:
43
static
const
char
*
TYPENAME
() {
return
"StarSystem"
; }
44
45
StarSystem
(
const
char
*
name
,
Point
loc
,
int
iff=0,
int
s=4);
46
virtual
~StarSystem
();
47
48
int
operator ==
(
const
StarSystem
& s)
const
{
return
name
== s.
name
; }
49
50
// operations:
51
virtual
void
Load
();
52
virtual
void
Create
();
53
virtual
void
Destroy
();
54
55
virtual
void
Activate
(
Scene
& scene);
56
virtual
void
Deactivate
();
57
58
virtual
void
ExecFrame
();
59
60
// accessors:
61
const
char
*
Name
()
const
{
return
name
; }
62
const
char
*
Govt
()
const
{
return
govt
; }
63
const
char
*
Description
()
const
{
return
description
; }
64
int
Affiliation
()
const
{
return
affiliation
; }
65
int
Sequence
()
const
{
return
seq
; }
66
Point
Location
()
const
{
return
loc
; }
67
int
NumStars
()
const
{
return
sky_stars
; }
68
int
NumDust
()
const
{
return
sky_dust
; }
69
Color
Ambient
()
const
;
70
71
List<OrbitalBody>
&
Bodies
() {
return
bodies
; }
72
List<OrbitalRegion>
&
Regions
() {
return
regions
; }
73
List<OrbitalRegion>
&
AllRegions
() {
return
all_regions
; }
74
OrbitalRegion
*
ActiveRegion
() {
return
active_region
; }
75
76
Orbital
*
FindOrbital
(
const
char
*
name
);
77
OrbitalRegion
*
FindRegion
(
const
char
*
name
);
78
79
void
SetActiveRegion
(
OrbitalRegion
* rgn);
80
81
static
void
SetBaseTime
(
double
t,
bool
absolute=
false
);
82
static
double
GetBaseTime
();
83
static
double
Stardate
() {
return
stardate
; }
84
static
void
CalcStardate
();
85
double
Radius
()
const
{
return
radius
; }
86
87
void
SetSunlight
(
Color
color,
double
brightness=1);
88
void
SetBacklight
(
Color
color,
double
brightness=1);
89
void
RestoreTrueSunColor
();
90
bool
HasLinkTo
(
StarSystem
* s)
const
;
91
const
Text
&
GetDataPath
()
const
{
return
datapath
; }
92
93
protected
:
94
void
ParseStar
(
TermStruct
* val);
95
void
ParsePlanet
(
TermStruct
* val);
96
void
ParseMoon
(
TermStruct
* val);
97
void
ParseRegion
(
TermStruct
* val);
98
void
ParseTerrain
(
TermStruct
* val);
99
void
ParseLayer
(
TerrainRegion
* rgn,
TermStruct
* val);
100
101
void
CreateBody
(
OrbitalBody
& body);
102
Point
TerrainTransform
(
const
Point
&
loc
);
103
104
char
filename
[64];
105
Text
name
;
106
Text
govt
;
107
Text
description
;
108
Text
datapath
;
109
int
affiliation
;
110
int
seq
;
111
Point
loc
;
112
static
double
stardate
;
113
double
radius
;
114
bool
instantiated
;
115
116
int
sky_stars
;
117
int
sky_dust
;
118
Text
sky_poly_stars
;
119
Text
sky_nebula
;
120
Text
sky_haze
;
121
double
sky_uscale
;
122
double
sky_vscale
;
123
Color
ambient
;
124
Color
sun_color
;
125
double
sun_brightness
;
126
double
sun_scale
;
127
List<Light>
sun_lights
;
128
List<Light>
back_lights
;
129
130
Graphic
*
point_stars
;
131
Solid
*
poly_stars
;
132
Solid
*
nebula
;
133
Solid
*
haze
;
134
135
List<OrbitalBody>
bodies
;
136
List<OrbitalRegion>
regions
;
137
List<OrbitalRegion>
all_regions
;
138
139
Orbital
*
center
;
140
OrbitalRegion
*
active_region
;
141
142
Point
tvpn
,
tvup
,
tvrt
;
143
};
144
145
// +--------------------------------------------------------------------+
146
147
class
Star
148
{
149
public
:
150
static
const
char
*
TYPENAME
() {
return
"Star"
; }
151
152
Star
(
const
char
* n,
const
Point
& l,
int
s) :
name
(n),
loc
(l),
seq
(s) { }
153
virtual
~Star
() { }
154
155
enum
SPECTRAL_CLASS
{
BLACK_HOLE
,
WHITE_DWARF
,
RED_GIANT
,
156
O
,
B
,
A
,
F
,
G
,
K
,
M
};
157
158
int
operator ==
(
const
Star
& s)
const
{
return
name
== s.
name
; }
159
160
// accessors:
161
const
char
*
Name
()
const
{
return
name
; }
162
const
Point
&
Location
()
const
{
return
loc
; }
163
int
Sequence
()
const
{
return
seq
; }
164
Color
GetColor
()
const
;
165
int
GetSize
()
const
;
166
167
static
Color
GetColor
(
int
spectral_class);
168
static
int
GetSize
(
int
spectral_class);
169
170
protected
:
171
Text
name
;
172
Point
loc
;
173
int
seq
;
174
};
175
176
// +--------------------------------------------------------------------+
177
178
class
Orbital
179
{
180
friend
class
StarSystem
;
181
182
public
:
183
static
const
char
*
TYPENAME
() {
return
"Orbital"
; }
184
185
enum
OrbitalType
{
NOTHING
,
STAR
,
PLANET
,
MOON
,
REGION
,
TERRAIN
};
186
187
Orbital
(
StarSystem
* sys,
const
char
* n,
OrbitalType
t,
double
m,
double
r,
double
o,
Orbital
* p=0);
188
virtual
~Orbital
();
189
190
int
operator ==
(
const
Orbital
& o)
const
{
return
type
== o.
type
&&
name
== o.
name
&&
system
== o.
system
; }
191
int
operator <
(
const
Orbital
& o)
const
{
return
loc
.
length
() < o.
loc
.
length
(); }
192
int
operator <=
(
const
Orbital
& o)
const
{
return
loc
.
length
() <= o.
loc
.
length
(); }
193
194
// operations:
195
virtual
void
Update
();
196
Point
PredictLocation
(
double
delta_t);
197
198
// accessors:
199
const
char
*
Name
()
const
{
return
name
; }
200
OrbitalType
Type
()
const
{
return
type
; }
201
int
SubType
()
const
{
return
subtype
; }
202
203
const
char
*
Description
()
const
{
return
description
; }
204
double
Mass
()
const
{
return
mass
; }
205
double
Radius
()
const
{
return
radius
; }
206
double
Rotation
()
const
{
return
rotation
; }
207
double
RotationPhase
()
const
{
return
theta
; }
208
double
Orbit
()
const
{
return
orbit
; }
209
bool
Retrograde
()
const
{
return
retro
; }
210
double
Phase
()
const
{
return
phase
; }
211
double
Period
()
const
{
return
period
; }
212
Point
Location
()
const
{
return
loc
; }
213
Graphic
*
Rep
()
const
{
return
rep
; }
214
215
const
Bitmap
&
GetMapIcon
()
const
{
return
map_icon
; }
216
void
SetMapIcon
(
const
Bitmap
& img);
217
218
StarSystem
*
System
()
const
{
return
system
; }
219
Orbital
*
Primary
()
const
{
return
primary
; }
220
ListIter<OrbitalRegion>
Regions
() {
return
regions
; }
221
222
protected
:
223
Text
name
;
224
OrbitalType
type
;
225
int
subtype
;
226
227
Text
description
;
228
double
mass
;
229
double
radius
;
230
double
rotation
;
231
double
theta
;
232
double
orbit
;
233
double
phase
;
234
double
period
;
235
double
velocity
;
236
Point
loc
;
237
bool
retro
;
238
Graphic
*
rep
;
239
Bitmap
map_icon
;
240
241
StarSystem
*
system
;
242
Orbital
*
primary
;
243
244
List<OrbitalRegion>
regions
;
245
};
246
247
// +--------------------------------------------------------------------+
248
249
class
OrbitalBody
:
public
Orbital
250
{
251
friend
class
StarSystem
;
252
253
public
:
254
static
const
char
*
TYPENAME
() {
return
"OrbitalBody"
; }
255
256
OrbitalBody
(
StarSystem
* sys,
const
char
* n,
OrbitalType
t,
double
m,
double
r,
double
o,
Orbital
* prime=0);
257
virtual
~OrbitalBody
();
258
259
// operations:
260
virtual
void
Update
();
261
262
// accessors:
263
ListIter<OrbitalBody>
Satellites
() {
return
satellites
; }
264
265
double
Tilt
()
const
{
return
tilt
; }
266
double
RingMin
()
const
{
return
ring_min
; }
267
double
RingMax
()
const
{
return
ring_max
; }
268
269
double
LightIntensity
()
const
{
return
light
; }
270
Color
LightColor
()
const
{
return
color
; }
271
bool
Luminous
()
const
{
return
luminous
; }
272
273
protected
:
274
Text
map_name
;
275
Text
tex_name
;
276
Text
tex_high_res
;
277
Text
tex_ring
;
278
Text
tex_glow
;
279
Text
tex_glow_high_res
;
280
Text
tex_gloss
;
281
282
double
tscale
;
283
double
light
;
284
double
ring_min
;
285
double
ring_max
;
286
double
tilt
;
287
Light
*
light_rep
;
288
Light
*
back_light
;
289
Color
color
;
290
Color
back
;
291
Color
atmosphere
;
292
bool
luminous
;
293
294
List<OrbitalBody>
satellites
;
295
};
296
297
// +--------------------------------------------------------------------+
298
299
class
OrbitalRegion
:
public
Orbital
300
{
301
friend
class
StarSystem
;
302
303
public
:
304
static
const
char
*
TYPENAME
() {
return
"OrbitalRegion"
; }
305
306
OrbitalRegion
(
StarSystem
* sys,
const
char
* n,
double
m,
double
r,
double
o,
Orbital
* prime=0);
307
virtual
~OrbitalRegion
();
308
309
double
GridSpace
()
const
{
return
grid
; }
310
double
Inclination
()
const
{
return
inclination
; }
311
int
Asteroids
()
const
{
return
asteroids
; }
312
List<Text>
&
Links
() {
return
links
; }
313
314
protected
:
315
double
grid
;
316
double
inclination
;
317
int
asteroids
;
318
List<Text>
links
;
319
};
320
321
#endif StarSystem_h
322
Stars45
StarSystem.h
Generated on Tue Jun 5 2012 20:47:13 for Starshatter_Open by
1.8.1