Initial revision
This commit is contained in:
parent
ca444b07bd
commit
29e3a4e231
545
Astro/stars.cxx
545
Astro/stars.cxx
@ -1,545 +0,0 @@
|
||||
// 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$
|
||||
// (Log is kept at end of this file)
|
||||
//*************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <XGL/xgl.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Misc/fgstream.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Misc/stopwatch.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "Misc/stopwatch.hxx"
|
||||
|
||||
#include "stars.hxx"
|
||||
|
||||
FG_USING_STD(getline);
|
||||
|
||||
#define EpochStart (631065600)
|
||||
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
|
||||
#define FG_MAX_STARS 3500
|
||||
|
||||
// Define four structures, each with varying amounts of stars
|
||||
static GLint stars[FG_STAR_LEVELS];
|
||||
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void ) {
|
||||
Point3D starlist[FG_MAX_STARS];
|
||||
// struct CelestialCoord pltPos;
|
||||
double right_ascension, declination, magnitude;
|
||||
double min_magnitude[FG_STAR_LEVELS];
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
||||
fg_gzifstream in( path );
|
||||
if ( ! in ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
starcount = 0;
|
||||
|
||||
StopWatch timer;
|
||||
timer.start();
|
||||
|
||||
// read in each line of the file
|
||||
while ( ! in.eof() && starcount < FG_MAX_STARS )
|
||||
{
|
||||
in >> skipcomment;
|
||||
string name;
|
||||
getline( in, name, ',' );
|
||||
in >> starlist[starcount];
|
||||
++starcount;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
"Loaded " << starcount << " stars in "
|
||||
<< timer.elapsedSeconds() << " seconds" );
|
||||
|
||||
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++ ) {
|
||||
magnitude = starlist[j].z();
|
||||
// printf("magnitude = %.2f\n", magnitude);
|
||||
|
||||
if ( magnitude < min_magnitude[i] ) {
|
||||
right_ascension = starlist[j].x();
|
||||
declination = starlist[j].y();
|
||||
|
||||
count++;
|
||||
|
||||
// scale magnitudes to (0.0 - 1.0)
|
||||
magnitude = (0.0 - magnitude) / 5.0 + 1.0;
|
||||
|
||||
// scale magnitudes again so they look ok
|
||||
if ( magnitude > 1.0 ) { magnitude = 1.0; }
|
||||
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
||||
// magnitude =
|
||||
// magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.042);
|
||||
|
||||
magnitude = magnitude * 0.9 +
|
||||
(((FG_STAR_LEVELS - 1) - i) * 0.014);
|
||||
// printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
|
||||
// name, right_ascension, declination, magnitude);
|
||||
|
||||
xglColor3f( magnitude, magnitude, magnitude );
|
||||
//xglColor3f(0,0,0);*/
|
||||
xglVertex3f( 50000.0*cos(right_ascension)*cos(declination),
|
||||
50000.0*sin(right_ascension)*cos(declination),
|
||||
50000.0*sin(declination) );
|
||||
}
|
||||
} // 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.
|
||||
}
|
||||
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void ) {
|
||||
FGInterface *f;
|
||||
fgLIGHT *l;
|
||||
fgTIME *t;
|
||||
int i;
|
||||
|
||||
f = current_aircraft.fdm_state;
|
||||
l = &cur_light_params;
|
||||
t = &cur_time_params;
|
||||
|
||||
// FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise
|
||||
|
||||
// t->sun_angle = 3.0; // to force stars to be drawn (for testing)
|
||||
|
||||
// render the stars
|
||||
if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
// printf("RENDERING STARS = %d (night)\n", i);
|
||||
|
||||
xglCallList(stars[i]);
|
||||
} else {
|
||||
// printf("not RENDERING STARS (day)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.27 1999/02/05 21:28:52 curt
|
||||
// Modifications to incorporate Jon S. Berndts flight model code.
|
||||
//
|
||||
// Revision 1.26 1999/02/02 20:13:30 curt
|
||||
// MSVC++ portability changes by Bernie Bright:
|
||||
//
|
||||
// Lib/Serial/serial.[ch]xx: Initial Windows support - incomplete.
|
||||
// Simulator/Astro/stars.cxx: typo? included <stdio> instead of <cstdio>
|
||||
// Simulator/Cockpit/hud.cxx: Added Standard headers
|
||||
// Simulator/Cockpit/panel.cxx: Redefinition of default parameter
|
||||
// Simulator/Flight/flight.cxx: Replaced cout with FG_LOG. Deleted <stdio.h>
|
||||
// Simulator/Main/fg_init.cxx:
|
||||
// Simulator/Main/GLUTmain.cxx:
|
||||
// Simulator/Main/options.hxx: Shuffled <fg_serial.hxx> dependency
|
||||
// Simulator/Objects/material.hxx:
|
||||
// Simulator/Time/timestamp.hxx: VC++ friend kludge
|
||||
// Simulator/Scenery/tile.[ch]xx: Fixed using std::X declarations
|
||||
// Simulator/Main/views.hxx: Added a constant
|
||||
//
|
||||
// Revision 1.25 1998/12/09 18:50:15 curt
|
||||
// Converted "class fgVIEW" to "class FGView" and updated to make data
|
||||
// members private and make required accessor functions.
|
||||
//
|
||||
// Revision 1.24 1998/12/05 15:54:04 curt
|
||||
// Renamed class fgFLIGHT to class FGState as per request by JSB.
|
||||
//
|
||||
// Revision 1.23 1998/11/23 21:48:28 curt
|
||||
// Borland portability tweaks.
|
||||
//
|
||||
// Revision 1.22 1998/11/07 19:07:07 curt
|
||||
// Enable release builds using the --without-logging option to the configure
|
||||
// script. Also a couple log message cleanups, plus some C to C++ comment
|
||||
// conversion.
|
||||
//
|
||||
// Revision 1.21 1998/11/06 21:17:42 curt
|
||||
// Converted to new logstream debugging facility. This allows release
|
||||
// builds with no messages at all (and no performance impact) by using
|
||||
// the -DFG_NDEBUG flag.
|
||||
//
|
||||
// Revision 1.20 1998/11/06 14:47:02 curt
|
||||
// Changes to track Bernie's updates to fgstream.
|
||||
//
|
||||
// Revision 1.19 1998/10/16 23:27:21 curt
|
||||
// C++-ifying.
|
||||
//
|
||||
// Revision 1.18 1998/10/16 00:52:20 curt
|
||||
// Converted to Point3D class.
|
||||
//
|
||||
// Revision 1.17 1998/09/24 15:36:19 curt
|
||||
// Converted to c++ style comments.
|
||||
//
|
||||
// Revision 1.16 1998/09/24 15:25:24 curt
|
||||
// Miscellaneous tweaks.
|
||||
//
|
||||
//
|
||||
// Revision 1.15 1998/09/17 18:25:12 curt
|
||||
// Fixed output message.
|
||||
//
|
||||
// Revision 1.14 1998/09/15 04:26:22 curt
|
||||
// New textured moon and rewritten/restructured Astro code contributed by Durk
|
||||
// Talsma.
|
||||
//
|
||||
// Revision 1.13 1998/09/01 19:03:04 curt
|
||||
// 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!
|
||||
//
|
||||
// Revision 1.12 1998/08/27 17:02:01 curt
|
||||
// Contributions from Bernie Bright <bbright@c031.aone.net.au>
|
||||
// - use strings for fg_root and airport_id and added methods to return
|
||||
// them as strings,
|
||||
// - inlined all access methods,
|
||||
// - made the parsing functions private methods,
|
||||
// - deleted some unused functions.
|
||||
// - propogated some of these changes out a bit further.
|
||||
//
|
||||
// Revision 1.11 1998/08/25 20:53:29 curt
|
||||
// Shuffled $FG_ROOT file layout.
|
||||
//
|
||||
// Revision 1.10 1998/08/10 20:33:09 curt
|
||||
// Rewrote star loading and rendering to:
|
||||
// 1. significantly improve load speed
|
||||
// 2. transition from no stars to stars through eight stages.
|
||||
//
|
||||
// Revision 1.9 1998/08/06 12:45:20 curt
|
||||
// Modified to bring in stars in 8 increments based on magnitude, not number
|
||||
// of stars.
|
||||
//
|
||||
// Revision 1.8 1998/07/13 21:00:10 curt
|
||||
// Wrote access functions for current fgOPTIONS.
|
||||
//
|
||||
// Revision 1.7 1998/05/29 20:35:42 curt
|
||||
// Added zlib support for reading in compressed data files.
|
||||
//
|
||||
// Revision 1.6 1998/05/13 18:25:35 curt
|
||||
// Root path info moved to fgOPTIONS.
|
||||
//
|
||||
// Revision 1.5 1998/04/28 01:19:03 curt
|
||||
// Type-ified fgTIME and fgVIEW
|
||||
//
|
||||
// Revision 1.4 1998/04/26 05:10:02 curt
|
||||
// "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
|
||||
//
|
||||
// Revision 1.3 1998/04/25 22:06:26 curt
|
||||
// Edited cvs log messages in source files ... bad bad bad!
|
||||
//
|
||||
// Revision 1.2 1998/04/24 00:45:03 curt
|
||||
// Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
|
||||
// Fixed a bug when generating sky colors.
|
||||
//
|
||||
// Revision 1.1 1998/04/22 13:21:34 curt
|
||||
// C++ - ifing the code a bit.
|
||||
//
|
||||
// Revision 1.11 1998/04/18 04:13:58 curt
|
||||
// Moved fg_debug.c to it's own library.
|
||||
//
|
||||
// Revision 1.10 1998/04/03 21:52:51 curt
|
||||
// Converting to Gnu autoconf system.
|
||||
//
|
||||
// Revision 1.9 1998/03/14 00:27:12 curt
|
||||
// Updated fgGENERAL to a "type" of struct.
|
||||
//
|
||||
// Revision 1.8 1998/02/12 21:59:38 curt
|
||||
// Incorporated code changes contributed by Charlie Hotchkiss
|
||||
// <chotchkiss@namg.us.anritsu.com>
|
||||
//
|
||||
// Revision 1.7 1998/02/09 15:07:48 curt
|
||||
// Minor tweaks.
|
||||
//
|
||||
// Revision 1.6 1998/02/02 20:53:23 curt
|
||||
// To version 0.29
|
||||
//
|
||||
// Revision 1.5 1998/01/27 18:35:53 curt
|
||||
// Minor tweaks.
|
||||
//
|
||||
// Revision 1.4 1998/01/27 00:47:49 curt
|
||||
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||
// system and commandline/config file processing code.
|
||||
//
|
||||
// Revision 1.3 1998/01/19 19:26:59 curt
|
||||
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||
// This should simplify things tremendously.
|
||||
//
|
||||
// Revision 1.2 1998/01/19 18:40:18 curt
|
||||
// Tons of little changes to clean up the code and to remove fatal errors
|
||||
// when building with the c++ compiler.
|
||||
//
|
||||
// Revision 1.1 1998/01/07 03:16:20 curt
|
||||
// Moved from .../Src/Scenery/ to .../Src/Astro/
|
||||
//
|
||||
// Revision 1.24 1997/12/30 22:22:39 curt
|
||||
// Further integration of event manager.
|
||||
//
|
||||
// Revision 1.23 1997/12/30 20:47:53 curt
|
||||
// Integrated new event manager with subsystem initializations.
|
||||
//
|
||||
// Revision 1.22 1997/12/30 16:36:53 curt
|
||||
// Merged in Durk's changes ...
|
||||
//
|
||||
// Revision 1.21 1997/12/19 23:35:00 curt
|
||||
// Lot's of tweaking with sky rendering and lighting.
|
||||
//
|
||||
// Revision 1.20 1997/12/15 23:55:03 curt
|
||||
// Add xgl wrappers for debugging.
|
||||
// Generate terrain normals on the fly.
|
||||
//
|
||||
// Revision 1.19 1997/12/12 19:53:00 curt
|
||||
// Working on lightling and material properties.
|
||||
//
|
||||
// Revision 1.18 1997/12/10 22:37:52 curt
|
||||
// Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||
// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||
//
|
||||
// Revision 1.17 1997/12/09 04:25:33 curt
|
||||
// Working on adding a global lighting params structure.
|
||||
//
|
||||
// Revision 1.16 1997/11/25 19:25:38 curt
|
||||
// Changes to integrate Durk's moon/sun code updates + clean up.
|
||||
//
|
||||
// Revision 1.15 1997/10/30 12:38:45 curt
|
||||
// Working on new scenery subsystem.
|
||||
//
|
||||
// Revision 1.14 1997/10/28 21:00:22 curt
|
||||
// Changing to new terrain format.
|
||||
//
|
||||
// Revision 1.13 1997/10/25 03:18:28 curt
|
||||
// Incorporated sun, moon, and planet position and rendering code contributed
|
||||
// by Durk Talsma.
|
||||
//
|
||||
// Revision 1.12 1997/09/23 00:29:43 curt
|
||||
// Tweaks to get things to compile with gcc-win32.
|
||||
//
|
||||
// Revision 1.11 1997/09/22 14:44:21 curt
|
||||
// Continuing to try to align stars correctly.
|
||||
//
|
||||
// Revision 1.10 1997/09/20 03:34:32 curt
|
||||
// Still trying to get those durned stars aligned properly.
|
||||
//
|
||||
// Revision 1.9 1997/09/18 16:20:09 curt
|
||||
// At dusk/dawn add/remove stars in stages.
|
||||
//
|
||||
// Revision 1.8 1997/09/16 22:14:52 curt
|
||||
// Tweaked time of day lighting equations. Don't draw stars during the day.
|
||||
//
|
||||
// Revision 1.7 1997/09/16 15:50:31 curt
|
||||
// Working on star alignment and time issues.
|
||||
//
|
||||
// Revision 1.6 1997/09/05 14:17:31 curt
|
||||
// More tweaking with stars.
|
||||
//
|
||||
// Revision 1.5 1997/09/05 01:35:59 curt
|
||||
// Working on getting stars right.
|
||||
//
|
||||
// Revision 1.4 1997/09/04 02:17:38 curt
|
||||
// Shufflin' stuff.
|
||||
//
|
||||
// Revision 1.3 1997/08/29 17:55:28 curt
|
||||
// Worked on properly aligning the stars.
|
||||
//
|
||||
// Revision 1.2 1997/08/27 21:32:30 curt
|
||||
// Restructured view calculation code. Added stars.
|
||||
//
|
||||
// Revision 1.1 1997/08/27 03:34:48 curt
|
||||
// Initial revision.
|
||||
|
||||
|
114
Astro/stars.hxx
114
Astro/stars.hxx
@ -1,114 +0,0 @@
|
||||
// stars.hxx -- 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$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifndef _STARS_HXX
|
||||
#define _STARS_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#define FG_STAR_LEVELS 8 // how many star transitions
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void );
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void );
|
||||
|
||||
// [no longer used?] extern struct OrbElements pltOrbElements[9];
|
||||
extern fgTIME cur_time_params;
|
||||
|
||||
|
||||
#endif // _STARS_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.8 1999/01/19 20:57:00 curt
|
||||
// MacOS portability changes contributed by "Robert Puyol" <puyol@abvent.fr>
|
||||
//
|
||||
// Revision 1.7 1998/09/24 15:36:20 curt
|
||||
// Converted to c++ style comments.
|
||||
//
|
||||
// Revision 1.6 1998/09/24 15:25:26 curt
|
||||
// Miscellaneous tweaks.
|
||||
//
|
||||
//
|
||||
// Revision 1.5 1998/09/17 18:25:13 curt
|
||||
// Fixed output message.
|
||||
//
|
||||
// Revision 1.4 1998/09/15 04:26:23 curt
|
||||
// New textured moon and rewritten/restructured Astro code contributed by Durk
|
||||
// Talsma.
|
||||
//
|
||||
// Revision 1.3 1998/08/06 12:45:20 curt
|
||||
// Modified to bring in stars in 8 increments based on magnitude, not number
|
||||
// of stars.
|
||||
//
|
||||
// Revision 1.2 1998/04/28 01:19:03 curt
|
||||
// Type-ified fgTIME and fgVIEW
|
||||
//
|
||||
// Revision 1.1 1998/04/22 13:21:35 curt
|
||||
// C++ - ifing the code a bit.
|
||||
//
|
||||
// Revision 1.5 1998/04/21 17:02:33 curt
|
||||
// Prepairing for C++ integration.
|
||||
//
|
||||
// Revision 1.4 1998/02/12 21:59:39 curt
|
||||
// Incorporated code changes contributed by Charlie Hotchkiss
|
||||
// <chotchkiss@namg.us.anritsu.com>
|
||||
//
|
||||
// Revision 1.3 1998/01/22 02:59:28 curt
|
||||
// Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||
//
|
||||
// Revision 1.2 1998/01/19 18:40:18 curt
|
||||
// Tons of little changes to clean up the code and to remove fatal errors
|
||||
// when building with the c++ compiler.
|
||||
//
|
||||
// Revision 1.1 1998/01/07 03:16:20 curt
|
||||
// Moved from .../Src/Scenery/ to .../Src/Astro/
|
||||
//
|
||||
// Revision 1.6 1997/10/25 03:18:29 curt
|
||||
// Incorporated sun, moon, and planet position and rendering code contributed
|
||||
// by Durk Talsma.
|
||||
//
|
||||
// Revision 1.5 1997/09/18 16:20:09 curt
|
||||
// At dusk/dawn add/remove stars in stages.
|
||||
//
|
||||
// Revision 1.4 1997/09/05 01:36:00 curt
|
||||
// Working on getting stars right.
|
||||
//
|
||||
// Revision 1.3 1997/08/29 17:55:28 curt
|
||||
// Worked on properly aligning the stars.
|
||||
//
|
||||
// Revision 1.2 1997/08/27 21:32:30 curt
|
||||
// Restructured view calculation code. Added stars.
|
||||
//
|
||||
// Revision 1.1 1997/08/27 03:34:50 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#include "celestialBody.hxx"
|
||||
@ -51,7 +50,7 @@
|
||||
* return value: none
|
||||
*
|
||||
*************************************************************************/
|
||||
void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
double eccAnom, v, ecl, actTime,
|
||||
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
@ -62,8 +61,8 @@ protected: // make the data protected, in order to give the inherit
|
||||
double lonEcl, latEcl;
|
||||
|
||||
double fgCalcEccAnom(double M, double e);
|
||||
double fgCalcActTime(fgTIME *t);
|
||||
void updateOrbElements(fgTIME *t);
|
||||
double fgCalcActTime(FGTime *t);
|
||||
void updateOrbElements(FGTime *t);
|
||||
|
||||
public:
|
||||
CelestialBody(double Nf, double Ns,
|
||||
@ -71,12 +70,12 @@ public:
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, fgTIME *t);
|
||||
double Mf, double Ms, FGTime *t);
|
||||
void getPos(double *ra, double *dec);
|
||||
void getPos(double *ra, double *dec, double *magnitude);
|
||||
double getLon();
|
||||
double getLat();
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
@ -104,7 +103,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns,
|
||||
double wf, double ws,
|
||||
double af, double as,
|
||||
double ef, double es,
|
||||
double Mf, double Ms, fgTIME *t)
|
||||
double Mf, double Ms, FGTime *t)
|
||||
{
|
||||
NFirst = Nf; NSec = Ns;
|
||||
iFirst = If; iSec = Is;
|
||||
@ -116,15 +115,15 @@ inline CelestialBody::CelestialBody(double Nf, double Ns,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* inline void CelestialBody::updateOrbElements(fgTIME *t)
|
||||
* inline void CelestialBody::updateOrbElements(FGTime *t)
|
||||
* given the current time, this private member calculates the actual
|
||||
* orbital elements
|
||||
*
|
||||
* Arguments: fgTIME *t: the current time:
|
||||
* Arguments: FGTime *t: the current time:
|
||||
*
|
||||
* return value: none
|
||||
***************************************************************************/
|
||||
inline void CelestialBody::updateOrbElements(fgTIME *t)
|
||||
inline void CelestialBody::updateOrbElements(FGTime *t)
|
||||
{
|
||||
double actTime = fgCalcActTime(t);
|
||||
M = DEG_TO_RAD * (MFirst + (MSec * actTime));
|
||||
@ -135,7 +134,7 @@ inline void CelestialBody::updateOrbElements(fgTIME *t)
|
||||
a = aFirst + (aSec * actTime);
|
||||
}
|
||||
/*****************************************************************************
|
||||
* inline double CelestialBody::fgCalcActTime(fgTIME *t)
|
||||
* inline double CelestialBody::fgCalcActTime(FGTime *t)
|
||||
* this private member function returns the offset in days from the epoch for
|
||||
* wich the orbital elements are calculated (Jan, 1st, 2000).
|
||||
*
|
||||
@ -143,9 +142,9 @@ inline void CelestialBody::updateOrbElements(fgTIME *t)
|
||||
*
|
||||
* return value: the (fractional) number of days until Jan 1, 2000.
|
||||
****************************************************************************/
|
||||
inline double CelestialBody::fgCalcActTime(fgTIME *t)
|
||||
inline double CelestialBody::fgCalcActTime(FGTime *t)
|
||||
{
|
||||
return (t->mjd - 36523.5);
|
||||
return (t->getMjd() - 36523.5);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
@ -32,13 +31,13 @@
|
||||
#include "jupiter.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Jupiter::Jupiter(fgTIME *t)
|
||||
* Jupiter::Jupiter(FGTime *t)
|
||||
* Public constructor for class Jupiter
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Jupiter are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Jupiter::Jupiter(fgTIME *t) :
|
||||
Jupiter::Jupiter(FGTime *t) :
|
||||
CelestialBody(100.4542, 2.7685400E-5,
|
||||
1.3030, -1.557E-7,
|
||||
273.8777, 1.6450500E-5,
|
||||
@ -49,13 +48,13 @@ Jupiter::Jupiter(fgTIME *t) :
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Jupiter::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Jupiter, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Jupiter specific equation
|
||||
*************************************************************************/
|
||||
void Jupiter::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _JUPITER_HXX_
|
||||
#define _JUPITER_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Jupiter : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Jupiter (fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
Jupiter (FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _JUPITER_HXX_
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -31,13 +30,13 @@
|
||||
#include "mars.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Mars::Mars(fgTIME *t)
|
||||
* Mars::Mars(FGTime *t)
|
||||
* Public constructor for class Mars
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Mars are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Mars::Mars(fgTIME *t) :
|
||||
Mars::Mars(FGTime *t) :
|
||||
CelestialBody(49.55740, 2.1108100E-5,
|
||||
1.8497, -1.78E-8,
|
||||
286.5016, 2.9296100E-5,
|
||||
@ -47,13 +46,13 @@ Mars::Mars(fgTIME *t) :
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Mars::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Mars::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Mars, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Mars specific equation
|
||||
*************************************************************************/
|
||||
void Mars::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Mars::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _MARS_HXX_
|
||||
#define _MARS_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Mars : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Mars ( fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
Mars ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _MARS_HXX_
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -31,13 +30,13 @@
|
||||
#include "mercury.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Mercury::Mercury(fgTIME *t)
|
||||
* Mercury::Mercury(FGTime *t)
|
||||
* Public constructor for class Mercury
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Mercury are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Mercury::Mercury(fgTIME *t) :
|
||||
Mercury::Mercury(FGTime *t) :
|
||||
CelestialBody (48.33130, 3.2458700E-5,
|
||||
7.0047, 5.00E-8,
|
||||
29.12410, 1.0144400E-5,
|
||||
@ -47,13 +46,13 @@ Mercury::Mercury(fgTIME *t) :
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Mercury::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Mercury::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Mercury, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Mercury specific equation
|
||||
*************************************************************************/
|
||||
void Mercury::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Mercury::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _MERCURY_HXX_
|
||||
#define _MERCURY_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Mercury : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Mercury ( fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star* ourSun);
|
||||
Mercury ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star* ourSun);
|
||||
};
|
||||
|
||||
#endif // _MERURY_HXX_
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#include <FDM/flight.hxx>
|
||||
@ -29,6 +28,8 @@
|
||||
#include "moon.hxx"
|
||||
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Misc/fgpath.hxx>
|
||||
#include <Objects/texload.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -38,14 +39,14 @@
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Moon::Moon(fgTIME *t)
|
||||
* Moon::Moon(FGTime *t)
|
||||
* Public constructor for class Moon. Initializes the orbital elements and
|
||||
* sets up the moon texture.
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Moon are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Moon::Moon(fgTIME *t) :
|
||||
Moon::Moon(FGTime *t) :
|
||||
CelestialBody(125.1228, -0.0529538083,
|
||||
5.1454, 0.00000,
|
||||
318.0634, 0.1643573223,
|
||||
@ -53,7 +54,6 @@ Moon::Moon(fgTIME *t) :
|
||||
0.054900, 0.000000,
|
||||
115.3654, 13.0649929509, t)
|
||||
{
|
||||
string tpath, fg_tpath;
|
||||
int width, height;
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
|
||||
@ -72,18 +72,21 @@ Moon::Moon(fgTIME *t) :
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// load in the texture data
|
||||
tpath = current_options.get_fg_root() + "/Textures/" + "moon.rgb";
|
||||
|
||||
FGPath tpath( current_options.get_fg_root() );
|
||||
tpath.append( "Textures" );
|
||||
tpath.append( "moon.rgb" );
|
||||
|
||||
if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
// Try compressed
|
||||
fg_tpath = tpath + ".gz";
|
||||
FGPath fg_tpath = tpath;
|
||||
fg_tpath.append( ".gz" );
|
||||
if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
|
||||
== NULL )
|
||||
{
|
||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||
"Error in loading moon texture " << tpath );
|
||||
"Error in loading moon texture " << tpath.str() );
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@ -185,12 +188,12 @@ void Moon::setHalo()
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* void Moon::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Moon::updatePosition(FGTime *t, Star *ourSun)
|
||||
* this member function calculates the actual topocentric position (i.e.)
|
||||
* the position of the moon as seen from the current position on the surface
|
||||
* of the moon.
|
||||
****************************************************************************/
|
||||
void Moon::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Moon::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
double
|
||||
eccAnom, ecl, actTime,
|
||||
@ -267,6 +270,11 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
|
||||
geoRa = atan2(ye, xe);
|
||||
geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa)
|
||||
<< "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */
|
||||
|
||||
|
||||
// Given the moon's geocentric ra and dec, calculate its
|
||||
// topocentric ra and dec. i.e. the position as seen from the
|
||||
// surface of the earth, instead of the center of the earth
|
||||
@ -274,16 +282,32 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
|
||||
// First calculate the moon's parrallax, that is, the apparent size of the
|
||||
// (equatorial) radius of the earth, as seen from the moon
|
||||
mpar = asin ( 1 / r);
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() );
|
||||
|
||||
gclat = f->get_Latitude() - 0.003358 *
|
||||
sin (2 * DEG_TO_RAD * f->get_Latitude() );
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
|
||||
|
||||
rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * f->get_Latitude());
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
|
||||
|
||||
if (geoRa < 0)
|
||||
geoRa += (2*FG_PI);
|
||||
|
||||
HA = t->lst - (3.8197186 * geoRa);
|
||||
HA = t->getLst() - (3.8197186 * geoRa);
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
|
||||
<< " HA = " << HA ); */
|
||||
|
||||
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
|
||||
// FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
|
||||
|
||||
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
|
||||
declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
|
||||
|
||||
/* FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
|
||||
}
|
||||
|
||||
|
||||
@ -308,87 +332,70 @@ void Moon::newImage()
|
||||
int moonSize = 750;
|
||||
|
||||
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
|
||||
GLfloat black[4] = {0.0, 0.0,0.0,1.0};
|
||||
GLfloat white[4] = {1.0, 1.0,1.0,1.0};
|
||||
GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
|
||||
|
||||
if( moon_angle*RAD_TO_DEG < 100 )
|
||||
{
|
||||
/*
|
||||
x_2 = moon_angle * moon_angle;
|
||||
x_4 = x_2 * x_2;
|
||||
x_8 = x_4 * x_4;
|
||||
x_10 = x_8 * x_2;
|
||||
ambient = (float)(0.4 * pow (1.1, - x_10 / 30.0));
|
||||
if (ambient < 0.3) ambient = 0.3;
|
||||
if (ambient > 1.0) ambient = 1.0;
|
||||
|
||||
amb[0] = ((ambient * 6.0) - 1.0); // minimum value = 0.8
|
||||
amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3
|
||||
amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0
|
||||
amb[3] = 1.00;
|
||||
|
||||
if (amb[0] > 1.0) amb[0] = 1.0;
|
||||
if (amb[1] > 1.0) amb[1] = 1.0;
|
||||
if (amb[2] > 1.0) amb[2] = 1.0;
|
||||
xglColor3fv(amb);
|
||||
xglColor3f(1.0, 1.0, 1.0); */
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" );
|
||||
|
||||
xglPushMatrix();
|
||||
{
|
||||
//xglRotatef(-90, 0.0, 0.0, 1.0);
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Ra = (" << (RAD_TO_DEG *rightAscension)
|
||||
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
|
||||
xglTranslatef(0.0, 58600.0, 0.0);
|
||||
xglTranslatef(0.0, 60000.0, 0.0);
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
// Draw the halo...
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
|
||||
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
|
||||
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
|
||||
xglEnable( GL_LIGHT0 );
|
||||
// set lighting parameters
|
||||
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
|
||||
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
|
||||
xglEnable( GL_CULL_FACE );
|
||||
// xglEnable( GL_CULL_FACE );
|
||||
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
|
||||
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
|
||||
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, moon_texid);
|
||||
//glDisable(GL_LIGHTING); // LIGHTING DISABLED
|
||||
// Draw the moon-proper
|
||||
|
||||
gluQuadricTexture(moonObject, GL_TRUE );
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, moon_texid);
|
||||
gluQuadricTexture(moonObject, GL_TRUE );
|
||||
}
|
||||
gluSphere(moonObject, moonSize, 12, 12 );
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
xglPopMatrix();
|
||||
glDisable(GL_LIGHTING); // LIGHTING DISABLED
|
||||
|
||||
glDisable(GL_LIGHTING); // Lighting Disabled.
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _MOON_HXX_
|
||||
#define _MOON_HXX_
|
||||
@ -47,9 +46,9 @@ private:
|
||||
|
||||
void setHalo();
|
||||
public:
|
||||
Moon ( fgTIME *t);
|
||||
Moon ( FGTime *t);
|
||||
~Moon();
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
void newImage();
|
||||
};
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -31,13 +30,13 @@
|
||||
#include "neptune.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Neptune::Neptune(fgTIME *t)
|
||||
* Neptune::Neptune(FGTime *t)
|
||||
* Public constructor for class Neptune
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Neptune are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Neptune::Neptune(fgTIME *t) :
|
||||
Neptune::Neptune(FGTime *t) :
|
||||
CelestialBody(131.7806, 3.0173000E-5,
|
||||
1.7700, -2.550E-7,
|
||||
272.8461, -6.027000E-6,
|
||||
@ -47,13 +46,13 @@ Neptune::Neptune(fgTIME *t) :
|
||||
{
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Neptune::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Neptune::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Neptune, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Neptune specific equation
|
||||
*************************************************************************/
|
||||
void Neptune::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Neptune::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _NEPTUNE_HXX_
|
||||
#define _NEPTUNE_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Neptune : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Neptune ( fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
Neptune ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _NEPTUNE_HXX_
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _PLUTO_HXX_
|
||||
#define _PLUTO_HXX_
|
||||
@ -31,7 +30,7 @@
|
||||
class Pluto : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Pluto ( fgTIME t);
|
||||
Pluto ( FGTime t);
|
||||
};
|
||||
|
||||
#endif // _PLUTO_HXX_
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -31,13 +30,13 @@
|
||||
#include "saturn.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Saturn::Saturn(fgTIME *t)
|
||||
* Saturn::Saturn(FGTime *t)
|
||||
* Public constructor for class Saturn
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Saturn are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Saturn::Saturn(fgTIME *t) :
|
||||
Saturn::Saturn(FGTime *t) :
|
||||
CelestialBody(113.6634, 2.3898000E-5,
|
||||
2.4886, -1.081E-7,
|
||||
339.3939, 2.9766100E-5,
|
||||
@ -48,13 +47,13 @@ Saturn::Saturn(fgTIME *t) :
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Saturn::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Saturn::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Saturn, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Saturn specific equation
|
||||
*************************************************************************/
|
||||
void Saturn::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Saturn::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _SATURN_HXX_
|
||||
#define _SATURN_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Saturn : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Saturn ( fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
Saturn ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _SATURN_HXX_
|
@ -19,7 +19,6 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -47,6 +46,11 @@
|
||||
#include "sky.hxx"
|
||||
|
||||
|
||||
#ifdef __MWERKS__
|
||||
# pragma global_optimizer off
|
||||
#endif
|
||||
|
||||
|
||||
// in meters of course
|
||||
#define CENTER_ELEV 25000.0
|
||||
|
||||
@ -361,156 +365,3 @@ void fgSkyRender( void ) {
|
||||
}
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.21 1999/02/05 21:28:50 curt
|
||||
// Modifications to incorporate Jon S. Berndts flight model code.
|
||||
//
|
||||
// Revision 1.20 1999/02/02 20:13:29 curt
|
||||
// MSVC++ portability changes by Bernie Bright:
|
||||
//
|
||||
// Lib/Serial/serial.[ch]xx: Initial Windows support - incomplete.
|
||||
// Simulator/Astro/stars.cxx: typo? included <stdio> instead of <cstdio>
|
||||
// Simulator/Cockpit/hud.cxx: Added Standard headers
|
||||
// Simulator/Cockpit/panel.cxx: Redefinition of default parameter
|
||||
// Simulator/Flight/flight.cxx: Replaced cout with FG_LOG. Deleted <stdio.h>
|
||||
// Simulator/Main/fg_init.cxx:
|
||||
// Simulator/Main/GLUTmain.cxx:
|
||||
// Simulator/Main/options.hxx: Shuffled <fg_serial.hxx> dependency
|
||||
// Simulator/Objects/material.hxx:
|
||||
// Simulator/Time/timestamp.hxx: VC++ friend kludge
|
||||
// Simulator/Scenery/tile.[ch]xx: Fixed using std::X declarations
|
||||
// Simulator/Main/views.hxx: Added a constant
|
||||
//
|
||||
// Revision 1.19 1999/02/01 21:33:26 curt
|
||||
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
|
||||
// Jon accepted my offer to do this and thought it was a good idea.
|
||||
//
|
||||
// Revision 1.18 1999/02/01 21:09:00 curt
|
||||
// Bug fix in vertex order of inner disk (fan) of the sky dome.
|
||||
//
|
||||
// Revision 1.17 1998/12/09 18:50:12 curt
|
||||
// Converted "class fgVIEW" to "class FGView" and updated to make data
|
||||
// members private and make required accessor functions.
|
||||
//
|
||||
// Revision 1.16 1998/12/05 15:54:03 curt
|
||||
// Renamed class fgFLIGHT to class FGState as per request by JSB.
|
||||
//
|
||||
// Revision 1.15 1998/12/03 01:15:36 curt
|
||||
// Converted fgFLIGHT to a class.
|
||||
// Tweaks for Sun portability.
|
||||
//
|
||||
// Revision 1.14 1998/11/06 21:17:39 curt
|
||||
// Converted to new logstream debugging facility. This allows release
|
||||
// builds with no messages at all (and no performance impact) by using
|
||||
// the -DFG_NDEBUG flag.
|
||||
//
|
||||
// Revision 1.13 1998/10/20 18:28:30 curt
|
||||
// Tweaked sunset/sunrise colors.
|
||||
//
|
||||
// Revision 1.12 1998/10/16 23:27:18 curt
|
||||
// C++-ifying.
|
||||
//
|
||||
// Revision 1.11 1998/10/16 00:52:19 curt
|
||||
// Converted to Point3D class.
|
||||
//
|
||||
// Revision 1.10 1998/08/29 13:07:16 curt
|
||||
// Rewrite of event manager thanks to Bernie Bright.
|
||||
//
|
||||
// Revision 1.9 1998/08/22 01:18:59 curt
|
||||
// Minor tweaks to avoid using unitialized memory.
|
||||
//
|
||||
// Revision 1.8 1998/08/12 21:40:44 curt
|
||||
// Sky now tracks adjusted fog color so it blends well with terrain.
|
||||
//
|
||||
// Revision 1.7 1998/07/22 21:39:21 curt
|
||||
// Lower skirt tracks adjusted fog color, not fog color.
|
||||
//
|
||||
// Revision 1.6 1998/05/23 14:07:14 curt
|
||||
// Use new C++ events class.
|
||||
//
|
||||
// Revision 1.5 1998/04/28 01:19:02 curt
|
||||
// Type-ified fgTIME and fgVIEW
|
||||
//
|
||||
// Revision 1.4 1998/04/26 05:10:01 curt
|
||||
// "struct fgLIGHT" -> "fgLIGHT" because fgLIGHT is typedef'd.
|
||||
//
|
||||
// Revision 1.3 1998/04/25 22:06:25 curt
|
||||
// Edited cvs log messages in source files ... bad bad bad!
|
||||
//
|
||||
// Revision 1.2 1998/04/24 00:45:03 curt
|
||||
// Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
|
||||
// Fixed a bug when generating sky colors.
|
||||
//
|
||||
// Revision 1.1 1998/04/22 13:21:32 curt
|
||||
// C++ - ifing the code a bit.
|
||||
//
|
||||
// Revision 1.9 1998/04/03 21:52:50 curt
|
||||
// Converting to Gnu autoconf system.
|
||||
//
|
||||
// Revision 1.8 1998/03/09 22:47:25 curt
|
||||
// Incorporated Durk's updates.
|
||||
//
|
||||
// Revision 1.7 1998/02/19 13:05:49 curt
|
||||
// Incorporated some HUD tweaks from Michelle America.
|
||||
// Tweaked the sky's sunset/rise colors.
|
||||
// Other misc. tweaks.
|
||||
//
|
||||
// Revision 1.6 1998/02/07 15:29:32 curt
|
||||
// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
|
||||
// <chotchkiss@namg.us.anritsu.com>
|
||||
//
|
||||
// Revision 1.5 1998/01/27 00:47:48 curt
|
||||
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||
// system and commandline/config file processing code.
|
||||
//
|
||||
// Revision 1.4 1998/01/26 15:54:28 curt
|
||||
// Added a "skirt" to try to help hide gaps between scenery and sky. This will
|
||||
// have to be revisited in the future.
|
||||
//
|
||||
// Revision 1.3 1998/01/19 19:26:59 curt
|
||||
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||
// This should simplify things tremendously.
|
||||
//
|
||||
// Revision 1.2 1998/01/19 18:40:17 curt
|
||||
// Tons of little changes to clean up the code and to remove fatal errors
|
||||
// when building with the c++ compiler.
|
||||
//
|
||||
// Revision 1.1 1998/01/07 03:16:19 curt
|
||||
// Moved from .../Src/Scenery/ to .../Src/Astro/
|
||||
//
|
||||
// Revision 1.11 1997/12/30 22:22:38 curt
|
||||
// Further integration of event manager.
|
||||
//
|
||||
// Revision 1.10 1997/12/30 20:47:53 curt
|
||||
// Integrated new event manager with subsystem initializations.
|
||||
//
|
||||
// Revision 1.9 1997/12/30 13:06:57 curt
|
||||
// A couple lighting tweaks ...
|
||||
//
|
||||
// Revision 1.8 1997/12/23 04:58:38 curt
|
||||
// Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
// control.
|
||||
//
|
||||
// Revision 1.7 1997/12/22 23:45:48 curt
|
||||
// First stab at sunset/sunrise sky glow effects.
|
||||
//
|
||||
// Revision 1.6 1997/12/22 04:14:34 curt
|
||||
// Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||
//
|
||||
// Revision 1.5 1997/12/19 23:34:59 curt
|
||||
// Lot's of tweaking with sky rendering and lighting.
|
||||
//
|
||||
// Revision 1.4 1997/12/19 16:45:02 curt
|
||||
// Working on scene rendering order and options.
|
||||
//
|
||||
// Revision 1.3 1997/12/18 23:32:36 curt
|
||||
// First stab at sky dome actually starting to look reasonable. :-)
|
||||
//
|
||||
// Revision 1.2 1997/12/18 04:07:03 curt
|
||||
// Worked on properly translating and positioning the sky dome.
|
||||
//
|
||||
// Revision 1.1 1997/12/17 23:14:30 curt
|
||||
// Initial revision.
|
||||
// Begin work on rendering the sky. (Rather than just using a clear screen.)
|
||||
//
|
||||
|
@ -19,7 +19,6 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#ifndef _SKY_HXX
|
||||
@ -44,30 +43,3 @@ void fgSkyRender( void );
|
||||
#endif // _SKY_HXX
|
||||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.2 1998/10/16 23:27:19 curt
|
||||
// C++-ifying.
|
||||
//
|
||||
// Revision 1.1 1998/04/22 13:21:33 curt
|
||||
// C++ - ifing the code a bit.
|
||||
//
|
||||
// Revision 1.4 1998/04/21 17:02:32 curt
|
||||
// Prepairing for C++ integration.
|
||||
//
|
||||
// Revision 1.3 1998/01/22 02:59:28 curt
|
||||
// Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||
//
|
||||
// Revision 1.2 1998/01/19 18:40:17 curt
|
||||
// Tons of little changes to clean up the code and to remove fatal errors
|
||||
// when building with the c++ compiler.
|
||||
//
|
||||
// Revision 1.1 1998/01/07 03:16:19 curt
|
||||
// Moved from .../Src/Scenery/ to .../Src/Astro/
|
||||
//
|
||||
// Revision 1.2 1997/12/22 23:45:49 curt
|
||||
// First stab at sunset/sunrise sky glow effects.
|
||||
//
|
||||
// Revision 1.1 1997/12/17 23:14:31 curt
|
||||
// Initial revision.
|
||||
// Begin work on rendering the sky. (Rather than just using a clear screen.)
|
||||
//
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -46,10 +45,10 @@
|
||||
/***************************************************************************
|
||||
* default constructor for class SolarSystem:
|
||||
* or course there can only be one way to create an entire solar system -:) )
|
||||
* the fgTIME argument is needed to properly initialize the the current orbital
|
||||
* the FGTime argument is needed to properly initialize the the current orbital
|
||||
* elements
|
||||
*************************************************************************/
|
||||
SolarSystem::SolarSystem(fgTIME *t)
|
||||
SolarSystem::SolarSystem(FGTime *t)
|
||||
{
|
||||
if (theSolarSystem)
|
||||
{
|
||||
@ -97,7 +96,7 @@ SolarSystem::~SolarSystem()
|
||||
void SolarSystem::rebuild()
|
||||
{
|
||||
//fgLIGHT *l = &cur_light_params;
|
||||
fgTIME *t = &cur_time_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
//float x, y, z;
|
||||
//double sun_angle;
|
||||
double ra, dec;
|
||||
@ -106,10 +105,8 @@ void SolarSystem::rebuild()
|
||||
//GLfloat ambient;
|
||||
//GLfloat amb[4];
|
||||
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
||||
// Step 1: update all the positions
|
||||
ourSun->updatePosition(t);
|
||||
earthsMoon->updatePosition(t, ourSun);
|
||||
@ -130,20 +127,19 @@ void SolarSystem::rebuild()
|
||||
|
||||
displayList = xglGenLists(1);
|
||||
|
||||
FG_LOG( FG_ASTRO, FG_INFO, "Rebuilding astro display list" );
|
||||
|
||||
// Step 2: rebuild the display list
|
||||
xglNewList( displayList, GL_COMPILE);
|
||||
{
|
||||
// Step 2a: Add the moon...
|
||||
// Not that it is preferred to draw the moon first, and the sun next, in order to mime a
|
||||
// solar eclipse. This is yet untested though...
|
||||
// Euhh, actually the ecplise doesn't work...
|
||||
|
||||
earthsMoon->newImage();
|
||||
// Step 2b: Add the sun
|
||||
//xglPushMatrix();
|
||||
//{
|
||||
ourSun->newImage();
|
||||
//}
|
||||
//xglPopMatrix();
|
||||
ourSun->newImage();
|
||||
// Step 2c: Add the planets
|
||||
xglBegin(GL_POINTS);
|
||||
mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _SOLARSYSTEM_H_
|
||||
#define _SOLARSYSTEM_H_
|
||||
@ -61,7 +60,7 @@ private:
|
||||
|
||||
|
||||
public:
|
||||
SolarSystem(fgTIME *t);
|
||||
SolarSystem(FGTime *t);
|
||||
CelestialBody *getSun();
|
||||
CelestialBody *getMoon();
|
||||
~SolarSystem();
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -30,10 +29,11 @@
|
||||
#include <Time/sunpos.hxx>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Time/light.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include "star.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Star::Star(fgTIME *t)
|
||||
* Star::Star(FGTime *t)
|
||||
* Public constructor for class Star
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements our sun are passed to
|
||||
@ -41,7 +41,7 @@
|
||||
* note that the word sun is avoided, in order to prevent some compilation
|
||||
* problems on sun systems
|
||||
************************************************************************/
|
||||
Star::Star(fgTIME *t) :
|
||||
Star::Star(FGTime *t) :
|
||||
CelestialBody (0.000000, 0.0000000000,
|
||||
0.0000, 0.00000,
|
||||
282.9404, 4.7093500E-5,
|
||||
@ -145,11 +145,11 @@ void Star::setTexture()
|
||||
//free(textureBuf);
|
||||
}
|
||||
/*************************************************************************
|
||||
* void Jupiter::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of our sun.
|
||||
*************************************************************************/
|
||||
void Star::updatePosition(fgTIME *t)
|
||||
void Star::updatePosition(FGTime *t)
|
||||
{
|
||||
double
|
||||
actTime, eccAnom,
|
||||
@ -233,40 +233,39 @@ void Star::newImage(void)
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
xglTranslatef(0,60000,0);
|
||||
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
//glEnable(GL_BLEND);
|
||||
//glDisable(GL_LIGHTING);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, sun_texid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
if (current_options.get_textures())
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
|
||||
glEnable(GL_BLEND); // BLEND ENABLED
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBindTexture(GL_TEXTURE_2D, sun_texid);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
|
||||
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
|
||||
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
|
||||
glEnd();
|
||||
}
|
||||
xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
xglDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
xglDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_LIGHTING); //LIGHTING DISABLED
|
||||
glDisable(GL_BLEND); //BLEND DISABLED
|
||||
glPushMatrix();
|
||||
{
|
||||
{
|
||||
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
|
||||
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
|
||||
xglTranslatef(0,58600,0);
|
||||
xglColor4fv(amb);
|
||||
xglTranslatef(0,60000,0);
|
||||
gluSphere( SunObject, sun_size, 10, 10 );
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
|
||||
glDisable(GL_BLEND); // BLEND DISABLED
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _STAR_HXX_
|
||||
#define _STAR_HXX_
|
||||
@ -42,9 +41,9 @@ private:
|
||||
|
||||
void setTexture();
|
||||
public:
|
||||
Star (fgTIME *t);
|
||||
Star (FGTime *t);
|
||||
~Star();
|
||||
void updatePosition(fgTIME *t);
|
||||
void updatePosition(FGTime *t);
|
||||
double getM();
|
||||
double getw();
|
||||
//double getLon();
|
267
simgear/ephemeris/stars.cxx
Normal file
267
simgear/ephemeris/stars.cxx
Normal file
@ -0,0 +1,267 @@
|
||||
// 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
|
||||
|
||||
#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
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <XGL/xgl.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Misc/fgpath.hxx>
|
||||
#include <Misc/fgstream.hxx>
|
||||
#include <Misc/stopwatch.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
#include "Misc/stopwatch.hxx"
|
||||
|
||||
#include "stars.hxx"
|
||||
|
||||
FG_USING_STD(getline);
|
||||
|
||||
#define EpochStart (631065600)
|
||||
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
|
||||
#define FG_MAX_STARS 3500
|
||||
|
||||
// Define four structures, each with varying amounts of stars
|
||||
static GLint stars[FG_STAR_LEVELS];
|
||||
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void ) {
|
||||
// -dw- avoid local data > 32k error by dynamic allocation of the
|
||||
// array, problem for some compilers
|
||||
Point3D *starlist = new Point3D[FG_MAX_STARS];
|
||||
// struct CelestialCoord pltPos;
|
||||
double right_ascension, declination, magnitude;
|
||||
double min_magnitude[FG_STAR_LEVELS];
|
||||
// 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);
|
||||
}
|
||||
|
||||
// build the full path name to the stars data base file
|
||||
FGPath path ( current_options.get_fg_root() );
|
||||
path.append( "Astro/stars" );
|
||||
FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path.str() );
|
||||
|
||||
fg_gzifstream in( path.str() );
|
||||
if ( ! in ) {
|
||||
FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path.str() );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
starcount = 0;
|
||||
|
||||
StopWatch timer;
|
||||
timer.start();
|
||||
|
||||
// read in each line of the file
|
||||
while ( ! in.eof() && starcount < FG_MAX_STARS )
|
||||
{
|
||||
in >> skipcomment;
|
||||
string name;
|
||||
getline( in, name, ',' );
|
||||
in >> starlist[starcount];
|
||||
++starcount;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
FG_LOG( FG_ASTRO, FG_INFO,
|
||||
"Loaded " << starcount << " stars in "
|
||||
<< timer.elapsedSeconds() << " seconds" );
|
||||
|
||||
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++ ) {
|
||||
magnitude = starlist[j].z();
|
||||
// printf("magnitude = %.2f\n", magnitude);
|
||||
|
||||
if ( magnitude < min_magnitude[i] ) {
|
||||
right_ascension = starlist[j].x();
|
||||
declination = starlist[j].y();
|
||||
|
||||
count++;
|
||||
|
||||
// scale magnitudes to (0.0 - 1.0)
|
||||
magnitude = (0.0 - magnitude) / 5.0 + 1.0;
|
||||
|
||||
// scale magnitudes again so they look ok
|
||||
if ( magnitude > 1.0 ) { magnitude = 1.0; }
|
||||
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
||||
// magnitude =
|
||||
// magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.042);
|
||||
|
||||
magnitude = magnitude * 0.9 +
|
||||
(((FG_STAR_LEVELS - 1) - i) * 0.014);
|
||||
// printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
|
||||
// name, right_ascension, declination, magnitude);
|
||||
|
||||
xglColor3f( magnitude, magnitude, magnitude );
|
||||
//xglColor3f(0,0,0);*/
|
||||
xglVertex3f( 50000.0*cos(right_ascension)*cos(declination),
|
||||
50000.0*sin(right_ascension)*cos(declination),
|
||||
50000.0*sin(declination) );
|
||||
}
|
||||
} // 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.
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
// FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise
|
||||
|
||||
// t->sun_angle = 3.0; // to force stars to be drawn (for testing)
|
||||
|
||||
// render the stars
|
||||
if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
// printf("RENDERING STARS = %d (night)\n", i);
|
||||
|
||||
xglCallList(stars[i]);
|
||||
} else {
|
||||
// printf("not RENDERING STARS (day)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
47
simgear/ephemeris/stars.hxx
Normal file
47
simgear/ephemeris/stars.hxx
Normal file
@ -0,0 +1,47 @@
|
||||
// stars.hxx -- 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$
|
||||
|
||||
|
||||
#ifndef _STARS_HXX
|
||||
#define _STARS_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <Time/fg_time.hxx>
|
||||
|
||||
#define FG_STAR_LEVELS 8 // how many star transitions
|
||||
|
||||
// Initialize the Star Management Subsystem
|
||||
int fgStarsInit( void );
|
||||
|
||||
// Draw the Stars
|
||||
void fgStarsRender( void );
|
||||
|
||||
// [no longer used?] extern FGTime cur_time_params;
|
||||
|
||||
|
||||
#endif // _STARS_HXX
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -31,13 +30,13 @@
|
||||
#include "uranus.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Uranus::Uranus(fgTIME *t)
|
||||
* Uranus::Uranus(FGTime *t)
|
||||
* Public constructor for class Uranus
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Uranus are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Uranus::Uranus(fgTIME *t) :
|
||||
Uranus::Uranus(FGTime *t) :
|
||||
CelestialBody(74.00050, 1.3978000E-5,
|
||||
0.7733, 1.900E-8,
|
||||
96.66120, 3.0565000E-5,
|
||||
@ -48,13 +47,13 @@ Uranus::Uranus(fgTIME *t) :
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Uranus::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Uranus::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Uranus, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Uranus specific equation
|
||||
*************************************************************************/
|
||||
void Uranus::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Uranus::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _URANUS_HXX_
|
||||
#define _URANUS_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Uranus : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Uranus ( fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
Uranus ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _URANUS_HXX_
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -31,13 +30,13 @@
|
||||
#include "venus.hxx"
|
||||
|
||||
/*************************************************************************
|
||||
* Venus::Venus(fgTIME *t)
|
||||
* Venus::Venus(FGTime *t)
|
||||
* Public constructor for class Venus
|
||||
* Argument: The current time.
|
||||
* the hard coded orbital elements for Venus are passed to
|
||||
* CelestialBody::CelestialBody();
|
||||
************************************************************************/
|
||||
Venus::Venus(fgTIME *t) :
|
||||
Venus::Venus(FGTime *t) :
|
||||
CelestialBody(76.67990, 2.4659000E-5,
|
||||
3.3946, 2.75E-8,
|
||||
54.89100, 1.3837400E-5,
|
||||
@ -48,13 +47,13 @@ Venus::Venus(fgTIME *t) :
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* void Venus::updatePosition(fgTIME *t, Star *ourSun)
|
||||
* void Venus::updatePosition(FGTime *t, Star *ourSun)
|
||||
*
|
||||
* calculates the current position of Venus, by calling the base class,
|
||||
* CelestialBody::updatePosition(); The current magnitude is calculated using
|
||||
* a Venus specific equation
|
||||
*************************************************************************/
|
||||
void Venus::updatePosition(fgTIME *t, Star *ourSun)
|
||||
void Venus::updatePosition(FGTime *t, Star *ourSun)
|
||||
{
|
||||
CelestialBody::updatePosition(t, ourSun);
|
||||
magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
**************************************************************************/
|
||||
#ifndef _VENUS_HXX_
|
||||
#define _VENUS_HXX_
|
||||
@ -32,8 +31,8 @@
|
||||
class Venus : public CelestialBody
|
||||
{
|
||||
public:
|
||||
Venus ( fgTIME *t);
|
||||
void updatePosition(fgTIME *t, Star *ourSun);
|
||||
Venus ( FGTime *t);
|
||||
void updatePosition(FGTime *t, Star *ourSun);
|
||||
};
|
||||
|
||||
#endif // _VENUS_HXX_
|
Loading…
Reference in New Issue
Block a user