1
0
Fork 0
flightgear/Simulator/Astro/stars.cxx

265 lines
7.2 KiB
C++
Raw Normal View History

1998-09-24 15:36:19 +00:00
// stars.cxx -- data structures and routines for managing and rendering stars.
//
// Written by Curtis Olson, started August 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
//*************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
1998-04-03 21:50:53 +00:00
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include "Include/compiler.h"
#ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# include <cstdio>
# include <cstring>
# include <ctime>
#else
# include <math.h>
# include <stdio.h>
# include <string.h>
# include <time.h>
#endif
1998-11-23 21:48:09 +00:00
#include <string>
#include <GL/glut.h>
#include <XGL/xgl.h>
1998-10-16 23:26:44 +00:00
#include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx>
#include <Include/fg_constants.h>
1998-09-24 15:36:19 +00:00
#include <Misc/fgstream.hxx>
1998-05-13 18:25:34 +00:00
#include <Main/options.hxx>
1998-04-22 13:21:26 +00:00
#include <Main/views.hxx>
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
#include <Misc/stopwatch.hxx>
#include <Time/fg_time.hxx>
#include "Misc/stopwatch.hxx"
1998-04-22 13:21:26 +00:00
#include "stars.hxx"
FG_USING_STD(getline);
1998-04-22 13:21:26 +00:00
#define EpochStart (631065600)
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
#define FG_MAX_STARS 3500
1998-09-24 15:36:19 +00:00
// Define four structures, each with varying amounts of stars
static GLint stars[FG_STAR_LEVELS];
1998-09-24 15:36:19 +00:00
// Initialize the Star Management Subsystem
int fgStarsInit( void ) {
1998-10-16 00:51:46 +00:00
Point3D starlist[FG_MAX_STARS];
1998-09-24 15:36:19 +00:00
// struct CelestialCoord pltPos;
double right_ascension, declination, magnitude;
double min_magnitude[FG_STAR_LEVELS];
1998-09-24 15:36:19 +00:00
// double ra_save, decl_save;
// double ra_save1, decl_save1;
int i, j, starcount, count;
FG_LOG( FG_ASTRO, FG_INFO, "Initializing stars" );
if ( FG_STAR_LEVELS < 4 ) {
FG_LOG( FG_ASTRO, FG_ALERT, "Big whups in stars.cxx" );
exit(-1);
}
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
// build the full path name to the stars data base file
string path = current_options.get_fg_root() + "/Astro/stars" + ".gz";
FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path );
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
fg_gzifstream in( path );
if ( ! in ) {
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path );
exit(-1);
}
starcount = 0;
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
StopWatch timer;
timer.start();
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
// read in each line of the file
while ( ! in.eof() && starcount < FG_MAX_STARS )
{
in >> skipcomment;
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
string name;
getline( in, name, ',' );
in >> starlist[starcount];
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
++starcount;
}
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
timer.stop();
FG_LOG( FG_ASTRO, FG_INFO,
"Loaded " << starcount << " stars in "
<< timer.elapsedSeconds() << " seconds" );
Changes contributed by Bernie Bright <bbright@c031.aone.net.au> - The new classes in libmisc.tgz define a stream interface into zlib. I've put these in a new directory, Lib/Misc. Feel free to rename it to something more appropriate. However you'll have to change the include directives in all the other files. Additionally you'll have add the library to Lib/Makefile.am and Simulator/Main/Makefile.am. The StopWatch class in Lib/Misc requires a HAVE_GETRUSAGE autoconf test so I've included the required changes in config.tgz. There are a fair few changes to Simulator/Objects as I've moved things around. Loading tiles is quicker but thats not where the delay is. Tile loading takes a few tenths of a second per file on a P200 but it seems to be the post-processing that leads to a noticeable blip in framerate. I suppose its time to start profiling to see where the delays are. I've included a brief description of each archives contents. Lib/Misc/ zfstream.cxx zfstream.hxx C++ stream interface into zlib. Taken from zlib-1.1.3/contrib/iostream/. Minor mods for STL compatibility. There's no copyright associated with these so I assume they're covered by zlib's. fgstream.cxx fgstream.hxx FlightGear input stream using gz_ifstream. Tries to open the given filename. If that fails then filename is examined and a ".gz" suffix is removed or appended and that file is opened. stopwatch.hxx A simple timer for benchmarking. Not used in production code. Taken from the Blitz++ project. Covered by GPL. strutils.cxx strutils.hxx Some simple string manipulation routines. Simulator/Airports/ Load airports database using fgstream. Changed fgAIRPORTS to use set<> instead of map<>. Added bool fgAIRPORTS::search() as a neater way doing the lookup. Returns true if found. Simulator/Astro/ Modified fgStarsInit() to load stars database using fgstream. Simulator/Objects/ Modified fgObjLoad() to use fgstream. Modified fgMATERIAL_MGR::load_lib() to use fgstream. Many changes to fgMATERIAL. Some changes to fgFRAGMENT but I forget what!
1998-09-01 19:02:53 +00:00
min_magnitude[0] = 4.2;
min_magnitude[1] = 3.6;
min_magnitude[2] = 3.0;
min_magnitude[3] = 2.4;
min_magnitude[4] = 1.8;
min_magnitude[5] = 1.2;
min_magnitude[6] = 0.6;
min_magnitude[7] = 0.0;
// build the various star display lists
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
stars[i] = xglGenLists(1);
xglNewList( stars[i], GL_COMPILE );
xglBegin( GL_POINTS );
count = 0;
for ( j = 0; j < starcount; j++ ) {
1998-10-16 00:51:46 +00:00
magnitude = starlist[j].z();
// printf("magnitude = %.2f\n", magnitude);
if ( magnitude < min_magnitude[i] ) {
1998-10-16 00:51:46 +00:00
right_ascension = starlist[j].x();
declination = starlist[j].y();
count++;
1998-09-24 15:36:19 +00:00
// scale magnitudes to (0.0 - 1.0)
magnitude = (0.0 - magnitude) / 5.0 + 1.0;
1998-09-24 15:36:19 +00:00
// scale magnitudes again so they look ok
if ( magnitude > 1.0 ) { magnitude = 1.0; }
if ( magnitude < 0.0 ) { magnitude = 0.0; }
1998-09-24 15:36:19 +00:00
// magnitude =
// magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.042);
magnitude = magnitude * 0.9 +
(((FG_STAR_LEVELS - 1) - i) * 0.014);
1998-09-24 15:36:19 +00:00
// printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
// name, right_ascension, declination, magnitude);
xglColor3f( magnitude, magnitude, magnitude );
1998-09-24 15:36:19 +00:00
//xglColor3f(0,0,0);*/
xglVertex3f( 50000.0*cos(right_ascension)*cos(declination),
50000.0*sin(right_ascension)*cos(declination),
50000.0*sin(declination) );
}
1998-09-24 15:36:19 +00:00
} // while
xglEnd();
/*
xglBegin(GL_LINE_LOOP);
xglColor3f(1.0, 0.0, 0.0);
xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
50000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
50000.0 * sin(decl_save-0.2) );
xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
50000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
50000.0 * sin(decl_save-0.2) );
xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
50000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
50000.0 * sin(decl_save+0.2) );
xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save+0.2),
50000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
50000.0 * sin(decl_save+0.2) );
xglEnd();
*/
/*
xglBegin(GL_LINE_LOOP);
xglColor3f(0.0, 1.0, 0.0);
xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
50000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
50000.0 * sin(decl_save1-0.2) );
xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
50000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
50000.0 * sin(decl_save1-0.2) );
xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
50000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
50000.0 * sin(decl_save1+0.2) );
xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
50000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
50000.0 * sin(decl_save1+0.2) );
xglEnd();
*/
xglEndList();
FG_LOG( FG_ASTRO, FG_INFO,
" Loading " << count << " stars brighter than "
<< min_magnitude[i] );
}
return 1; // OK, we got here because initialization worked.
}
1998-09-24 15:36:19 +00:00
// Draw the Stars
void fgStarsRender( void ) {
FGInterface *f;
fgLIGHT *l;
FGTime *t;
int i;
f = current_aircraft.fdm_state;
l = &cur_light_params;
t = FGTime::cur_time_params;
1998-09-24 15:36:19 +00:00
// FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise
1998-09-24 15:36:19 +00:00
// t->sun_angle = 3.0; // to force stars to be drawn (for testing)
1998-09-24 15:36:19 +00:00
// render the stars
if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
1998-09-24 15:36:19 +00:00
// determine which star structure to draw
if ( l->sun_angle > (FG_PI_2 + 10.0 * DEG_TO_RAD ) ) {
i = 0;
} else if ( l->sun_angle > (FG_PI_2 + 8.8 * DEG_TO_RAD ) ) {
i = 1;
} else if ( l->sun_angle > (FG_PI_2 + 7.5 * DEG_TO_RAD ) ) {
i = 2;
} else if ( l->sun_angle > (FG_PI_2 + 7.0 * DEG_TO_RAD ) ) {
i = 3;
} else if ( l->sun_angle > (FG_PI_2 + 6.5 * DEG_TO_RAD ) ) {
i = 4;
} else if ( l->sun_angle > (FG_PI_2 + 6.0 * DEG_TO_RAD ) ) {
i = 5;
} else if ( l->sun_angle > (FG_PI_2 + 5.5 * DEG_TO_RAD ) ) {
i = 6;
} else {
i = 7;
}
1998-09-24 15:36:19 +00:00
// printf("RENDERING STARS = %d (night)\n", i);
xglCallList(stars[i]);
} else {
1998-09-24 15:36:19 +00:00
// printf("not RENDERING STARS (day)\n");
}
}