lib_LTLIBRARIES = libAstro.la
libAstro_la_SOURCES = \
- moon.c moon.h \
- orbits.c orbits.h \
- planets.c planets.h \
- sky.c sky.h \
- stars.c stars.h \
- sun.c sun.h
+ moon.cxx moon.hxx \
+ orbits.cxx orbits.hxx \
+ planets.cxx planets.hxx \
+ sky.cxx sky.hxx \
+ stars.cxx stars.hxx \
+ sun.cxx sun.hxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
lib_LTLIBRARIES = libAstro.la
libAstro_la_SOURCES = \
- moon.c moon.h \
- orbits.c orbits.h \
- planets.c planets.h \
- sky.c sky.h \
- stars.c stars.h \
- sun.c sun.h
+ moon.cxx moon.hxx \
+ orbits.cxx orbits.hxx \
+ planets.cxx planets.hxx \
+ sky.cxx sky.hxx \
+ stars.cxx stars.hxx \
+ sun.cxx sun.hxx
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../Include/config.h
CONFIG_CLEAN_FILES =
libAstro_la_LIBADD =
libAstro_la_OBJECTS = moon.lo orbits.lo planets.lo sky.lo stars.lo \
sun.lo
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
+CXXFLAGS = @CXXFLAGS@
+CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)
+CXXLINK = $(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in
GZIP = --best
DEP_FILES = .deps/moon.P .deps/orbits.P .deps/planets.P .deps/sky.P \
.deps/stars.P .deps/sun.P
+CXXMKDEP = $(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)
SOURCES = $(libAstro_la_SOURCES)
OBJECTS = $(libAstro_la_OBJECTS)
all: Makefile $(LTLIBRARIES)
.SUFFIXES:
-.SUFFIXES: .S .c .lo .o .s
+.SUFFIXES: .S .c .cxx .lo .o .s
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu Simulator/Astro/Makefile
maintainer-clean-libtool:
libAstro.la: $(libAstro_la_OBJECTS) $(libAstro_la_DEPENDENCIES)
- $(LINK) -rpath $(libdir) $(libAstro_la_LDFLAGS) $(libAstro_la_OBJECTS) $(libAstro_la_LIBADD) $(LIBS)
+ $(CXXLINK) -rpath $(libdir) $(libAstro_la_LDFLAGS) $(libAstro_la_OBJECTS) $(libAstro_la_LIBADD) $(LIBS)
+.cxx.o:
+ $(CXXCOMPILE) -c $<
+.cxx.lo:
+ $(LTCXXCOMPILE) -c $<
tags: TAGS
@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \
< .deps/$(*F).p > .deps/$(*F).P
@-rm -f .deps/$(*F).p
+
+%.o: %.cxx
+ @echo '$(CXXCOMPILE) -c $<'; \
+ $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).P -c $<
+
+%.lo: %.cxx
+ @echo '$(LTCXXCOMPILE) -c $<'; \
+ $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<
+ @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \
+ < .deps/$(*F).p > .deps/$(*F).P
+ @-rm -f .deps/$(*F).p
info:
dvi:
check: all
+++ /dev/null
-/**************************************************************************
- * moon.c
- * Written by Durk Talsma. Started October 1997, for the flight gear project.
- *
- * 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)
- **************************************************************************/
-
-
-#include <config.h>
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <math.h>
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Astro/orbits.h>
-#include <Astro/moon.h>
-
-#include <Aircraft/aircraft.h>
-#include <Debug/fg_debug.h>
-#include <Include/fg_constants.h>
-#include <Include/general.h>
-#include <Main/views.h>
-#include <Time/fg_time.h>
-
-struct CelestialCoord moonPos;
-
-static float xMoon, yMoon, zMoon;
-static GLint moon = 0;
-
-
-
-/* --------------------------------------------------------------
- This section contains the code that calculates the actual
- position of the moon in the night sky.
-----------------------------------------------------------------*/
-struct CelestialCoord fgCalculateMoon(struct OrbElements params,
- struct OrbElements sunParams,
- struct fgTIME t)
-{
- struct CelestialCoord
- geocCoord, topocCoord;
-
- double
- eccAnom, ecl, lonecl, latecl, actTime,
- xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
- Ls, Lm, D, F, mpar, gclat, rho, HA, g;
-
- fgAIRCRAFT *a;
- fgFLIGHT *f;
-
- a = ¤t_aircraft;
- f = a->flight;
-
- /* calculate the angle between ecliptic and equatorial coordinate
- * system, in Radians */
- actTime = fgCalcActTime(t);
- ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
- /*ecl = 0.409093 - 6.2186E-9 * actTime; */
-
- /* calculate the eccentric anomaly */
- eccAnom = fgCalcEccAnom(params.M, params.e);
-
- /* calculate the moon's distance (r) and true anomaly (v) */
- xv = params.a * ( cos(eccAnom) - params.e);
- yv = params.a * ( sqrt(1.0 - params.e*params.e) * sin(eccAnom));
- v =atan2(yv, xv);
- r = sqrt(xv*xv + yv*yv);
-
- /* estimate the geocentric rectangular coordinates here */
- xh = r * (cos (params.N) * cos (v + params.w) -
- sin (params.N) * sin (v + params.w) * cos (params.i));
- yh = r * (sin (params.N) * cos (v + params.w) +
- cos (params.N) * sin (v + params.w) * cos (params.i));
- zh = r * (sin(v + params.w) * sin(params.i));
-
- /* calculate the ecliptic latitude and longitude here */
- lonecl = atan2( yh, xh);
- latecl = atan2( zh, sqrt( xh*xh + yh*yh));
-
- /* calculate a number of perturbations, i.e. disturbances caused by
- * the gravitational influence of the sun and the other mayor
- * planets. The largest of these even have their own names */
- Ls = sunParams.M + sunParams.w;
- Lm = params.M + params.w + params.N;
- D = Lm - Ls;
- F = Lm - params.N;
-
- lonecl += DEG_TO_RAD * (
- - 1.274 * sin (params.M - 2*D) /* the Evection */
- + 0.658 * sin (2 * D) /* the Variation */
- - 0.186 * sin (sunParams.M) /* the yearly variation */
- - 0.059 * sin (2*params.M - 2*D)
- - 0.057 * sin (params.M - 2*D + sunParams.M)
- + 0.053 * sin (params.M + 2*D)
- + 0.046 * sin (2*D - sunParams.M)
- + 0.041 * sin (params.M - sunParams.M)
- - 0.035 * sin (D) /* the Parallactic Equation */
- - 0.031 * sin (params.M + sunParams.M)
- - 0.015 * sin (2*F - 2*D)
- + 0.011 * sin (params.M - 4*D)
- );
- latecl += DEG_TO_RAD * (
- - 0.173 * sin (F - 2*D)
- - 0.055 * sin (params.M - F - 2*D)
- - 0.046 * sin (params.M + F - 2*D)
- + 0.033 * sin (F + 2*D)
- + 0.017 * sin (2 * params.M + F)
- );
-
- r += (
- - 0.58 * cos(params.M - 2*D)
- - 0.46 * cos(2*D)
- );
-
- xg = r * cos(lonecl) * cos(latecl);
- yg = r * sin(lonecl) * cos(latecl);
- zg = r * sin(latecl);
-
- xe = xg;
- ye = yg * cos(ecl) - zg * sin(ecl);
- ze = yg * sin(ecl) + zg * cos(ecl);
-
-
-
-
- geocCoord.RightAscension = atan2(ye, xe);
- geocCoord.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
-
- /* New since 25 december 1997 */
- /* Calculate the moon's topocentric position instead of it's geocentric! */
-
- /* calculate the moon's parrallax, i.e. the apparent size of the
- * (equatorial) radius of the Earth, as seen from the moon */
- mpar = asin( 1 / r);
- gclat = FG_Latitude - 0.083358 * sin (2 * DEG_TO_RAD * FG_Latitude);
- rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * FG_Latitude);
-
- if (geocCoord.RightAscension < 0)
- geocCoord.RightAscension += (2*FG_PI);
-
- HA = t.lst - (3.8197186 * geocCoord.RightAscension);
-
- g = atan (tan(gclat) / cos( (HA / 3.8197186)));
-
-
-
- topocCoord.RightAscension = geocCoord.RightAscension -
- mpar * rho * cos (gclat) * sin (HA) / cos (geocCoord.Declination);
- topocCoord.Declination = geocCoord.Declination -
- mpar * rho * sin (gclat) * sin (g - geocCoord.Declination) / sin (g);
- return topocCoord;
-}
-
-
-void fgMoonInit( void ) {
- GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
- GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
-
- fgPrintf( FG_ASTRO, FG_INFO, "Initializing the Moon\n");
- fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
- moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
- cur_time_params);
- fgPrintf( FG_ASTRO, FG_DEBUG,
- "Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension,
- moonPos.Declination);
-
- xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
- yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
- zMoon = 60000.0 * sin(moonPos.Declination);
-
- if (moon) {
- xglDeleteLists (moon, 1);
- }
-
- moon = xglGenLists (1);
- xglNewList (moon, GL_COMPILE);
-
- xglMaterialfv (GL_FRONT, GL_AMBIENT, black);
- xglMaterialfv (GL_FRONT, GL_DIFFUSE, moonColor);
- xglPushMatrix ();
- xglTranslatef (xMoon, yMoon, zMoon);
- xglScalef (1400, 1400, 1400);
-
- glutSolidSphere (1.0, 10, 10);
- xglPopMatrix ();
- xglEndList ();
-}
-
-
-/* Draw the moon */
-void fgMoonRender( void ) {
- xglCallList(moon);
-}
-
-
-/* $Log$
-/* Revision 1.9 1998/04/18 04:13:56 curt
-/* Moved fg_debug.c to it's own library.
-/*
- * Revision 1.8 1998/04/03 21:52:49 curt
- * Converting to Gnu autoconf system.
- *
- * Revision 1.7 1998/02/23 19:07:54 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * 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/02/02 20:53:21 curt
- * To version 0.29
- *
- * Revision 1.4 1998/01/27 00:47:46 curt
- * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.3 1998/01/19 19:26:57 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:16 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:16 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.16 1998/01/06 01:20:24 curt
- * Tweaks to help building with MSVC++
- *
- * Revision 1.15 1998/01/05 18:44:35 curt
- * Add an option to advance/decrease time from keyboard.
- *
- * Revision 1.14 1997/12/30 20:47:50 curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.13 1997/12/30 16:41:00 curt
- * Added log at end of file.
- *
- */
--- /dev/null
+/**************************************************************************
+ * moon.c
+ * Written by Durk Talsma. Started October 1997, for the flight gear project.
+ *
+ * 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)
+ **************************************************************************/
+
+
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <math.h>
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <Aircraft/aircraft.h>
+#include <Debug/fg_debug.h>
+#include <Include/fg_constants.h>
+#include <Include/general.h>
+#include <Main/views.hxx>
+#include <Time/fg_time.h>
+
+#include "orbits.hxx"
+#include "moon.hxx"
+
+
+struct CelestialCoord moonPos;
+
+static float xMoon, yMoon, zMoon;
+static GLint moon = 0;
+
+
+
+/* --------------------------------------------------------------
+ This section contains the code that calculates the actual
+ position of the moon in the night sky.
+----------------------------------------------------------------*/
+struct CelestialCoord fgCalculateMoon(struct OrbElements params,
+ struct OrbElements sunParams,
+ struct fgTIME t)
+{
+ struct CelestialCoord
+ geocCoord, topocCoord;
+
+ double
+ eccAnom, ecl, lonecl, latecl, actTime,
+ xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
+ Ls, Lm, D, F, mpar, gclat, rho, HA, g;
+
+ fgAIRCRAFT *a;
+ fgFLIGHT *f;
+
+ a = ¤t_aircraft;
+ f = a->flight;
+
+ /* calculate the angle between ecliptic and equatorial coordinate
+ * system, in Radians */
+ actTime = fgCalcActTime(t);
+ ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
+ /*ecl = 0.409093 - 6.2186E-9 * actTime; */
+
+ /* calculate the eccentric anomaly */
+ eccAnom = fgCalcEccAnom(params.M, params.e);
+
+ /* calculate the moon's distance (r) and true anomaly (v) */
+ xv = params.a * ( cos(eccAnom) - params.e);
+ yv = params.a * ( sqrt(1.0 - params.e*params.e) * sin(eccAnom));
+ v =atan2(yv, xv);
+ r = sqrt(xv*xv + yv*yv);
+
+ /* estimate the geocentric rectangular coordinates here */
+ xh = r * (cos (params.N) * cos (v + params.w) -
+ sin (params.N) * sin (v + params.w) * cos (params.i));
+ yh = r * (sin (params.N) * cos (v + params.w) +
+ cos (params.N) * sin (v + params.w) * cos (params.i));
+ zh = r * (sin(v + params.w) * sin(params.i));
+
+ /* calculate the ecliptic latitude and longitude here */
+ lonecl = atan2( yh, xh);
+ latecl = atan2( zh, sqrt( xh*xh + yh*yh));
+
+ /* calculate a number of perturbations, i.e. disturbances caused by
+ * the gravitational influence of the sun and the other mayor
+ * planets. The largest of these even have their own names */
+ Ls = sunParams.M + sunParams.w;
+ Lm = params.M + params.w + params.N;
+ D = Lm - Ls;
+ F = Lm - params.N;
+
+ lonecl += DEG_TO_RAD * (
+ - 1.274 * sin (params.M - 2*D) /* the Evection */
+ + 0.658 * sin (2 * D) /* the Variation */
+ - 0.186 * sin (sunParams.M) /* the yearly variation */
+ - 0.059 * sin (2*params.M - 2*D)
+ - 0.057 * sin (params.M - 2*D + sunParams.M)
+ + 0.053 * sin (params.M + 2*D)
+ + 0.046 * sin (2*D - sunParams.M)
+ + 0.041 * sin (params.M - sunParams.M)
+ - 0.035 * sin (D) /* the Parallactic Equation */
+ - 0.031 * sin (params.M + sunParams.M)
+ - 0.015 * sin (2*F - 2*D)
+ + 0.011 * sin (params.M - 4*D)
+ );
+ latecl += DEG_TO_RAD * (
+ - 0.173 * sin (F - 2*D)
+ - 0.055 * sin (params.M - F - 2*D)
+ - 0.046 * sin (params.M + F - 2*D)
+ + 0.033 * sin (F + 2*D)
+ + 0.017 * sin (2 * params.M + F)
+ );
+
+ r += (
+ - 0.58 * cos(params.M - 2*D)
+ - 0.46 * cos(2*D)
+ );
+
+ xg = r * cos(lonecl) * cos(latecl);
+ yg = r * sin(lonecl) * cos(latecl);
+ zg = r * sin(latecl);
+
+ xe = xg;
+ ye = yg * cos(ecl) - zg * sin(ecl);
+ ze = yg * sin(ecl) + zg * cos(ecl);
+
+
+
+
+ geocCoord.RightAscension = atan2(ye, xe);
+ geocCoord.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
+
+ /* New since 25 december 1997 */
+ /* Calculate the moon's topocentric position instead of it's geocentric! */
+
+ /* calculate the moon's parrallax, i.e. the apparent size of the
+ * (equatorial) radius of the Earth, as seen from the moon */
+ mpar = asin( 1 / r);
+ gclat = FG_Latitude - 0.083358 * sin (2 * DEG_TO_RAD * FG_Latitude);
+ rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * FG_Latitude);
+
+ if (geocCoord.RightAscension < 0)
+ geocCoord.RightAscension += (2*FG_PI);
+
+ HA = t.lst - (3.8197186 * geocCoord.RightAscension);
+
+ g = atan (tan(gclat) / cos( (HA / 3.8197186)));
+
+
+
+ topocCoord.RightAscension = geocCoord.RightAscension -
+ mpar * rho * cos (gclat) * sin (HA) / cos (geocCoord.Declination);
+ topocCoord.Declination = geocCoord.Declination -
+ mpar * rho * sin (gclat) * sin (g - geocCoord.Declination) / sin (g);
+ return topocCoord;
+}
+
+
+void fgMoonInit( void ) {
+ GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
+ GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
+
+ fgPrintf( FG_ASTRO, FG_INFO, "Initializing the Moon\n");
+ fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
+ moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
+ cur_time_params);
+ fgPrintf( FG_ASTRO, FG_DEBUG,
+ "Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension,
+ moonPos.Declination);
+
+ xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
+ yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
+ zMoon = 60000.0 * sin(moonPos.Declination);
+
+ if (moon) {
+ xglDeleteLists (moon, 1);
+ }
+
+ moon = xglGenLists (1);
+ xglNewList (moon, GL_COMPILE);
+
+ xglMaterialfv (GL_FRONT, GL_AMBIENT, black);
+ xglMaterialfv (GL_FRONT, GL_DIFFUSE, moonColor);
+ xglPushMatrix ();
+ xglTranslatef (xMoon, yMoon, zMoon);
+ xglScalef (1400, 1400, 1400);
+
+ glutSolidSphere (1.0, 10, 10);
+ xglPopMatrix ();
+ xglEndList ();
+}
+
+
+/* Draw the moon */
+void fgMoonRender( void ) {
+ xglCallList(moon);
+}
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:28 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.9 1998/04/18 04:13:56 curt
+ * Moved fg_debug.c to it's own library.
+ *
+ * Revision 1.8 1998/04/03 21:52:49 curt
+ * Converting to Gnu autoconf system.
+ *
+ * Revision 1.7 1998/02/23 19:07:54 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * 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/02/02 20:53:21 curt
+ * To version 0.29
+ *
+ * Revision 1.4 1998/01/27 00:47:46 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.3 1998/01/19 19:26:57 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:16 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:16 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.16 1998/01/06 01:20:24 curt
+ * Tweaks to help building with MSVC++
+ *
+ * Revision 1.15 1998/01/05 18:44:35 curt
+ * Add an option to advance/decrease time from keyboard.
+ *
+ * Revision 1.14 1997/12/30 20:47:50 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.13 1997/12/30 16:41:00 curt
+ * Added log at end of file.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * moon.h
- *
- * Written 1997 by Durk Talsma, started October, 1997.
- *
- * 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 _MOON_H
-#define _MOON_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include <Astro/orbits.h>
-
-#include <Time/fg_time.h>
-#include <math.h>
-
-
-/* Initialize the Moon Display management Subsystem */
-void fgMoonInit( void );
-
-/* Draw the Moon */
-void fgMoonRender( void );
-
-struct CelestialCoord fgCalculateMoon(struct OrbElements Params,
- struct OrbElements sunParams,
- struct fgTIME t);
-
-extern struct OrbElements pltOrbElements[9];
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _MOON_H */
-
-
-/* $Log$
-/* Revision 1.7 1998/04/21 17:02:30 curt
-/* Prepairing for C++ integration.
-/*
- * Revision 1.6 1998/02/23 19:07:54 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.5 1998/02/02 20:53:21 curt
- * To version 0.29
- *
- * Revision 1.4 1998/01/22 02:59:27 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.3 1998/01/19 19:26:58 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:16 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.4 1997/12/11 04:43:56 curt
- * Fixed sun vector and lighting problems. I thing the moon is now lit
- * correctly.
- *
- * Revision 1.3 1997/11/25 19:25:35 curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.2 1997/10/25 03:24:23 curt
- * Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
- *
- * Revision 1.1 1997/10/25 03:16:09 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
--- /dev/null
+/**************************************************************************
+ * moon.h
+ *
+ * Written 1997 by Durk Talsma, started October, 1997.
+ *
+ * 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 _MOON_HXX
+#define _MOON_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+#include <math.h>
+
+#include <Time/fg_time.h>
+
+#include "orbits.hxx"
+
+
+/* Initialize the Moon Display management Subsystem */
+void fgMoonInit( void );
+
+/* Draw the Moon */
+void fgMoonRender( void );
+
+struct CelestialCoord fgCalculateMoon(struct OrbElements Params,
+ struct OrbElements sunParams,
+ struct fgTIME t);
+
+extern struct OrbElements pltOrbElements[9];
+
+
+#endif /* _MOON_HXX */
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:28 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.7 1998/04/21 17:02:30 curt
+ * Prepairing for C++ integration.
+ *
+ * Revision 1.6 1998/02/23 19:07:54 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * Revision 1.5 1998/02/02 20:53:21 curt
+ * To version 0.29
+ *
+ * Revision 1.4 1998/01/22 02:59:27 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.3 1998/01/19 19:26:58 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:16 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.4 1997/12/11 04:43:56 curt
+ * Fixed sun vector and lighting problems. I thing the moon is now lit
+ * correctly.
+ *
+ * Revision 1.3 1997/11/25 19:25:35 curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
+ * Revision 1.2 1997/10/25 03:24:23 curt
+ * Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
+ *
+ * Revision 1.1 1997/10/25 03:16:09 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * orbits.c - calculates the orbital elements of the sun, moon and planets.
- * For inclusion in flight gear
- *
- * Written 1997 by Durk Talsma, started October 19, 1997.
- *
- * 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)
- **************************************************************************/
-
-
-#include <math.h>
-#include <string.h>
-
-#include <Astro/orbits.h>
-
-#include <Debug/fg_debug.h>
-#include <Include/fg_constants.h>
-#include <Include/general.h>
-#include <Time/fg_time.h>
-
-struct OrbElements pltOrbElements[9];
-
-
-double fgCalcActTime(struct fgTIME t)
-{
- return (t.mjd - 36523.5);
-}
-
-
-double fgCalcEccAnom(double M, double e)
-{
- double
- eccAnom, E0, E1, diff;
-
- eccAnom = M + e * sin(M) * (1.0 + e * cos(M));
- /* iterate to achieve a greater precision for larger eccentricities */
- if (e > 0.05)
- {
- E0 = eccAnom;
- do
- {
- E1 = E0 - (E0 - e * sin(E0) - M) / (1 - e * cos(E0));
- diff = fabs(E0 - E1);
- E0 = E1;
- }
- while (diff > (DEG_TO_RAD * 0.001));
- return E0;
- }
- return eccAnom;
-}
-
-
-/* This function assumes that if the FILE ptr is valid that the
- contents will be valid. Should we check the file for validity? */
-
-/* Sounds like a good idea to me. What type of checks are you thinking
- of, other than feof(FILE*)? That's currently the only check I can
- think of (Durk) */
-
-int fgReadOrbElements(struct OrbElements *dest, FILE *src)
-{
- char line[256];
- int i,j;
- j = 0;
- do
- {
- if (feof (src)) {
- fgPrintf (FG_ASTRO, FG_ALERT,
- "End of file found while reading planetary positions:\n");
- return 0;
- }
-
- fgets(line, 256,src);
- for (i = 0; i < 256; i++)
- {
- if (line[i] == '#')
- line[i] = 0;
- }
- /*printf("Reading line %d\n", j++); */
- }
- while (!(strlen(line)));
- sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n",
- &dest->NFirst, &dest->NSec,
- &dest->iFirst, &dest->iSec,
- &dest->wFirst, &dest->wSec,
- &dest->aFirst, &dest->aSec,
- &dest->eFirst, &dest->eSec,
- &dest->MFirst, &dest->MSec);
-
- return(1);
-}
-
-
-int fgSolarSystemInit(struct fgTIME t)
-{
- fgGENERAL *g;
- char path[80];
- int i;
- FILE *data;
- int ret_val = 0;
-
- fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
-
- /* build the full path name to the orbital elements database file */
- g = &general;
- path[0] = '\0';
- strcat(path, g->root_dir);
- strcat(path, "/Scenery/");
- strcat(path, "Planets.dat");
-
- if ( (data = fopen(path, "r")) == NULL )
- {
- fgPrintf( FG_ASTRO, FG_ALERT,
- "Cannot open data file: '%s'\n", path);
- } else {
- /* printf(" reading datafile %s\n", path); */
- fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
-
- /* for all the objects... */
- for (i = 0; i < 9; i ++)
- {
- /* ...read from the data file ... */
- if (!(fgReadOrbElements (&pltOrbElements[i], data))) {
- ret_val = 0;
- }
- /* ...and calculate the actual values */
- fgSolarSystemUpdate(&pltOrbElements[i], t);
- }
- ret_val = 1;
- }
- return ret_val;
-}
-
-
-void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
-{
- double
- actTime;
-
- actTime = fgCalcActTime(t);
-
- /* calculate the actual orbital elements */
- planet->M = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime));
- planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime));
- planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime));
- planet->i = DEG_TO_RAD * (planet->iFirst + (planet->iSec * actTime));
- planet->e = planet->eFirst + (planet->eSec * actTime);
- planet->a = planet->aFirst + (planet->aSec * actTime);
-}
-
-
-/* $Log$
-/* Revision 1.10 1998/04/18 04:13:57 curt
-/* Moved fg_debug.c to it's own library.
-/*
- * Revision 1.9 1998/03/14 00:27:12 curt
- * Updated fgGENERAL to a "type" of struct.
- *
- * Revision 1.8 1998/02/23 19:07:55 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.7 1998/02/12 21:59:33 curt
- * Incorporated code changes contributed by Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.6 1998/02/03 23:20:11 curt
- * Lots of little tweaks to fix various consistency problems discovered by
- * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
- * passed arguments along to the real printf(). Also incorporated HUD changes
- * by Michele America.
- *
- * Revision 1.5 1998/02/02 20:53:22 curt
- * To version 0.29
- *
- * Revision 1.4 1998/01/27 00:47:47 curt
- * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.3 1998/01/22 02:59:27 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.2 1998/01/19 19:26:58 curt
- * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
- * This should simplify things tremendously.
- *
- * Revision 1.1 1998/01/07 03:16:17 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.6 1997/12/30 20:47:52 curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.5 1997/12/15 23:55:02 curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.4 1997/12/10 22:37:51 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.3 1997/11/25 23:20:44 curt
- * Changed planets.dat Planets.dat
- *
- * Revision 1.2 1997/11/25 19:25:36 curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.1 1997/10/25 03:16:10 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
--- /dev/null
+/**************************************************************************
+ * orbits.c - calculates the orbital elements of the sun, moon and planets.
+ * For inclusion in flight gear
+ *
+ * Written 1997 by Durk Talsma, started October 19, 1997.
+ *
+ * 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)
+ **************************************************************************/
+
+
+#include <config.h>
+
+#include <math.h>
+#include <string.h>
+
+#include <Debug/fg_debug.h>
+#include <Include/fg_constants.h>
+#include <Include/general.h>
+#include <Time/fg_time.h>
+
+#include "orbits.hxx"
+
+
+struct OrbElements pltOrbElements[9];
+
+
+double fgCalcActTime(struct fgTIME t)
+{
+ return (t.mjd - 36523.5);
+}
+
+
+double fgCalcEccAnom(double M, double e)
+{
+ double
+ eccAnom, E0, E1, diff;
+
+ eccAnom = M + e * sin(M) * (1.0 + e * cos(M));
+ /* iterate to achieve a greater precision for larger eccentricities */
+ if (e > 0.05)
+ {
+ E0 = eccAnom;
+ do
+ {
+ E1 = E0 - (E0 - e * sin(E0) - M) / (1 - e * cos(E0));
+ diff = fabs(E0 - E1);
+ E0 = E1;
+ }
+ while (diff > (DEG_TO_RAD * 0.001));
+ return E0;
+ }
+ return eccAnom;
+}
+
+
+/* This function assumes that if the FILE ptr is valid that the
+ contents will be valid. Should we check the file for validity? */
+
+/* Sounds like a good idea to me. What type of checks are you thinking
+ of, other than feof(FILE*)? That's currently the only check I can
+ think of (Durk) */
+
+int fgReadOrbElements(struct OrbElements *dest, FILE *src)
+{
+ char line[256];
+ int i,j;
+ j = 0;
+ do
+ {
+ if (feof (src)) {
+ fgPrintf (FG_ASTRO, FG_ALERT,
+ "End of file found while reading planetary positions:\n");
+ return 0;
+ }
+
+ fgets(line, 256,src);
+ for (i = 0; i < 256; i++)
+ {
+ if (line[i] == '#')
+ line[i] = 0;
+ }
+ /*printf("Reading line %d\n", j++); */
+ }
+ while (!(strlen(line)));
+ sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n",
+ &dest->NFirst, &dest->NSec,
+ &dest->iFirst, &dest->iSec,
+ &dest->wFirst, &dest->wSec,
+ &dest->aFirst, &dest->aSec,
+ &dest->eFirst, &dest->eSec,
+ &dest->MFirst, &dest->MSec);
+
+ return(1);
+}
+
+
+int fgSolarSystemInit(struct fgTIME t)
+{
+ fgGENERAL *g;
+ char path[80];
+ int i;
+ FILE *data;
+ int ret_val = 0;
+
+ fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
+
+ /* build the full path name to the orbital elements database file */
+ g = &general;
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Scenery/");
+ strcat(path, "Planets.dat");
+
+ if ( (data = fopen(path, "r")) == NULL )
+ {
+ fgPrintf( FG_ASTRO, FG_ALERT,
+ "Cannot open data file: '%s'\n", path);
+ } else {
+ /* printf(" reading datafile %s\n", path); */
+ fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
+
+ /* for all the objects... */
+ for (i = 0; i < 9; i ++)
+ {
+ /* ...read from the data file ... */
+ if (!(fgReadOrbElements (&pltOrbElements[i], data))) {
+ ret_val = 0;
+ }
+ /* ...and calculate the actual values */
+ fgSolarSystemUpdate(&pltOrbElements[i], t);
+ }
+ ret_val = 1;
+ }
+ return ret_val;
+}
+
+
+void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
+{
+ double
+ actTime;
+
+ actTime = fgCalcActTime(t);
+
+ /* calculate the actual orbital elements */
+ planet->M = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime));
+ planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime));
+ planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime));
+ planet->i = DEG_TO_RAD * (planet->iFirst + (planet->iSec * actTime));
+ planet->e = planet->eFirst + (planet->eSec * actTime);
+ planet->a = planet->aFirst + (planet->aSec * actTime);
+}
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:29 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.10 1998/04/18 04:13:57 curt
+ * Moved fg_debug.c to it's own library.
+ *
+ * Revision 1.9 1998/03/14 00:27:12 curt
+ * Updated fgGENERAL to a "type" of struct.
+ *
+ * Revision 1.8 1998/02/23 19:07:55 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * Revision 1.7 1998/02/12 21:59:33 curt
+ * Incorporated code changes contributed by Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.6 1998/02/03 23:20:11 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
+ * Revision 1.5 1998/02/02 20:53:22 curt
+ * To version 0.29
+ *
+ * Revision 1.4 1998/01/27 00:47:47 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.3 1998/01/22 02:59:27 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.2 1998/01/19 19:26:58 curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
+ * Revision 1.1 1998/01/07 03:16:17 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.6 1997/12/30 20:47:52 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.5 1997/12/15 23:55:02 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
+ * Revision 1.4 1997/12/10 22:37:51 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.3 1997/11/25 23:20:44 curt
+ * Changed planets.dat Planets.dat
+ *
+ * Revision 1.2 1997/11/25 19:25:36 curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
+ * Revision 1.1 1997/10/25 03:16:10 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * orbits.h - calculates the orbital elements of the sun, moon and planets.
- * For inclusion in flight gear
- *
- * Written 1997 by Durk Talsma, started October 19, 1997.
- *
- * 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 _ORBITS_H
-#define _ORBITS_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include <stdio.h>
-#include <math.h>
-
-#include <Time/fg_time.h>
-
-
-
-//#define STANDARDEPOCH 2000
-
-typedef struct {
- double xs;
- double ys;
- double dist;
- double lonSun;
-} fgSUNPOS;
-
-extern fgSUNPOS solarPosition;
-
-
-struct OrbElements {
- double NFirst; /* longitude of the ascending node first part */
- double NSec; /* longitude of the ascending node second part */
- double iFirst; /* inclination to the ecliptic first part */
- double iSec; /* inclination to the ecliptic second part */
- double wFirst; /* first part of argument of perihelion */
- double wSec; /* second part of argument of perihelion */
- double aFirst; /* semimayor axis first part*/
- double aSec; /* semimayor axis second part */
- double eFirst; /* eccentricity first part */
- double eSec; /* eccentricity second part */
- double MFirst; /* Mean anomaly first part */
- double MSec; /* Mean anomaly second part */
-
- double N, i, w, a, e, M; /* the resultant orbital elements, obtained from the former */
-};
-
-struct CelestialCoord {
- double RightAscension;
- double Declination;
- double distance;
- double magnitude;
-};
-
-
-double fgCalcEccAnom(double M, double e);
-double fgCalcActTime(struct fgTIME t);
-
-int fgReadOrbElements (struct OrbElements *dest, FILE * src);
-int fgSolarSystemInit(struct fgTIME t);
-void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _ORBITS_H */
-
-
-/* $Log$
-/* Revision 1.7 1998/04/21 17:02:31 curt
-/* Prepairing for C++ integration.
-/*
- * Revision 1.6 1998/02/23 19:07:55 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.5 1998/02/12 21:59:35 curt
- * Incorporated code changes contributed by Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.4 1998/02/02 20:53:22 curt
- * To version 0.29
- *
- * Revision 1.3 1998/01/22 02:59:27 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.2 1998/01/19 19:26:58 curt
- * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
- * This should simplify things tremendously.
- *
- * Revision 1.1 1998/01/07 03:16:17 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.2 1997/12/30 16:36:52 curt
- * Merged in Durk's changes ...
- *
- * Revision 1.1 1997/10/25 03:16:10 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
--- /dev/null
+/**************************************************************************
+ * orbits.h - calculates the orbital elements of the sun, moon and planets.
+ * For inclusion in flight gear
+ *
+ * Written 1997 by Durk Talsma, started October 19, 1997.
+ *
+ * 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 _ORBITS_HXX
+#define _ORBITS_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+#include <stdio.h>
+#include <math.h>
+
+#include <Time/fg_time.h>
+
+
+
+//#define STANDARDEPOCH 2000
+
+typedef struct {
+ double xs;
+ double ys;
+ double dist;
+ double lonSun;
+} fgSUNPOS;
+
+extern fgSUNPOS solarPosition;
+
+
+struct OrbElements {
+ double NFirst; /* longitude of the ascending node first part */
+ double NSec; /* longitude of the ascending node second part */
+ double iFirst; /* inclination to the ecliptic first part */
+ double iSec; /* inclination to the ecliptic second part */
+ double wFirst; /* first part of argument of perihelion */
+ double wSec; /* second part of argument of perihelion */
+ double aFirst; /* semimayor axis first part*/
+ double aSec; /* semimayor axis second part */
+ double eFirst; /* eccentricity first part */
+ double eSec; /* eccentricity second part */
+ double MFirst; /* Mean anomaly first part */
+ double MSec; /* Mean anomaly second part */
+
+ double N, i, w, a, e, M; /* the resultant orbital elements, obtained from the former */
+};
+
+struct CelestialCoord {
+ double RightAscension;
+ double Declination;
+ double distance;
+ double magnitude;
+};
+
+
+double fgCalcEccAnom(double M, double e);
+double fgCalcActTime(struct fgTIME t);
+
+int fgReadOrbElements (struct OrbElements *dest, FILE * src);
+int fgSolarSystemInit(struct fgTIME t);
+void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
+
+
+#endif /* _ORBITS_HXX */
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:30 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.7 1998/04/21 17:02:31 curt
+ * Prepairing for C++ integration.
+ *
+ * Revision 1.6 1998/02/23 19:07:55 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * Revision 1.5 1998/02/12 21:59:35 curt
+ * Incorporated code changes contributed by Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.4 1998/02/02 20:53:22 curt
+ * To version 0.29
+ *
+ * Revision 1.3 1998/01/22 02:59:27 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.2 1998/01/19 19:26:58 curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
+ * Revision 1.1 1998/01/07 03:16:17 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.2 1997/12/30 16:36:52 curt
+ * Merged in Durk's changes ...
+ *
+ * Revision 1.1 1997/10/25 03:16:10 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * planets.c
- *
- * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
- * project.
- *
- * 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)
- **************************************************************************/
-
-
-#include <config.h>
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Astro/orbits.h>
-#include <Astro/planets.h>
-#include <Astro/sun.h>
-#include <Debug/fg_debug.h>
-#include <Include/fg_constants.h>
-#include <Time/fg_time.h>
-
-GLint planets = 0;
-
-struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
- struct OrbElements theSun,
- struct fgTIME t, int idx)
-{
- struct CelestialCoord result;
-
- fgSUNPOS SolarPosition;
-
- double eccAnom, r, v, ecl, actTime, R, s, ir, Nr, B, FV, ring_magn,
- xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
-
- actTime = fgCalcActTime(t);
- /*calculate the angle between ecliptic and equatorial coordinate system */
- ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime);
-
- /* calculate the eccentric anomaly */
- eccAnom = fgCalcEccAnom(planet.M, planet.e);
-
- /* calculate the planets distance (r) and true anomaly (v) */
- xv = planet.a * (cos(eccAnom) - planet.e);
- yv = planet.a * (sqrt(1.0 - planet.e*planet.e) * sin(eccAnom));
- v = atan2(yv, xv);
- r = sqrt ( xv*xv + yv*yv);
-
- /* calculate the planets position in 3-dimensional space */
- xh = r * (cos (planet.N) * cos (v + planet.w) -
- sin (planet.N) * sin (v + planet.w) * cos (planet.i));
- yh = r * (sin (planet.N) * cos (v + planet.w) +
- cos (planet.N) * sin (v + planet.w) * cos (planet.i));
- zh = r * ( sin(v+planet.w) * sin(planet.i));
-
- /* calculate the ecliptic longitude and latitude */
-
- xg = xh + solarPosition.xs;
- yg = yh + solarPosition.ys;
- zg = zh;
-
- xe = xg;
- ye = yg * cos(ecl) - zg * sin(ecl);
- ze = yg * sin(ecl) + zg * cos(ecl);
-
- result.RightAscension = atan2(ye,xe);
- result.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
-
- /* Let's calculate the brightness of the planet */
- R = sqrt ( xg*xg + yg*yg + zg*zg);
- s = SolarPosition.dist;
- FV = acos( (r*r + R*R - s*s) / (2*r*R));
- FV *= 57.29578; /* convert radians to degrees */
- switch(idx)
- {
- case 2: /* mercury */
- result.magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
- break;
- case 3: /*venus */
- result.magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
- break;
- case 4: /* mars */
- result.magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
- break;
- case 5: /* Jupiter */
- result.magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
- break;
- case 6: /* Saturn */
-
- ir = 0.4897394;
- Nr = 2.9585076 + 6.6672E-7*actTime;
-
- B = asin (sin (result.Declination) * cos (ir) -
- cos (result.Declination) * sin (ir) *
- sin (result.RightAscension - Nr));
- ring_magn = -2.6 * sin (fabs(B)) + 1.2 * pow(sin(B),2);
- result.magnitude = -9.0 + 5*log10( r*R ) + 0.044 * FV + ring_magn;
- break;
- case 7: /* Uranus */
- result.magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
- break;
- case 8: /* Neptune */
- result.magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
- break;
- default:
- fgPrintf( FG_ASTRO, FG_ALERT, "index %d out of range !!!!\n", idx);
- }
- fgPrintf( FG_ASTRO, FG_DEBUG,
- " Planet found at %f (ra), %f (dec)\n",
- result.RightAscension, result.Declination);
- fgPrintf( FG_ASTRO, FG_DEBUG,
- " Geocentric dist %f\n"
- " Heliocentric dist %f\n"
- " Distance to the sun %f\n"
- " Phase angle %f\n"
- " Brightness %f\n", R, r, s, FV, result.magnitude);
- return result;
-}
-
-
-void fgPlanetsInit( void )
-{
- struct fgLIGHT *l;
- int i;
- struct CelestialCoord pltPos;
- double magnitude;
-
- l = &cur_light_params;
- /* if the display list was already built during a previous init,
- then recycle it */
-
- if (planets) {
- xglDeleteLists(planets, 1);
- }
-
- planets = xglGenLists(1);
- xglNewList( planets, GL_COMPILE );
- xglBegin( GL_POINTS );
-
-
- /* Add the planets to all four display lists */
- for ( i = 2; i < 9; i++ ) {
- fgSolarSystemUpdate(&(pltOrbElements[i]), cur_time_params);
- pltPos = fgCalculatePlanet(pltOrbElements[i],
- pltOrbElements[0], cur_time_params, i);
-
- magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
-
- /* scale magnitudes again so they look ok */
- /* magnitude =
- magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1); */
-
- /* the following statement could be made a little more sopisticated
- for the moment: Stick to this one */
- magnitude = magnitude * 0.7 + (3 * 0.1);
- if ( magnitude > 1.0 ) { magnitude = 1.0; }
- if ( magnitude < 0.0 ) { magnitude = 0.0; }
-
- /* Add planets to the display list, based on sun_angle and current
- magnitude It's pretty experimental... */
-
- if ((double) (l->sun_angle - FG_PI_2) >
- ((magnitude - 1.0) * -20 * DEG_TO_RAD))
- {
- xglColor3f (magnitude, magnitude, magnitude);
- printf ("Sun Angle to Horizon (in Rads) = %f\n",
- (double) (l->sun_angle - FG_PI_2));
- printf ("Transformed Magnitude is :%f %f\n",
- magnitude, (magnitude - 1.0) * -20 * DEG_TO_RAD);
-
- xglVertex3f (50000.0 * cos (pltPos.RightAscension) *
- cos (pltPos.Declination),
- 50000.0 * sin (pltPos.RightAscension) *
- cos (pltPos.Declination),
- 50000.0 * sin (pltPos.Declination));
- }
- }
- xglEnd();
- xglEndList();
-
-}
-
-
-void fgPlanetsRender( void ) {
- xglCallList(planets);
-}
-
-
-/* $Log$
-/* Revision 1.9 1998/04/18 04:13:57 curt
-/* Moved fg_debug.c to it's own library.
-/*
- * Revision 1.8 1998/04/03 21:52:50 curt
- * Converting to Gnu autoconf system.
- *
- * Revision 1.7 1998/02/23 19:07:55 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.6 1998/02/12 21:59:36 curt
- * Incorporated code changes contributed by Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.5 1998/02/03 23:20:12 curt
- * Lots of little tweaks to fix various consistency problems discovered by
- * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
- * passed arguments along to the real printf(). Also incorporated HUD changes
- * by Michele America.
- *
- * Revision 1.4 1998/02/02 20:53:23 curt
- * To version 0.29
- *
- * Revision 1.3 1998/01/27 00:47:47 curt
- * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.2 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.1 1998/01/07 03:16:18 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.4 1997/12/30 20:47:52 curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.3 1997/12/30 16:36:52 curt
- * Merged in Durk's changes ...
- *
- * Revision 1.2 1997/12/12 21:41:29 curt
- * More light/material property tweaking ... still a ways off.
- *
- * Revision 1.1 1997/10/25 03:16:10 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
-
-
--- /dev/null
+/**************************************************************************
+ * planets.c
+ *
+ * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
+ * project.
+ *
+ * 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)
+ **************************************************************************/
+
+
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <Debug/fg_debug.h>
+#include <Include/fg_constants.h>
+#include <Time/fg_time.h>
+#include <Time/light.hxx>
+
+#include "orbits.hxx"
+#include "planets.hxx"
+#include "sun.hxx"
+
+GLint planets = 0;
+
+struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
+ struct OrbElements theSun,
+ struct fgTIME t, int idx)
+{
+ struct CelestialCoord result;
+
+ fgSUNPOS SolarPosition;
+
+ double eccAnom, r, v, ecl, actTime, R, s, ir, Nr, B, FV, ring_magn,
+ xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
+
+ actTime = fgCalcActTime(t);
+ /*calculate the angle between ecliptic and equatorial coordinate system */
+ ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime);
+
+ /* calculate the eccentric anomaly */
+ eccAnom = fgCalcEccAnom(planet.M, planet.e);
+
+ /* calculate the planets distance (r) and true anomaly (v) */
+ xv = planet.a * (cos(eccAnom) - planet.e);
+ yv = planet.a * (sqrt(1.0 - planet.e*planet.e) * sin(eccAnom));
+ v = atan2(yv, xv);
+ r = sqrt ( xv*xv + yv*yv);
+
+ /* calculate the planets position in 3-dimensional space */
+ xh = r * (cos (planet.N) * cos (v + planet.w) -
+ sin (planet.N) * sin (v + planet.w) * cos (planet.i));
+ yh = r * (sin (planet.N) * cos (v + planet.w) +
+ cos (planet.N) * sin (v + planet.w) * cos (planet.i));
+ zh = r * ( sin(v+planet.w) * sin(planet.i));
+
+ /* calculate the ecliptic longitude and latitude */
+
+ xg = xh + solarPosition.xs;
+ yg = yh + solarPosition.ys;
+ zg = zh;
+
+ xe = xg;
+ ye = yg * cos(ecl) - zg * sin(ecl);
+ ze = yg * sin(ecl) + zg * cos(ecl);
+
+ result.RightAscension = atan2(ye,xe);
+ result.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
+
+ /* Let's calculate the brightness of the planet */
+ R = sqrt ( xg*xg + yg*yg + zg*zg);
+ s = SolarPosition.dist;
+ FV = acos( (r*r + R*R - s*s) / (2*r*R));
+ FV *= 57.29578; /* convert radians to degrees */
+ switch(idx)
+ {
+ case 2: /* mercury */
+ result.magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
+ break;
+ case 3: /*venus */
+ result.magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
+ break;
+ case 4: /* mars */
+ result.magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
+ break;
+ case 5: /* Jupiter */
+ result.magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
+ break;
+ case 6: /* Saturn */
+
+ ir = 0.4897394;
+ Nr = 2.9585076 + 6.6672E-7*actTime;
+
+ B = asin (sin (result.Declination) * cos (ir) -
+ cos (result.Declination) * sin (ir) *
+ sin (result.RightAscension - Nr));
+ ring_magn = -2.6 * sin (fabs(B)) + 1.2 * pow(sin(B),2);
+ result.magnitude = -9.0 + 5*log10( r*R ) + 0.044 * FV + ring_magn;
+ break;
+ case 7: /* Uranus */
+ result.magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
+ break;
+ case 8: /* Neptune */
+ result.magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
+ break;
+ default:
+ fgPrintf( FG_ASTRO, FG_ALERT, "index %d out of range !!!!\n", idx);
+ }
+ fgPrintf( FG_ASTRO, FG_DEBUG,
+ " Planet found at %f (ra), %f (dec)\n",
+ result.RightAscension, result.Declination);
+ fgPrintf( FG_ASTRO, FG_DEBUG,
+ " Geocentric dist %f\n"
+ " Heliocentric dist %f\n"
+ " Distance to the sun %f\n"
+ " Phase angle %f\n"
+ " Brightness %f\n", R, r, s, FV, result.magnitude);
+ return result;
+}
+
+
+void fgPlanetsInit( void )
+{
+ struct fgLIGHT *l;
+ int i;
+ struct CelestialCoord pltPos;
+ double magnitude;
+
+ l = &cur_light_params;
+ /* if the display list was already built during a previous init,
+ then recycle it */
+
+ if (planets) {
+ xglDeleteLists(planets, 1);
+ }
+
+ planets = xglGenLists(1);
+ xglNewList( planets, GL_COMPILE );
+ xglBegin( GL_POINTS );
+
+
+ /* Add the planets to all four display lists */
+ for ( i = 2; i < 9; i++ ) {
+ fgSolarSystemUpdate(&(pltOrbElements[i]), cur_time_params);
+ pltPos = fgCalculatePlanet(pltOrbElements[i],
+ pltOrbElements[0], cur_time_params, i);
+
+ magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
+
+ /* scale magnitudes again so they look ok */
+ /* magnitude =
+ magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1); */
+
+ /* the following statement could be made a little more sopisticated
+ for the moment: Stick to this one */
+ magnitude = magnitude * 0.7 + (3 * 0.1);
+ if ( magnitude > 1.0 ) { magnitude = 1.0; }
+ if ( magnitude < 0.0 ) { magnitude = 0.0; }
+
+ /* Add planets to the display list, based on sun_angle and current
+ magnitude It's pretty experimental... */
+
+ if ((double) (l->sun_angle - FG_PI_2) >
+ ((magnitude - 1.0) * -20 * DEG_TO_RAD))
+ {
+ xglColor3f (magnitude, magnitude, magnitude);
+ printf ("Sun Angle to Horizon (in Rads) = %f\n",
+ (double) (l->sun_angle - FG_PI_2));
+ printf ("Transformed Magnitude is :%f %f\n",
+ magnitude, (magnitude - 1.0) * -20 * DEG_TO_RAD);
+
+ xglVertex3f (50000.0 * cos (pltPos.RightAscension) *
+ cos (pltPos.Declination),
+ 50000.0 * sin (pltPos.RightAscension) *
+ cos (pltPos.Declination),
+ 50000.0 * sin (pltPos.Declination));
+ }
+ }
+ xglEnd();
+ xglEndList();
+
+}
+
+
+void fgPlanetsRender( void ) {
+ xglCallList(planets);
+}
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:31 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.9 1998/04/18 04:13:57 curt
+ * Moved fg_debug.c to it's own library.
+ *
+ * Revision 1.8 1998/04/03 21:52:50 curt
+ * Converting to Gnu autoconf system.
+ *
+ * Revision 1.7 1998/02/23 19:07:55 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * Revision 1.6 1998/02/12 21:59:36 curt
+ * Incorporated code changes contributed by Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.5 1998/02/03 23:20:12 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
+ * Revision 1.4 1998/02/02 20:53:23 curt
+ * To version 0.29
+ *
+ * Revision 1.3 1998/01/27 00:47:47 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.2 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.1 1998/01/07 03:16:18 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.4 1997/12/30 20:47:52 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.3 1997/12/30 16:36:52 curt
+ * Merged in Durk's changes ...
+ *
+ * Revision 1.2 1997/12/12 21:41:29 curt
+ * More light/material property tweaking ... still a ways off.
+ *
+ * Revision 1.1 1997/10/25 03:16:10 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */
+
+
+++ /dev/null
-/**************************************************************************
- * planets.h
- *
- * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
- * project.
- *
- * 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 _PLANETS_H
-#define _PLANETS_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
- struct OrbElements theSun,
- struct fgTIME t, int idx);
-
-
-void fgPlanetsInit( void );
-void fgPlanetsRender( void );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* PLANETS_H */
-
-
-/* $Log$
-/* Revision 1.5 1998/04/21 17:02:31 curt
-/* Prepairing for C++ integration.
-/*
- * Revision 1.4 1998/02/12 21:59:38 curt
- * Incorporated code changes contributed by Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.3 1998/02/02 20:53:23 curt
- * To version 0.29
- *
- * Revision 1.2 1998/01/22 02:59:28 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.1 1998/01/07 03:16:18 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.3 1997/12/30 16:36:53 curt
- * Merged in Durk's changes ...
- *
- * Revision 1.2 1997/12/12 21:41:30 curt
- * More light/material property tweaking ... still a ways off.
- *
- * Revision 1.1 1997/10/25 03:16:11 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
--- /dev/null
+/**************************************************************************
+ * planets.hxx
+ *
+ * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
+ * project.
+ *
+ * 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 _PLANETS_HXX
+#define _PLANETS_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
+ struct OrbElements theSun,
+ struct fgTIME t, int idx);
+
+
+void fgPlanetsInit( void );
+void fgPlanetsRender( void );
+
+
+#endif /* PLANETS_HXX */
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:32 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.5 1998/04/21 17:02:31 curt
+ * Prepairing for C++ integration.
+ *
+ * Revision 1.4 1998/02/12 21:59:38 curt
+ * Incorporated code changes contributed by Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.3 1998/02/02 20:53:23 curt
+ * To version 0.29
+ *
+ * Revision 1.2 1998/01/22 02:59:28 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.1 1998/01/07 03:16:18 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.3 1997/12/30 16:36:53 curt
+ * Merged in Durk's changes ...
+ *
+ * Revision 1.2 1997/12/12 21:41:30 curt
+ * More light/material property tweaking ... still a ways off.
+ *
+ * Revision 1.1 1997/10/25 03:16:11 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * sky.c -- model sky with an upside down "bowl"
- *
- * Written by Curtis Olson, started December 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * 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)
- **************************************************************************/
-
-
-#include <config.h>
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <math.h>
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Astro/sky.h>
-
-#include <Time/event.h>
-#include <Time/fg_time.h>
-
-#include <Aircraft/aircraft.h>
-#include <Flight/flight.h>
-#include <Include/fg_constants.h>
-#include <Main/views.h>
-#include <Math/fg_random.h>
-
-/*
-#include <Include/general.h>
-*/
-
-/* in meters of course */
-#define CENTER_ELEV 25000.0
-
-#define INNER_RADIUS 50000.0
-#define INNER_ELEV 20000.0
-
-#define MIDDLE_RADIUS 70000.0
-#define MIDDLE_ELEV 8000.0
-
-#define OUTER_RADIUS 80000.0
-#define OUTER_ELEV 0.0
-
-#define BOTTOM_RADIUS 50000.0
-#define BOTTOM_ELEV -2000.0
-
-
-static float inner_vertex[12][3];
-static float middle_vertex[12][3];
-static float outer_vertex[12][3];
-static float bottom_vertex[12][3];
-
-static float inner_color[12][4];
-static float middle_color[12][4];
-static float outer_color[12][4];
-
-
-/* Calculate the sky structure vertices */
-void fgSkyVerticesInit( void ) {
- float theta;
- int i;
-
- printf(" Generating the sky dome vertices.\n");
-
- for ( i = 0; i < 12; i++ ) {
- theta = (i * 30.0) * DEG_TO_RAD;
-
- inner_vertex[i][0] = cos(theta) * INNER_RADIUS;
- inner_vertex[i][1] = sin(theta) * INNER_RADIUS;
- inner_vertex[i][2] = INNER_ELEV;
-
- /* printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
- sin(theta) * INNER_RADIUS); */
-
- middle_vertex[i][0] = cos((double)theta) * MIDDLE_RADIUS;
- middle_vertex[i][1] = sin((double)theta) * MIDDLE_RADIUS;
- middle_vertex[i][2] = MIDDLE_ELEV;
-
- outer_vertex[i][0] = cos((double)theta) * OUTER_RADIUS;
- outer_vertex[i][1] = sin((double)theta) * OUTER_RADIUS;
- outer_vertex[i][2] = OUTER_ELEV;
-
- bottom_vertex[i][0] = cos((double)theta) * BOTTOM_RADIUS;
- bottom_vertex[i][1] = sin((double)theta) * BOTTOM_RADIUS;
- bottom_vertex[i][2] = BOTTOM_ELEV;
- }
-}
-
-
-/* (Re)calculate the sky colors at each vertex */
-void fgSkyColorsInit( void ) {
- struct fgLIGHT *l;
- float sun_angle, diff;
- float outer_param[3], outer_amt[3], outer_diff[3];
- float middle_param[3], middle_amt[3], middle_diff[3];
- int i, j;
-
- l = &cur_light_params;
-
- printf(" Generating the sky colors for each vertex.\n");
-
- /* setup for the possibility of sunset effects */
- sun_angle = l->sun_angle * RAD_TO_DEG;
- printf(" Sun angle in degrees = %.2f\n", sun_angle);
-
- if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
- /* 0.0 - 0.4 */
- outer_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 25.0;
- outer_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 35.0;
- outer_param[2] = 0.0;
-
- middle_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 20.0;
- middle_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
- middle_param[2] = 0.0;
-
- outer_diff[0] = outer_param[0] / 6.0;
- outer_diff[1] = outer_param[1] / 6.0;
- outer_diff[2] = outer_param[2] / 6.0;
-
- middle_diff[0] = middle_param[0] / 6.0;
- middle_diff[1] = middle_param[1] / 6.0;
- middle_diff[2] = middle_param[2] / 6.0;
- } else {
- outer_param[0] = outer_param[1] = outer_param[2] = 0.0;
- middle_param[0] = middle_param[1] = middle_param[2] = 0.0;
-
- outer_diff[0] = outer_diff[1] = outer_diff[2] = 0.0;
- middle_diff[0] = middle_diff[1] = middle_diff[2] = 0.0;
- }
- /* printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
- outer_red_param, outer_red_diff); */
-
- /* calculate transition colors between sky and fog */
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] = outer_param[j];
- middle_amt[j] = middle_param[j];
- }
-
- for ( i = 0; i < 6; i++ ) {
- for ( j = 0; j < 3; j++ ) {
- diff = l->sky_color[j] - l->fog_color[j];
-
- inner_color[i][j] = l->sky_color[j] - diff * 0.3;
- middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
- outer_color[i][j] = l->fog_color[j] + outer_amt[j];
-
- if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
- if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
- if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
- if ( outer_color[i][j] < 0.10 ) { outer_color[i][j] = 0.10; }
- }
- inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
- l->sky_color[3];
-
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] -= outer_diff[j];
- middle_amt[j] -= middle_diff[j];
- }
-
- /*
- printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
- inner_color[i][1], inner_color[i][2], inner_color[i][3]);
- printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- middle_color[i][0], middle_color[i][1], middle_color[i][2],
- middle_color[i][3]);
- printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- outer_color[i][0], outer_color[i][1], outer_color[i][2],
- outer_color[i][3]);
- */
- }
-
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] = 0.0;
- middle_amt[j] = 0.0;
- }
-
- for ( i = 6; i < 12; i++ ) {
-
- for ( j = 0; j < 3; j++ ) {
- diff = l->sky_color[j] - l->fog_color[j];
-
- inner_color[i][j] = l->sky_color[j] - diff * 0.3;
- middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
- outer_color[i][j] = l->fog_color[j] + outer_amt[j];
-
- if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
- if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
- if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
- if ( outer_color[i][j] < 0.15 ) { outer_color[i][j] = 0.15; }
- }
- inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
- l->sky_color[3];
-
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] += outer_diff[j];
- middle_amt[j] += middle_diff[j];
- }
-
- /*
- printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
- inner_color[i][1], inner_color[i][2], inner_color[i][3]);
- printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- middle_color[i][0], middle_color[i][1], middle_color[i][2],
- middle_color[i][3]);
- printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- outer_color[i][0], outer_color[i][1], outer_color[i][2],
- outer_color[i][3]);
- */
- }
-}
-
-
-/* Initialize the sky structure and colors */
-void fgSkyInit( void ) {
- printf("Initializing the sky\n");
-
- fgSkyVerticesInit();
-
- /* regester fgSkyColorsInit() as an event to be run periodically */
- fgEventRegister("fgSkyColorsInit()", fgSkyColorsInit,
- FG_EVENT_READY, 30000);
-}
-
-
-/* Draw the Sky */
-void fgSkyRender( void ) {
- fgFLIGHT *f;
- struct fgLIGHT *l;
- struct fgVIEW *v;
- float /* inner_color[4], middle_color[4], diff, */ east_dot, dot, angle;
- int i;
-
- f = current_aircraft.flight;
- l = &cur_light_params;
- v = ¤t_view;
-
- /* printf("Rendering the sky.\n"); */
-
- xglPushMatrix();
-
- /* calculate the angle between v->surface_to_sun and
- * v->surface_east. We do this so we can sort out the acos()
- * ambiguity. I wish I could think of a more efficient way ... :-( */
- east_dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_east);
- /* printf(" East dot product = %.2f\n", east_dot); */
-
- /* calculate the angle between v->surface_to_sun and
- * v->surface_south. this is how much we have to rotate the sky
- * for it to align with the sun */
- dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_south);
- /* printf(" Dot product = %.2f\n", dot); */
- if ( east_dot >= 0 ) {
- angle = acos(dot);
- } else {
- angle = -acos(dot);
- }
- /*printf(" Sky needs to rotate = %.3f rads = %.1f degrees.\n",
- angle, angle * RAD_TO_DEG); */
-
- /* Translate to view position */
- xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z );
- /* printf(" Translated to %.2f %.2f %.2f\n",
- v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z ); */
-
- /* Rotate to proper orientation */
- /* printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
- FG_Latitude * RAD_TO_DEG); */
- xglRotatef( FG_Longitude * RAD_TO_DEG, 0.0, 0.0, 1.0 );
- xglRotatef( 90.0 - FG_Latitude * RAD_TO_DEG, 0.0, 1.0, 0.0 );
- xglRotatef( angle * RAD_TO_DEG, 0.0, 0.0, 1.0 );
-
- /* Draw inner/center section of sky*/
- xglBegin( GL_TRIANGLE_FAN );
- xglColor4fv(l->sky_color);
- xglVertex3f(0.0, 0.0, CENTER_ELEV);
- for ( i = 0; i < 12; i++ ) {
- xglColor4fv( inner_color[i] );
- xglVertex3fv( inner_vertex[i] );
- }
- xglColor4fv( inner_color[0] );
- xglVertex3fv( inner_vertex[0] );
- xglEnd();
-
- /* Draw the middle ring */
- xglBegin( GL_TRIANGLE_STRIP );
- for ( i = 0; i < 12; i++ ) {
- xglColor4fv( middle_color[i] );
- xglVertex3fv( middle_vertex[i] );
- xglColor4fv( inner_color[i] );
- xglVertex3fv( inner_vertex[i] );
- }
- xglColor4fv( middle_color[0] );
- /* xglColor4f(1.0, 0.0, 0.0, 1.0); */
- xglVertex3fv( middle_vertex[0] );
- xglColor4fv( inner_color[0] );
- /* xglColor4f(1.0, 0.0, 0.0, 1.0); */
- xglVertex3fv( inner_vertex[0] );
- xglEnd();
-
- /* Draw the outer ring */
- xglBegin( GL_TRIANGLE_STRIP );
- for ( i = 0; i < 12; i++ ) {
- xglColor4fv( outer_color[i] );
- xglVertex3fv( outer_vertex[i] );
- xglColor4fv( middle_color[i] );
- xglVertex3fv( middle_vertex[i] );
- }
- xglColor4fv( outer_color[0] );
- xglVertex3fv( outer_vertex[0] );
- xglColor4fv( middle_color[0] );
- xglVertex3fv( middle_vertex[0] );
- xglEnd();
-
- /* Draw the bottom skirt */
- xglBegin( GL_TRIANGLE_STRIP );
- for ( i = 0; i < 12; i++ ) {
- xglColor4fv( l->fog_color );
- xglVertex3fv( bottom_vertex[i] );
- xglColor4fv( outer_color[i] );
- xglVertex3fv( outer_vertex[i] );
- }
- xglColor4fv( l->fog_color );
- xglVertex3fv( bottom_vertex[0] );
- xglColor4fv( outer_color[0] );
- xglVertex3fv( outer_vertex[0] );
- xglEnd();
-
- xglPopMatrix();
-}
-
-
-/* $Log$
-/* 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 <bleisch@chromatic.com> 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.)
- *
- */
--- /dev/null
+/**************************************************************************
+ * sky.c -- model sky with an upside down "bowl"
+ *
+ * Written by Curtis Olson, started December 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * 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)
+ **************************************************************************/
+
+
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <math.h>
+
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <Aircraft/aircraft.h>
+#include <Flight/flight.h>
+#include <Include/fg_constants.h>
+#include <Main/views.hxx>
+#include <Math/fg_random.h>
+#include <Time/event.h>
+#include <Time/fg_time.h>
+
+#include "sky.hxx"
+
+
+/*
+#include <Include/general.h>
+*/
+
+/* in meters of course */
+#define CENTER_ELEV 25000.0
+
+#define INNER_RADIUS 50000.0
+#define INNER_ELEV 20000.0
+
+#define MIDDLE_RADIUS 70000.0
+#define MIDDLE_ELEV 8000.0
+
+#define OUTER_RADIUS 80000.0
+#define OUTER_ELEV 0.0
+
+#define BOTTOM_RADIUS 50000.0
+#define BOTTOM_ELEV -2000.0
+
+
+static float inner_vertex[12][3];
+static float middle_vertex[12][3];
+static float outer_vertex[12][3];
+static float bottom_vertex[12][3];
+
+static float inner_color[12][4];
+static float middle_color[12][4];
+static float outer_color[12][4];
+
+
+/* Calculate the sky structure vertices */
+void fgSkyVerticesInit( void ) {
+ float theta;
+ int i;
+
+ printf(" Generating the sky dome vertices.\n");
+
+ for ( i = 0; i < 12; i++ ) {
+ theta = (i * 30.0) * DEG_TO_RAD;
+
+ inner_vertex[i][0] = cos(theta) * INNER_RADIUS;
+ inner_vertex[i][1] = sin(theta) * INNER_RADIUS;
+ inner_vertex[i][2] = INNER_ELEV;
+
+ /* printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
+ sin(theta) * INNER_RADIUS); */
+
+ middle_vertex[i][0] = cos((double)theta) * MIDDLE_RADIUS;
+ middle_vertex[i][1] = sin((double)theta) * MIDDLE_RADIUS;
+ middle_vertex[i][2] = MIDDLE_ELEV;
+
+ outer_vertex[i][0] = cos((double)theta) * OUTER_RADIUS;
+ outer_vertex[i][1] = sin((double)theta) * OUTER_RADIUS;
+ outer_vertex[i][2] = OUTER_ELEV;
+
+ bottom_vertex[i][0] = cos((double)theta) * BOTTOM_RADIUS;
+ bottom_vertex[i][1] = sin((double)theta) * BOTTOM_RADIUS;
+ bottom_vertex[i][2] = BOTTOM_ELEV;
+ }
+}
+
+
+/* (Re)calculate the sky colors at each vertex */
+void fgSkyColorsInit( void ) {
+ struct fgLIGHT *l;
+ float sun_angle, diff;
+ float outer_param[3], outer_amt[3], outer_diff[3];
+ float middle_param[3], middle_amt[3], middle_diff[3];
+ int i, j;
+
+ l = &cur_light_params;
+
+ printf(" Generating the sky colors for each vertex.\n");
+
+ /* setup for the possibility of sunset effects */
+ sun_angle = l->sun_angle * RAD_TO_DEG;
+ printf(" Sun angle in degrees = %.2f\n", sun_angle);
+
+ if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
+ /* 0.0 - 0.4 */
+ outer_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 25.0;
+ outer_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 35.0;
+ outer_param[2] = 0.0;
+
+ middle_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 20.0;
+ middle_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
+ middle_param[2] = 0.0;
+
+ outer_diff[0] = outer_param[0] / 6.0;
+ outer_diff[1] = outer_param[1] / 6.0;
+ outer_diff[2] = outer_param[2] / 6.0;
+
+ middle_diff[0] = middle_param[0] / 6.0;
+ middle_diff[1] = middle_param[1] / 6.0;
+ middle_diff[2] = middle_param[2] / 6.0;
+ } else {
+ outer_param[0] = outer_param[1] = outer_param[2] = 0.0;
+ middle_param[0] = middle_param[1] = middle_param[2] = 0.0;
+
+ outer_diff[0] = outer_diff[1] = outer_diff[2] = 0.0;
+ middle_diff[0] = middle_diff[1] = middle_diff[2] = 0.0;
+ }
+ /* printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
+ outer_red_param, outer_red_diff); */
+
+ /* calculate transition colors between sky and fog */
+ for ( j = 0; j < 3; j++ ) {
+ outer_amt[j] = outer_param[j];
+ middle_amt[j] = middle_param[j];
+ }
+
+ for ( i = 0; i < 6; i++ ) {
+ for ( j = 0; j < 3; j++ ) {
+ diff = l->sky_color[j] - l->fog_color[j];
+
+ inner_color[i][j] = l->sky_color[j] - diff * 0.3;
+ middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
+ outer_color[i][j] = l->fog_color[j] + outer_amt[j];
+
+ if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
+ if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
+ if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
+ if ( outer_color[i][j] < 0.10 ) { outer_color[i][j] = 0.10; }
+ }
+ inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
+ l->sky_color[3];
+
+ for ( j = 0; j < 3; j++ ) {
+ outer_amt[j] -= outer_diff[j];
+ middle_amt[j] -= middle_diff[j];
+ }
+
+ /*
+ printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
+ inner_color[i][1], inner_color[i][2], inner_color[i][3]);
+ printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
+ middle_color[i][0], middle_color[i][1], middle_color[i][2],
+ middle_color[i][3]);
+ printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
+ outer_color[i][0], outer_color[i][1], outer_color[i][2],
+ outer_color[i][3]);
+ */
+ }
+
+ for ( j = 0; j < 3; j++ ) {
+ outer_amt[j] = 0.0;
+ middle_amt[j] = 0.0;
+ }
+
+ for ( i = 6; i < 12; i++ ) {
+
+ for ( j = 0; j < 3; j++ ) {
+ diff = l->sky_color[j] - l->fog_color[j];
+
+ inner_color[i][j] = l->sky_color[j] - diff * 0.3;
+ middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
+ outer_color[i][j] = l->fog_color[j] + outer_amt[j];
+
+ if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
+ if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
+ if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
+ if ( outer_color[i][j] < 0.15 ) { outer_color[i][j] = 0.15; }
+ }
+ inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
+ l->sky_color[3];
+
+ for ( j = 0; j < 3; j++ ) {
+ outer_amt[j] += outer_diff[j];
+ middle_amt[j] += middle_diff[j];
+ }
+
+ /*
+ printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
+ inner_color[i][1], inner_color[i][2], inner_color[i][3]);
+ printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
+ middle_color[i][0], middle_color[i][1], middle_color[i][2],
+ middle_color[i][3]);
+ printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
+ outer_color[i][0], outer_color[i][1], outer_color[i][2],
+ outer_color[i][3]);
+ */
+ }
+}
+
+
+/* Initialize the sky structure and colors */
+void fgSkyInit( void ) {
+ printf("Initializing the sky\n");
+
+ fgSkyVerticesInit();
+
+ /* regester fgSkyColorsInit() as an event to be run periodically */
+ fgEventRegister("fgSkyColorsInit()", fgSkyColorsInit,
+ FG_EVENT_READY, 30000);
+}
+
+
+/* Draw the Sky */
+void fgSkyRender( void ) {
+ fgFLIGHT *f;
+ struct fgLIGHT *l;
+ struct fgVIEW *v;
+ float /* inner_color[4], middle_color[4], diff, */ east_dot, dot, angle;
+ int i;
+
+ f = current_aircraft.flight;
+ l = &cur_light_params;
+ v = ¤t_view;
+
+ /* printf("Rendering the sky.\n"); */
+
+ xglPushMatrix();
+
+ /* calculate the angle between v->surface_to_sun and
+ * v->surface_east. We do this so we can sort out the acos()
+ * ambiguity. I wish I could think of a more efficient way ... :-( */
+ east_dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_east);
+ /* printf(" East dot product = %.2f\n", east_dot); */
+
+ /* calculate the angle between v->surface_to_sun and
+ * v->surface_south. this is how much we have to rotate the sky
+ * for it to align with the sun */
+ dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_south);
+ /* printf(" Dot product = %.2f\n", dot); */
+ if ( east_dot >= 0 ) {
+ angle = acos(dot);
+ } else {
+ angle = -acos(dot);
+ }
+ /*printf(" Sky needs to rotate = %.3f rads = %.1f degrees.\n",
+ angle, angle * RAD_TO_DEG); */
+
+ /* Translate to view position */
+ xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z );
+ /* printf(" Translated to %.2f %.2f %.2f\n",
+ v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z ); */
+
+ /* Rotate to proper orientation */
+ /* printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
+ FG_Latitude * RAD_TO_DEG); */
+ xglRotatef( FG_Longitude * RAD_TO_DEG, 0.0, 0.0, 1.0 );
+ xglRotatef( 90.0 - FG_Latitude * RAD_TO_DEG, 0.0, 1.0, 0.0 );
+ xglRotatef( angle * RAD_TO_DEG, 0.0, 0.0, 1.0 );
+
+ /* Draw inner/center section of sky*/
+ xglBegin( GL_TRIANGLE_FAN );
+ xglColor4fv(l->sky_color);
+ xglVertex3f(0.0, 0.0, CENTER_ELEV);
+ for ( i = 0; i < 12; i++ ) {
+ xglColor4fv( inner_color[i] );
+ xglVertex3fv( inner_vertex[i] );
+ }
+ xglColor4fv( inner_color[0] );
+ xglVertex3fv( inner_vertex[0] );
+ xglEnd();
+
+ /* Draw the middle ring */
+ xglBegin( GL_TRIANGLE_STRIP );
+ for ( i = 0; i < 12; i++ ) {
+ xglColor4fv( middle_color[i] );
+ xglVertex3fv( middle_vertex[i] );
+ xglColor4fv( inner_color[i] );
+ xglVertex3fv( inner_vertex[i] );
+ }
+ xglColor4fv( middle_color[0] );
+ /* xglColor4f(1.0, 0.0, 0.0, 1.0); */
+ xglVertex3fv( middle_vertex[0] );
+ xglColor4fv( inner_color[0] );
+ /* xglColor4f(1.0, 0.0, 0.0, 1.0); */
+ xglVertex3fv( inner_vertex[0] );
+ xglEnd();
+
+ /* Draw the outer ring */
+ xglBegin( GL_TRIANGLE_STRIP );
+ for ( i = 0; i < 12; i++ ) {
+ xglColor4fv( outer_color[i] );
+ xglVertex3fv( outer_vertex[i] );
+ xglColor4fv( middle_color[i] );
+ xglVertex3fv( middle_vertex[i] );
+ }
+ xglColor4fv( outer_color[0] );
+ xglVertex3fv( outer_vertex[0] );
+ xglColor4fv( middle_color[0] );
+ xglVertex3fv( middle_vertex[0] );
+ xglEnd();
+
+ /* Draw the bottom skirt */
+ xglBegin( GL_TRIANGLE_STRIP );
+ for ( i = 0; i < 12; i++ ) {
+ xglColor4fv( l->fog_color );
+ xglVertex3fv( bottom_vertex[i] );
+ xglColor4fv( outer_color[i] );
+ xglVertex3fv( outer_vertex[i] );
+ }
+ xglColor4fv( l->fog_color );
+ xglVertex3fv( bottom_vertex[0] );
+ xglColor4fv( outer_color[0] );
+ xglVertex3fv( outer_vertex[0] );
+ xglEnd();
+
+ xglPopMatrix();
+}
+
+
+/* $Log$
+/* 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 <bleisch@chromatic.com> 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.)
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * sky.h -- model sky with an upside down "bowl"
- *
- * Written by Curtis Olson, started December 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * 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 _SKY_H
-#define _SKY_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* (Re)generate the display list */
-void fgSkyInit( void );
-
-/* (Re)calculate the sky colors at each vertex */
-void fgSkyColorsInit( void );
-
-/* Draw the Sky */
-void fgSkyRender( void );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _SKY_H */
-
-
-/* $Log$
-/* 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.)
- *
- */
--- /dev/null
+/**************************************************************************
+ * sky.hxx -- model sky with an upside down "bowl"
+ *
+ * Written by Curtis Olson, started December 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * 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 _SKY_HXX
+#define _SKY_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+/* (Re)generate the display list */
+void fgSkyInit( void );
+
+/* (Re)calculate the sky colors at each vertex */
+void fgSkyColorsInit( void );
+
+/* Draw the Sky */
+void fgSkyRender( void );
+
+
+#endif /* _SKY_HXX */
+
+
+/* $Log$
+/* 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.)
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * stars.c -- data structures and routines for managing and rendering stars.
- *
- * Written by Curtis Olson, started August 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * 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)
- **************************************************************************/
-
-
-#include <config.h>
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Astro/orbits.h>
-#include <Astro/planets.h>
-#include <Astro/stars.h>
-
-#include <Aircraft/aircraft.h>
-#include <Debug/fg_debug.h>
-#include <Include/fg_constants.h>
-#include <Include/general.h>
-#include <Main/views.h>
-#include <Time/fg_time.h>
-
-#define EpochStart (631065600)
-#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
-
-
-/* Define four structures, each with varying amounts of stars */
-/* static */ GLint stars[FG_STAR_LEVELS];
-
-
-/* Initialize the Star Management Subsystem */
-int fgStarsInit( void ) {
- FILE *fd;
- fgGENERAL *g;
- /* struct CelestialCoord pltPos; */
- char path[1024];
- char line[256], name[256];
- char *front, *end;
- double right_ascension, declination, magnitude;
- /* double ra_save, decl_save; */
- /* double ra_save1, decl_save1; */
- int count, i, max_stars;
-
- fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
-
- g = &general;
-
- /* build the full path name to the stars data base file */
- path[0] = '\0';
- strcat(path, g->root_dir);
- strcat(path, "/Scenery/");
- strcat(path, "Stars.dat");
-
- max_stars = FG_MAX_STARS;
-
- for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
- fgPrintf( FG_ASTRO, FG_INFO,
- " Loading %d Stars: %s\n", max_stars, path);
-
- if ( (fd = fopen(path, "r")) == NULL ) {
- fgPrintf( FG_ASTRO, FG_ALERT,
- "Cannot open star file: '%s'\n", path);
- return 0; // Oops, lets not even try to continue. This is critical.
- }
-
- stars[i] = xglGenLists(1);
- xglNewList( stars[i], GL_COMPILE );
- xglBegin( GL_POINTS );
-
- /* read in each line of the file */
- count = 0;
- while ( (fgets(line, 256, fd) != NULL) && (count < max_stars) ) {
- front = line;
-
- /* printf(" Read line = %s", front); */
-
- /* advance to first non-whitespace character */
- while ( (front[0] == ' ') || (front[0] == '\t') ) {
- front++;
- }
-
- /* printf(" Line length (after trimming) = %d\n", strlen(front));*/
-
- if ( front[0] == '#' ) {
- /* comment */
- } else if ( strlen(front) <= 1 ) {
- /* blank line */
- } else {
- /* star data line */
-
- /* get name */
- end = front;
- while ( end[0] != ',' ) {
- end++;
- }
- end[0] = '\0';
- strcpy(name, front);
- front = end;
- front++;
-
- sscanf(front, "%lf,%lf,%lf\n",
- &right_ascension, &declination, &magnitude);
-
- /*
- if ( strcmp(name, "Betelgeuse") == 0 ) {
- printf(" *** Marking %s\n", name);
- ra_save = right_ascension;
- decl_save = declination;
- }
- */
-
- /*
- if ( strcmp(name, "Alnilam") == 0 ) {
- printf(" *** Marking %s\n", name);
- ra_save1 = right_ascension;
- decl_save1 = declination;
- }
- */
-
- /* 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.1);
- /* 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) );
-
- count++;
- } // valid line
-
- } /* while */
-
- fclose(fd);
-
- 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();
-
- max_stars /= 2;
- }
-
- return 1; // OK, we got here because initialization worked.
-}
-
-
-/* Draw the Stars */
-void fgStarsRender( void ) {
- fgFLIGHT *f;
- struct fgVIEW *v;
- struct fgLIGHT *l;
- struct fgTIME *t;
- int i;
-
- f = current_aircraft.flight;
- l = &cur_light_params;
- t = &cur_time_params;
- v = ¤t_view;
-
- /* 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 + 7.25 * DEG_TO_RAD ) ) {
- i = 0;
- } else if ( l->sun_angle > (FG_PI_2 + 6.50 * DEG_TO_RAD ) ) {
- i = 1;
- } else if ( l->sun_angle > (FG_PI_2 + 5.75 * DEG_TO_RAD ) ) {
- i = 2;
- } else {
- i = 3;
- }
-
- /* printf("RENDERING STARS = %d (night)\n", i); */
-
- xglCallList(stars[i]);
- } else {
- /* printf("not RENDERING STARS (day)\n"); */
- }
-}
-
-
-/* $Log$
-/* 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 <bleisch@chromatic.com> 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.
- *
- */
--- /dev/null
+/**************************************************************************
+ * stars.c -- data structures and routines for managing and rendering stars.
+ *
+ * Written by Curtis Olson, started August 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * 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)
+ **************************************************************************/
+
+
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <Aircraft/aircraft.h>
+#include <Debug/fg_debug.h>
+#include <Include/fg_constants.h>
+#include <Include/general.h>
+#include <Main/views.hxx>
+#include <Time/fg_time.h>
+
+#include "orbits.hxx"
+#include "planets.hxx"
+#include "stars.hxx"
+
+
+#define EpochStart (631065600)
+#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
+
+
+/* Define four structures, each with varying amounts of stars */
+/* static */ GLint stars[FG_STAR_LEVELS];
+
+
+/* Initialize the Star Management Subsystem */
+int fgStarsInit( void ) {
+ FILE *fd;
+ fgGENERAL *g;
+ /* struct CelestialCoord pltPos; */
+ char path[1024];
+ char line[256], name[256];
+ char *front, *end;
+ double right_ascension, declination, magnitude;
+ /* double ra_save, decl_save; */
+ /* double ra_save1, decl_save1; */
+ int count, i, max_stars;
+
+ fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
+
+ g = &general;
+
+ /* build the full path name to the stars data base file */
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Scenery/");
+ strcat(path, "Stars.dat");
+
+ max_stars = FG_MAX_STARS;
+
+ for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
+ fgPrintf( FG_ASTRO, FG_INFO,
+ " Loading %d Stars: %s\n", max_stars, path);
+
+ if ( (fd = fopen(path, "r")) == NULL ) {
+ fgPrintf( FG_ASTRO, FG_ALERT,
+ "Cannot open star file: '%s'\n", path);
+ return 0; // Oops, lets not even try to continue. This is critical.
+ }
+
+ stars[i] = xglGenLists(1);
+ xglNewList( stars[i], GL_COMPILE );
+ xglBegin( GL_POINTS );
+
+ /* read in each line of the file */
+ count = 0;
+ while ( (fgets(line, 256, fd) != NULL) && (count < max_stars) ) {
+ front = line;
+
+ /* printf(" Read line = %s", front); */
+
+ /* advance to first non-whitespace character */
+ while ( (front[0] == ' ') || (front[0] == '\t') ) {
+ front++;
+ }
+
+ /* printf(" Line length (after trimming) = %d\n", strlen(front));*/
+
+ if ( front[0] == '#' ) {
+ /* comment */
+ } else if ( strlen(front) <= 1 ) {
+ /* blank line */
+ } else {
+ /* star data line */
+
+ /* get name */
+ end = front;
+ while ( end[0] != ',' ) {
+ end++;
+ }
+ end[0] = '\0';
+ strcpy(name, front);
+ front = end;
+ front++;
+
+ sscanf(front, "%lf,%lf,%lf\n",
+ &right_ascension, &declination, &magnitude);
+
+ /*
+ if ( strcmp(name, "Betelgeuse") == 0 ) {
+ printf(" *** Marking %s\n", name);
+ ra_save = right_ascension;
+ decl_save = declination;
+ }
+ */
+
+ /*
+ if ( strcmp(name, "Alnilam") == 0 ) {
+ printf(" *** Marking %s\n", name);
+ ra_save1 = right_ascension;
+ decl_save1 = declination;
+ }
+ */
+
+ /* 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.1);
+ /* 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) );
+
+ count++;
+ } // valid line
+
+ } /* while */
+
+ fclose(fd);
+
+ 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();
+
+ max_stars /= 2;
+ }
+
+ return 1; // OK, we got here because initialization worked.
+}
+
+
+/* Draw the Stars */
+void fgStarsRender( void ) {
+ fgFLIGHT *f;
+ struct fgVIEW *v;
+ struct fgLIGHT *l;
+ struct fgTIME *t;
+ int i;
+
+ f = current_aircraft.flight;
+ l = &cur_light_params;
+ t = &cur_time_params;
+ v = ¤t_view;
+
+ /* 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 + 7.25 * DEG_TO_RAD ) ) {
+ i = 0;
+ } else if ( l->sun_angle > (FG_PI_2 + 6.50 * DEG_TO_RAD ) ) {
+ i = 1;
+ } else if ( l->sun_angle > (FG_PI_2 + 5.75 * DEG_TO_RAD ) ) {
+ i = 2;
+ } else {
+ i = 3;
+ }
+
+ /* printf("RENDERING STARS = %d (night)\n", i); */
+
+ xglCallList(stars[i]);
+ } else {
+ /* printf("not RENDERING STARS (day)\n"); */
+ }
+}
+
+
+/* $Log$
+/* 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 <bleisch@chromatic.com> 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.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * stars.h -- data structures and routines for managing and rendering stars.
- *
- * Written by Curtis Olson, started August 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * 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_H
-#define _STARS_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define FG_MAX_STARS 500
-#define FG_STAR_LEVELS 4 /* how many star transitions */
-#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
-
-/* Initialize the Star Management Subsystem */
-int fgStarsInit( void );
-
-/* Draw the Stars */
-void fgStarsRender( void );
-extern struct OrbElements pltOrbElements[9];
-extern struct fgTIME cur_time_params;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _STARS_H */
-
-
-/* $Log$
-/* 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.
- *
- */
--- /dev/null
+/**************************************************************************
+ * 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@infoplane.com
+ *
+ * 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
+
+
+#define FG_MAX_STARS 500
+#define FG_STAR_LEVELS 4 /* how many star transitions */
+#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
+
+/* Initialize the Star Management Subsystem */
+int fgStarsInit( void );
+
+/* Draw the Stars */
+void fgStarsRender( void );
+extern struct OrbElements pltOrbElements[9];
+extern struct fgTIME cur_time_params;
+
+
+#endif /* _STARS_HXX */
+
+
+/* $Log$
+/* 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.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * sun.c
- *
- * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
- * project.
- *
- * 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)
- **************************************************************************/
-
-
-#include <config.h>
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Astro/orbits.h>
-#include <Astro/sun.h>
-#include <Debug/fg_debug.h>
-#include <Include/fg_constants.h>
-#include <Main/views.h>
-#include <Time/fg_time.h>
-#include <Time/sunpos.h>
-
-GLint sun_obj = 0;
-
-static struct CelestialCoord sunPos;
-
-fgSUNPOS solarPosition;
-
-void fgCalcSunPos(struct OrbElements params)
-{
- double EccAnom, xv, yv, v, r;
-
- /* calculate the eccentric anomaly */
- EccAnom = fgCalcEccAnom(params.M, params.e);
-
- /* calculate the Suns distance (r) and its true anomaly (v) */
- xv = cos(EccAnom) - params.e;
- yv = sqrt(1.0 - params.e*params.e) * sin(EccAnom);
- v = atan2(yv, xv);
- r = sqrt(xv*xv + yv*yv);
-
- /* calculate the the Sun's true longitude (lonsun) */
- solarPosition.lonSun = v + params.w;
-
- /* convert true longitude and distance to ecliptic rectangular
- geocentric coordinates (xs, ys) */
- solarPosition.xs = r * cos (solarPosition.lonSun);
- solarPosition.ys = r * sin (solarPosition.lonSun);
- solarPosition.dist = r;
- /* return solarPosition; */
-}
-
-
-struct CelestialCoord fgCalculateSun (struct OrbElements params,
- struct fgTIME t)
-{
- struct CelestialCoord result;
- double xe, ye, ze, ecl, actTime;
-
- /* calculate the angle between ecliptic and equatorial coordinate
- * system */
- actTime = fgCalcActTime (t);
- ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle now in Rads
-
- /* calculate the sun's ecliptic position */
- fgCalcSunPos (params);
-
- /* convert ecliptic coordinates to equatorial rectangular
- * geocentric coordinates */
- xe = solarPosition.xs;
- ye = solarPosition.ys * cos (ecl);
- ze = solarPosition.ys * sin (ecl);
-
- /* and finally... Calulate Right Ascention and Declination */
- result.RightAscension = atan2 (ye, xe);
- result.Declination = atan2 (ze, sqrt (xe * xe + ye * ye));
- return result;
-}
-
-
-/* Initialize the Sun */
-void fgSunInit( void ) {
- struct fgLIGHT *l;
- struct fgTIME *t;
- struct fgVIEW *v;
- float xSun, ySun, zSun;
-
- /* GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 }; */
- double x_2, x_4, x_8, x_10;
- GLfloat ambient;
- GLfloat amb[4];
-
- l = &cur_light_params;
- t = &cur_time_params;
- v = ¤t_view;
-
- fgPrintf( FG_ASTRO, FG_INFO, " Initializing the Sun\n");
-
- // Calculate basic sun position
- fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
- sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
-
- // Calculate additional sun position parameters based on the above
- // position that are needed by other parts of FG
- fgUpdateSunPos();
-
- fgPrintf( FG_ASTRO, FG_INFO,
- "Sun found at %f (ra), %f (dec)\n",
- sunPos.RightAscension, sunPos.Declination);
-
- xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
- ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
- zSun = 60000.0 * sin(sunPos.Declination);
-
-
- if (sun_obj) {
- xglDeleteLists(sun_obj, 1);
- }
-
- /* printf("First time through, creating sun display list\n"); */
-
- sun_obj = xglGenLists(1);
- xglNewList(sun_obj, GL_COMPILE );
-
-
- t = &cur_time_params;
- v = ¤t_view;
- l = &cur_light_params;
-
- x_2 = l->sun_angle * l->sun_angle;
- x_4 = x_2 * x_2;
- x_8 = x_4 * x_4;
- x_10 = x_8 * x_2;
-
- ambient = (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] = 0.00 + ((ambient * 6.0) - 1.0); /* minimum val = 0.8 */
- amb[1] = 0.00 + ((ambient * 11.0) - 3.0); /* minimum val = 0.3 */
- amb[2] = 0.00 + ((ambient * 12.0) - 3.6); /* minimum val = 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;
-
- fgPrintf( FG_ASTRO, FG_DEBUG,
- "Color of the sun: %f, %f, %f\n"
- "Ambient value : %f\n"
- "Sun Angle : %f\n" ,
- amb[0], amb[1], amb[2], ambient, l->sun_angle);
-
- xglPushMatrix();
- xglTranslatef(xSun, ySun, zSun);
- xglScalef(1400, 1400, 1400);
- xglColor3f(amb[0], amb[1], amb[2]);
- glutSolidSphere(1.0, 10, 10);
- xglPopMatrix();
- xglEndList();
-}
-
-
-/* Draw the Sun */
-void fgSunRender( void ) {
- xglCallList(sun_obj);
-}
-
-
-/* $Log$
-/* Revision 1.10 1998/04/18 04:13:58 curt
-/* Moved fg_debug.c to it's own library.
-/*
- * Revision 1.9 1998/04/03 21:52:51 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/23 19:07:56 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.6 1998/02/12 21:59:39 curt
- * Incorporated code changes contributed by Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.5 1998/02/02 20:53:24 curt
- * To version 0.29
- *
- * Revision 1.4 1998/01/27 00:47:50 curt
- * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.3 1998/01/19 19:27:00 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.12 1998/01/05 18:44:36 curt
- * Add an option to advance/decrease time from keyboard.
- *
- * Revision 1.11 1997/12/30 23:09:40 curt
- * Worked on winding problem without luck, so back to calling glFrontFace()
- * 3 times for each scenery area.
- *
- * Revision 1.10 1997/12/30 20:47:54 curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.9 1997/12/30 16:36:54 curt
- * Merged in Durk's changes ...
- *
- * Revision 1.8 1997/12/19 23:35:00 curt
- * Lot's of tweaking with sky rendering and lighting.
- *
- * Revision 1.7 1997/12/17 23:12:16 curt
- * Fixed so moon and sun display lists aren't recreate periodically.
- *
- * Revision 1.6 1997/12/15 23:55:04 curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.5 1997/12/12 21:41:31 curt
- * More light/material property tweaking ... still a ways off.
- *
- * Revision 1.4 1997/12/10 22:37:53 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.3 1997/12/09 05:11:56 curt
- * Working on tweaking lighting.
- *
- * Revision 1.2 1997/11/25 19:25:39 curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.1 1997/10/25 03:16:11 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
-
-
-
-
-
--- /dev/null
+/**************************************************************************
+ * sun.c
+ *
+ * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
+ * project.
+ *
+ * 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)
+ **************************************************************************/
+
+
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <Debug/fg_debug.h>
+#include <Include/fg_constants.h>
+#include <Main/views.hxx>
+#include <Time/fg_time.h>
+#include <Time/sunpos.hxx>
+
+#include "orbits.hxx"
+#include "sun.hxx"
+
+
+GLint sun_obj = 0;
+
+static struct CelestialCoord sunPos;
+
+fgSUNPOS solarPosition;
+
+void fgCalcSunPos(struct OrbElements params)
+{
+ double EccAnom, xv, yv, v, r;
+
+ /* calculate the eccentric anomaly */
+ EccAnom = fgCalcEccAnom(params.M, params.e);
+
+ /* calculate the Suns distance (r) and its true anomaly (v) */
+ xv = cos(EccAnom) - params.e;
+ yv = sqrt(1.0 - params.e*params.e) * sin(EccAnom);
+ v = atan2(yv, xv);
+ r = sqrt(xv*xv + yv*yv);
+
+ /* calculate the the Sun's true longitude (lonsun) */
+ solarPosition.lonSun = v + params.w;
+
+ /* convert true longitude and distance to ecliptic rectangular
+ geocentric coordinates (xs, ys) */
+ solarPosition.xs = r * cos (solarPosition.lonSun);
+ solarPosition.ys = r * sin (solarPosition.lonSun);
+ solarPosition.dist = r;
+ /* return solarPosition; */
+}
+
+
+struct CelestialCoord fgCalculateSun (struct OrbElements params,
+ struct fgTIME t)
+{
+ struct CelestialCoord result;
+ double xe, ye, ze, ecl, actTime;
+
+ /* calculate the angle between ecliptic and equatorial coordinate
+ * system */
+ actTime = fgCalcActTime (t);
+ ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle now in Rads
+
+ /* calculate the sun's ecliptic position */
+ fgCalcSunPos (params);
+
+ /* convert ecliptic coordinates to equatorial rectangular
+ * geocentric coordinates */
+ xe = solarPosition.xs;
+ ye = solarPosition.ys * cos (ecl);
+ ze = solarPosition.ys * sin (ecl);
+
+ /* and finally... Calulate Right Ascention and Declination */
+ result.RightAscension = atan2 (ye, xe);
+ result.Declination = atan2 (ze, sqrt (xe * xe + ye * ye));
+ return result;
+}
+
+
+/* Initialize the Sun */
+void fgSunInit( void ) {
+ struct fgLIGHT *l;
+ struct fgTIME *t;
+ struct fgVIEW *v;
+ float xSun, ySun, zSun;
+
+ /* GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 }; */
+ double x_2, x_4, x_8, x_10;
+ GLfloat ambient;
+ GLfloat amb[4];
+
+ l = &cur_light_params;
+ t = &cur_time_params;
+ v = ¤t_view;
+
+ fgPrintf( FG_ASTRO, FG_INFO, " Initializing the Sun\n");
+
+ // Calculate basic sun position
+ fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
+ sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
+
+ // Calculate additional sun position parameters based on the above
+ // position that are needed by other parts of FG
+ fgUpdateSunPos();
+
+ fgPrintf( FG_ASTRO, FG_INFO,
+ "Sun found at %f (ra), %f (dec)\n",
+ sunPos.RightAscension, sunPos.Declination);
+
+ xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
+ ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
+ zSun = 60000.0 * sin(sunPos.Declination);
+
+
+ if (sun_obj) {
+ xglDeleteLists(sun_obj, 1);
+ }
+
+ /* printf("First time through, creating sun display list\n"); */
+
+ sun_obj = xglGenLists(1);
+ xglNewList(sun_obj, GL_COMPILE );
+
+
+ t = &cur_time_params;
+ v = ¤t_view;
+ l = &cur_light_params;
+
+ x_2 = l->sun_angle * l->sun_angle;
+ x_4 = x_2 * x_2;
+ x_8 = x_4 * x_4;
+ x_10 = x_8 * x_2;
+
+ ambient = (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] = 0.00 + ((ambient * 6.0) - 1.0); /* minimum val = 0.8 */
+ amb[1] = 0.00 + ((ambient * 11.0) - 3.0); /* minimum val = 0.3 */
+ amb[2] = 0.00 + ((ambient * 12.0) - 3.6); /* minimum val = 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;
+
+ fgPrintf( FG_ASTRO, FG_DEBUG,
+ "Color of the sun: %f, %f, %f\n"
+ "Ambient value : %f\n"
+ "Sun Angle : %f\n" ,
+ amb[0], amb[1], amb[2], ambient, l->sun_angle);
+
+ xglPushMatrix();
+ xglTranslatef(xSun, ySun, zSun);
+ xglScalef(1400, 1400, 1400);
+ xglColor3f(amb[0], amb[1], amb[2]);
+ glutSolidSphere(1.0, 10, 10);
+ xglPopMatrix();
+ xglEndList();
+}
+
+
+/* Draw the Sun */
+void fgSunRender( void ) {
+ xglCallList(sun_obj);
+}
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:36 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.10 1998/04/18 04:13:58 curt
+ * Moved fg_debug.c to it's own library.
+ *
+ * Revision 1.9 1998/04/03 21:52:51 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/23 19:07:56 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * Revision 1.6 1998/02/12 21:59:39 curt
+ * Incorporated code changes contributed by Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.5 1998/02/02 20:53:24 curt
+ * To version 0.29
+ *
+ * Revision 1.4 1998/01/27 00:47:50 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.3 1998/01/19 19:27:00 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.12 1998/01/05 18:44:36 curt
+ * Add an option to advance/decrease time from keyboard.
+ *
+ * Revision 1.11 1997/12/30 23:09:40 curt
+ * Worked on winding problem without luck, so back to calling glFrontFace()
+ * 3 times for each scenery area.
+ *
+ * Revision 1.10 1997/12/30 20:47:54 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.9 1997/12/30 16:36:54 curt
+ * Merged in Durk's changes ...
+ *
+ * Revision 1.8 1997/12/19 23:35:00 curt
+ * Lot's of tweaking with sky rendering and lighting.
+ *
+ * Revision 1.7 1997/12/17 23:12:16 curt
+ * Fixed so moon and sun display lists aren't recreate periodically.
+ *
+ * Revision 1.6 1997/12/15 23:55:04 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
+ * Revision 1.5 1997/12/12 21:41:31 curt
+ * More light/material property tweaking ... still a ways off.
+ *
+ * Revision 1.4 1997/12/10 22:37:53 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.3 1997/12/09 05:11:56 curt
+ * Working on tweaking lighting.
+ *
+ * Revision 1.2 1997/11/25 19:25:39 curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
+ * Revision 1.1 1997/10/25 03:16:11 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */
+
+
+
+
+
+++ /dev/null
-/**************************************************************************
- * sun.h
- *
- * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
- * project.
- *
- * 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 _SUN_H
-#define _SUN_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-extern fgSUNPOS solarPosition;
-
-
-void fgCalcSunPos (struct OrbElements sunParams);
-extern struct OrbElements pltOrbElements[9];
-
-/* Initialize the Sun */
-void fgSunInit( void );
-
-/* Draw the Sun */
-void fgSunRender( void );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _SUN_H */
-
-
-/* $Log$
-/* Revision 1.6 1998/04/21 17:02:33 curt
-/* Prepairing for C++ integration.
-/*
- * Revision 1.5 1998/03/09 22:47:26 curt
- * Incorporated Durk's updates.
- *
- * Revision 1.4 1998/02/23 19:07:57 curt
- * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
- * calculation code between sun display, and other FG sections that use this
- * for things like lighting.
- *
- * Revision 1.3 1998/01/22 02:59:29 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.2 1998/01/19 18:40:19 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:21 curt
- * Moved from .../Src/Scenery/ to .../Src/Astro/
- *
- * Revision 1.3 1997/12/11 04:43:56 curt
- * Fixed sun vector and lighting problems. I thing the moon is now lit
- * correctly.
- *
- * Revision 1.2 1997/11/25 19:25:39 curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.1 1997/10/25 03:16:12 curt
- * Initial revision of code contributed by Durk Talsma.
- *
- */
--- /dev/null
+/**************************************************************************
+ * sun.hxx
+ *
+ * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
+ * project.
+ *
+ * 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 _SUN_HXX
+#define _SUN_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+extern fgSUNPOS solarPosition;
+
+
+void fgCalcSunPos (struct OrbElements sunParams);
+extern struct OrbElements pltOrbElements[9];
+
+
+/* Initialize the Sun */
+void fgSunInit( void );
+
+
+/* Draw the Sun */
+void fgSunRender( void );
+
+
+#endif /* _SUN_HXX */
+
+
+/* $Log$
+/* Revision 1.1 1998/04/22 13:21:37 curt
+/* C++ - ifing the code a bit.
+/*
+ * Revision 1.6 1998/04/21 17:02:33 curt
+ * Prepairing for C++ integration.
+ *
+ * Revision 1.5 1998/03/09 22:47:26 curt
+ * Incorporated Durk's updates.
+ *
+ * Revision 1.4 1998/02/23 19:07:57 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
+ * Revision 1.3 1998/01/22 02:59:29 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.2 1998/01/19 18:40:19 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:21 curt
+ * Moved from .../Src/Scenery/ to .../Src/Astro/
+ *
+ * Revision 1.3 1997/12/11 04:43:56 curt
+ * Fixed sun vector and lighting problems. I thing the moon is now lit
+ * correctly.
+ *
+ * Revision 1.2 1997/11/25 19:25:39 curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
+ * Revision 1.1 1997/10/25 03:16:12 curt
+ * Initial revision of code contributed by Durk Talsma.
+ *
+ */