forked from CelestiaProject/Celestia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devguide.txt
200 lines (158 loc) · 6.71 KB
/
devguide.txt
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
File Overview
-------------
* winmain.cpp
Windows front-end. There's a lot of initialization code that should be
moved to a module that's not platform-specific.
* simulation.cpp
The heart of Celestia . . . handles tracking an observer moving through
the universe.
* render.cpp
The Renderer class. Everything on the screen is put there by an instance
of Renderer.
* bigfix.cpp
High precision (128-bit) fixed point numbers.
* univcoord.cpp
UnivseralCoord class--a 3-vector with BigFix components. Represents
positions over a range of billions of light years to about
millimeter resolution.
* observer.cpp
This class is a package for position, orientation, and velocity. The
position of the observer is a UniversalCoord.
* octree.cpp
Octree is a class used to determine which stars from are visible to an
Observer
* stellarclass.cpp
* starname.cpp
* star.cpp
* stardb.cpp
Everything to do with stars. StarDatabase contains a list of Stars and a
list of StarNames.
* constellation.cpp
Just a bunch of static data giving the names and official abbreviations of
the 88 recognized constellations.
* orbit.cpp
The Orbit base class has a single method to compute the barycentric position
of an object at a given Julian Date. Currently, the only subclass of Orbit
is EllipticalOrbit, which calculates the position of an object along an
orbit specified by the standard six orbital elements.
* body.cpp
A planet, moon, probe, etc. Pretty much anything in space other than
a star is a Body. A PlanetarySystem is a list of bodies.
* solarsys.cpp
SolarSystem and SolarSystemCatalog classes.
* mesh.cpp
* spheremesh.cpp
* 3dsmesh.cpp
* vertexlist.cpp
These files are all related to internal geometry representation.
Mesh is an abstract class from which SphereMesh and Mesh3DS are derived.
VertexList is basically an easy to use wrapper for OpenGL 1.1 vertex arrays.
Eventually, VertexList will be made a subclass of mesh (SimpleMesh) and
Mesh3DS will be replaced by a more general class, CompositeMesh, which is
just a container for multiple Meshes.
* surface.h
An aggregation of surface properties that may be applied to a mesh.
* texture.cpp
An OpenGL texture class.
* tokenizer.cpp
* parser.cpp
The tokenizer and parser for Celestia text files (including the config file,
the solar system catalogs, and Celestia procedural meshes)
* resmanager.cpp
* texmanager.cpp
* meshmanager.cpp
Resource management. Resource manager is an abstract class from which
TextureManager and MeshManager are derived. Right now, there isn't much
in the way of actual management done, but having these classes around
makes it much easier to implement a more sophisticated texture manager
in the future.
* 3dschunk.h
* 3dsread.cpp
* 3dsmodel.cpp
3DS mesh reading stuff. Slurp a file and spits out a Mesh3DS.
* console.cpp
GL text console class that supports both printf and C++ << style output.
* perlin.cpp
Noise functions used for procedural geometry and textures.
* regcombine.cpp
A few functions that make it easy to use nVidia's REGISTER_COMBINERS
extension.
* color.cpp
Simple RGBA color class.
* astro.cpp
Astronomical conversions and a Date class for converting from dd/mm/yyyy
to Julian date.
* vecgl.h
A handful of template functions which make it easy to use types from
Eigen with OpenGL
* glext.h
* glext.cpp
GL extension declarations
* filetype.cpp
A function for determining the type of a file based on its extension.
* dispmap.cpp
Some silly code for applying displacement maps to SphereMeshes.
* texfont.cpp
Mark J. Kilgard's texture font package
* buildstardb.cpp
The program used to munge the HIPPARCOS data set into the star database.
If you wish to munge your own database, you will need to download a copy
of the HIPPARCOS database, it may be found at the URL:
ftp://cdsarc.u-strasbg.fr/cats/I/239
You will need the files hip_main.dat h_dm_com.dat hip_dm_o.da & tyc_main.dat
The Star Database
-----------------
The main star database is data/stars.dat. This contains about 112,000 stars,
including most of the HIPPARCOS catalog, plus one addition: Sol, our
sun. The file starnames.dat contains proper names and Bayer and Flamsteed
designations for about 1000 stars. Every star in stars.dat has a unique
identifier called its catalog number, and the name entries are linked with
stars from the database via this number.
The readStars function in celestiacore.cpp is responsible for loading the star
database for Celestia. Once initialized, the StarDatabase may be queried in
one of three ways: by star index, by catalog number, or by star name. The
star index is just the order of the star within the database, so lookup by
index is a constant time operation. Looking up a star by catalog number
requires a search of the star database; since the database entries are sorted
by catalog number, this is a log N operation. All three query types return
a pointer to a star from the database.
Stars
-----
Since there are so many stars in a star database, it's important that the
size of the Star class be kept to a minimum. Thus, in order to avoid the
4 byte vtable overhead Star is not a derived class, even though it might
be somewhat useful to have a common base class for stars and planets. All
stars have a unique catalog number, a position, a stellar class, and a
luminosity. The radius, temperature, and color of a star are not stored,
but are instead derived from stellar class and luminosity. The position
of a star is its cartesian ecliptical position in units of
light years. The catalog number of a star is generally it's HD number. In
cases where the star doesn't have an HD number, the lower 28 bits are the
HIPPARCOS catalog number and the high 4 bits are 0x1.
Celestia Overview
-----------------
The basic skeleton of Celestia looks like this:
StarDatabase* stardb = ReadStars("data/stars.dat", "data/starnames.dat");
SolarSystemCatalog* solarSystems = ReadSolarSystems("data/solarsys.ssc");
Simulation* sim = new Simulation();
sim->setStarDatabase(stardb);
sim->setTime(now);
Renderer renderer = new Renderer();
renderer->init();
for (;;)
{
sim->update(tick);
sim->render(*renderer);
}
The platform specific stuff to create a GL window and update it has been
omitted, as has any UI.
Tracking Visible Stars
----------------------
The VisibleStarSet class exists to limit the amount of computation spent
determining which stars from a StarDatabase are visible to an Observer. The
fairly simple trick used to help alleviate the problem involves only checking a
portion of the database for visibility at each update.
UNIX
----
To develop under Unix, you will probably need some of the following packages:
autoconf, automake, and of course the usual array of c++ compilers/linkers.