From 7b3b55f6ef520f0b77d144a0f318e4ff57f9624b Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 7 Jan 1998 03:06:12 +0000 Subject: [PATCH] Moved from .../Src/Scenery/ to .../Src/Astro/ --- Astro/Makefile | 165 ++++++++++++++++ Astro/depend | 56 ++++++ {Scenery => Astro}/moon.c | 7 +- {Scenery => Astro}/moon.h | 9 +- {Scenery => Astro}/orbits.c | 7 +- {Scenery => Astro}/orbits.h | 7 +- {Scenery => Astro}/planets.c | 7 +- {Scenery => Astro}/planets.h | 7 +- {Scenery => Astro}/sky.c | 7 +- {Scenery => Astro}/sky.h | 7 +- Astro/stars.c | 357 +++++++++++++++++++++++++++++++++++ Astro/stars.h | 69 +++++++ {Scenery => Astro}/sun.c | 7 +- {Scenery => Astro}/sun.h | 9 +- Scenery/astro.c | 152 --------------- Scenery/astro.h | 61 ------ 16 files changed, 699 insertions(+), 235 deletions(-) create mode 100644 Astro/Makefile create mode 100644 Astro/depend rename {Scenery => Astro}/moon.c (98%) rename {Scenery => Astro}/moon.h (89%) rename {Scenery => Astro}/orbits.c (96%) rename {Scenery => Astro}/orbits.h (94%) rename {Scenery => Astro}/planets.c (95%) rename {Scenery => Astro}/planets.h (89%) rename {Scenery => Astro}/sky.c (98%) rename {Scenery => Astro}/sky.h (88%) create mode 100644 Astro/stars.c create mode 100644 Astro/stars.h rename {Scenery => Astro}/sun.c (97%) rename {Scenery => Astro}/sun.h (87%) delete mode 100644 Scenery/astro.c delete mode 100644 Scenery/astro.h diff --git a/Astro/Makefile b/Astro/Makefile new file mode 100644 index 00000000..24e85c65 --- /dev/null +++ b/Astro/Makefile @@ -0,0 +1,165 @@ +#--------------------------------------------------------------------------- +# Makefile +# +# Written by Curtis Olson, started May 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) +#--------------------------------------------------------------------------- + + +TARGET = libAstro.a + +CFILES = moon.c orbits.c planets.c sky.c stars.c sun.c + +OFILES = $(CFILES:.c=.o) + + +include ../make.inc + + +CFLAGS = $(FG_CFLAGS) + + +#--------------------------------------------------------------------------- +# Primary Targets +#--------------------------------------------------------------------------- + +$(TARGET): $(OFILES) $(HFILES) + $(AR) rv $(TARGET) $(OFILES) + $(RANLIB) $(TARGET) + +all: $(TARGET) + +clean: + rm -f *.o $(TARGET) lib*.a *.os2 *~ core + +realclean: clean + + +#--------------------------------------------------------------------------- +# Secondary Targets +#--------------------------------------------------------------------------- + +include depend + +moon.o: + $(CC) $(CFLAGS) -c moon.c -o $@ + +orbits.o: + $(CC) $(CFLAGS) -c orbits.c -o $@ + +planets.o: + $(CC) $(CFLAGS) -c planets.c -o $@ + +sky.c: + $(CC) $(CFLAGS) -c sky.c -o $@ + +stars.c: + $(CC) $(CFLAGS) -c stars.c -o $@ + +sun.o: + $(CC) $(CFLAGS) -c sun.c -o $@ + + + +#--------------------------------------------------------------------------- +# $Log$ +# Revision 1.1 1998/01/07 03:16:15 curt +# Moved from .../Src/Scenery/ to .../Src/Astro/ +# +# Revision 1.26 1997/12/19 16:45:01 curt +# Working on scene rendering order and options. +# +# Revision 1.25 1997/12/17 23:13:45 curt +# Began working on rendering the sky. +# +# Revision 1.24 1997/11/25 19:25:33 curt +# Changes to integrate Durk's moon/sun code updates + clean up. +# +# Revision 1.23 1997/10/28 21:00:20 curt +# Changing to new terrain format. +# +# Revision 1.22 1997/10/25 03:30:07 curt +# Misc. tweaks. +# +# Revision 1.21 1997/10/25 03:18:26 curt +# Incorporated sun, moon, and planet position and rendering code contributed +# by Durk Talsma. +# +# Revision 1.20 1997/09/22 14:44:21 curt +# Continuing to try to align stars correctly. +# +# Revision 1.19 1997/08/27 03:30:23 curt +# Changed naming scheme of basic shared structures. +# +# Revision 1.18 1997/08/02 19:10:12 curt +# Incorporated mesh2GL.c into mesh.c +# +# Revision 1.17 1997/07/23 21:52:23 curt +# Put comments around the text after an #endif for increased portability. +# +# Revision 1.16 1997/07/20 02:19:11 curt +# First stab at a system to generate os2 makefiles automatically. +# +# Revision 1.15 1997/07/12 02:24:47 curt +# Added ranlib. +# +# Revision 1.14 1997/06/29 21:16:47 curt +# More twiddling with the Scenery Management system. +# +# Revision 1.13 1997/06/27 21:38:10 curt +# Working on Makefile structure. +# +# Revision 1.12 1997/06/27 20:03:37 curt +# Working on Makefile structure. +# +# Revision 1.11 1997/06/26 22:14:57 curt +# Beginning work on a scenery management system. +# +# Revision 1.10 1997/06/26 19:08:34 curt +# Restructuring make, adding automatic "make dep" support. +# +# Revision 1.9 1997/06/25 15:39:48 curt +# Minor changes to compile with rsxnt/win32. +# +# Revision 1.8 1997/06/21 17:58:07 curt +# directory shuffling ... +# +# Revision 1.1 1997/06/21 17:39:28 curt +# Moved to the ParseScn subdirectory. +# +# Revision 1.6 1997/06/21 17:12:55 curt +# Capitalized subdirectory names. +# +# Revision 1.5 1997/05/31 19:16:29 curt +# Elevator trim added. +# +# Revision 1.4 1997/05/27 17:48:50 curt +# Added -f flag to flex to generate a "fast" scanner. +# +# Revision 1.3 1997/05/23 15:40:40 curt +# Added GNU copyright headers. +# +# Revision 1.2 1997/05/17 00:17:01 curt +# Cosmetic changes. +# +# Revision 1.1 1997/05/16 16:07:02 curt +# Initial revision. +# diff --git a/Astro/depend b/Astro/depend new file mode 100644 index 00000000..a948633f --- /dev/null +++ b/Astro/depend @@ -0,0 +1,56 @@ +astro.o: astro.c ../XGL/xgl.h astro.h stars.h moon.h orbits.h \ + ../Time/fg_time.h ../Time/../Include/types.h \ + ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h planets.h sun.h \ + ../Include/constants.h ../Include/general.h ../Main/views.h \ + ../Main/../Include/types.h ../Main/../Flight/flight.h \ + ../Main/../Math/mat3.h ../Main/../Time/fg_time.h \ + ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ + ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h +moon.o: moon.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h moon.h ../Aircraft/aircraft.h \ + ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h ../Include/constants.h \ + ../Include/general.h ../Main/views.h ../Main/../Include/types.h \ + ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ + ../Main/../Time/fg_time.h +orbits.o: orbits.c orbits.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h ../Include/general.h +planets.o: planets.c ../Time/fg_time.h ../Time/../Include/types.h \ + ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h orbits.h planets.h sun.h +sky.o: sky.c ../XGL/xgl.h sky.h ../Time/event.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h ../Aircraft/aircraft.h \ + ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ + ../Include/constants.h ../Main/views.h ../Main/../Include/types.h \ + ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ + ../Main/../Time/fg_time.h ../Math/fg_random.h +stars.o: stars.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h planets.h stars.h \ + ../Include/constants.h ../Include/general.h ../Aircraft/aircraft.h \ + ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h ../Main/views.h \ + ../Main/../Include/types.h ../Main/../Flight/flight.h \ + ../Main/../Math/mat3.h ../Main/../Time/fg_time.h +sun.o: sun.c ../XGL/xgl.h ../Time/fg_time.h ../Time/../Include/types.h \ + ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h ../Main/views.h \ + ../Main/../Include/types.h ../Main/../Flight/flight.h \ + ../Main/../Math/mat3.h ../Main/../Time/fg_time.h orbits.h sun.h diff --git a/Scenery/moon.c b/Astro/moon.c similarity index 98% rename from Scenery/moon.c rename to Astro/moon.c index dd39f072..aa99c92d 100644 --- a/Scenery/moon.c +++ b/Astro/moon.c @@ -320,9 +320,12 @@ void fgMoonRender() { /* $Log$ -/* Revision 1.16 1998/01/06 01:20:24 curt -/* Tweaks to help building with MSVC++ +/* 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. * diff --git a/Scenery/moon.h b/Astro/moon.h similarity index 89% rename from Scenery/moon.h rename to Astro/moon.h index a8e90386..c4d21ed2 100644 --- a/Scenery/moon.h +++ b/Astro/moon.h @@ -51,10 +51,13 @@ extern struct OrbElements pltOrbElements[9]; /* $Log$ -/* 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.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. * diff --git a/Scenery/orbits.c b/Astro/orbits.c similarity index 96% rename from Scenery/orbits.c rename to Astro/orbits.c index 99ddd635..50a28366 100644 --- a/Scenery/orbits.c +++ b/Astro/orbits.c @@ -173,9 +173,12 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t) /* $Log$ -/* Revision 1.6 1997/12/30 20:47:52 curt -/* Integrated new event manager with subsystem initializations. +/* 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. diff --git a/Scenery/orbits.h b/Astro/orbits.h similarity index 94% rename from Scenery/orbits.h rename to Astro/orbits.h index c51b305e..9077cd4a 100644 --- a/Scenery/orbits.h +++ b/Astro/orbits.h @@ -81,9 +81,12 @@ void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t); /* $Log$ -/* Revision 1.2 1997/12/30 16:36:52 curt -/* Merged in Durk's changes ... +/* 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. * diff --git a/Scenery/planets.c b/Astro/planets.c similarity index 95% rename from Scenery/planets.c rename to Astro/planets.c index cd2171c5..0453cb33 100644 --- a/Scenery/planets.c +++ b/Astro/planets.c @@ -133,9 +133,12 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet, /* $Log$ -/* Revision 1.4 1997/12/30 20:47:52 curt -/* Integrated new event manager with subsystem initializations. +/* 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 ... * diff --git a/Scenery/planets.h b/Astro/planets.h similarity index 89% rename from Scenery/planets.h rename to Astro/planets.h index 3d5df465..6cf87489 100644 --- a/Scenery/planets.h +++ b/Astro/planets.h @@ -35,9 +35,12 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet, /* $Log$ -/* Revision 1.3 1997/12/30 16:36:53 curt -/* Merged in Durk's changes ... +/* 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. * diff --git a/Scenery/sky.c b/Astro/sky.c similarity index 98% rename from Scenery/sky.c rename to Astro/sky.c index e34e6c7b..4de37c73 100644 --- a/Scenery/sky.c +++ b/Astro/sky.c @@ -329,9 +329,12 @@ void fgSkyRender() { /* $Log$ -/* Revision 1.11 1997/12/30 22:22:38 curt -/* Further integration of event manager. +/* 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. * diff --git a/Scenery/sky.h b/Astro/sky.h similarity index 88% rename from Scenery/sky.h rename to Astro/sky.h index f5bd771b..7ba4863e 100644 --- a/Scenery/sky.h +++ b/Astro/sky.h @@ -35,9 +35,12 @@ void fgSkyRender(); /* $Log$ -/* Revision 1.2 1997/12/22 23:45:49 curt -/* First stab at sunset/sunrise sky glow effects. +/* 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.) diff --git a/Astro/stars.c b/Astro/stars.c new file mode 100644 index 00000000..6d3d4a53 --- /dev/null +++ b/Astro/stars.c @@ -0,0 +1,357 @@ +/************************************************************************** + * 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) + **************************************************************************/ + + +#ifdef WIN32 +# include +#endif + +#include +#include +#include +#include + +#include +#include "../XGL/xgl.h" + +#include "orbits.h" +#include "planets.h" +#include "stars.h" + +#include "../Include/constants.h" +#include "../Include/general.h" +#include "../Aircraft/aircraft.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 */ +void fgStarsInit() { + FILE *fd; + struct 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, j, max_stars; + + printf("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++ ) { + printf(" Loading %d Stars: %s\n", max_stars, path); + + if ( (fd = fopen(path, "r")) == NULL ) { + printf("Cannot open star file: '%s'\n", path); + return; + } + + 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++; + } /* if valid line */ + + } /* while */ + + fclose(fd); + + /* Add the planets to all four display lists */ + for ( j = 2; j < 9; j++ ) { + pltPos = fgCalculatePlanet(pltOrbElements[j], + pltOrbElements[0], cur_time_params, j); + /* give the planets a temporary color, for testing purposes */ + /* xglColor3f( 1.0, 0.0, 0.0); */ + + /* scale magnitudes to (0.0 - 1.0) */ + magnitude = (0.0 - pltPos.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); + + + xglColor3f(magnitude, magnitude, magnitude); + + xglVertex3f( 50000.0 * cos(pltPos.RightAscension) * + cos(pltPos.Declination), + 50000.0 * sin(pltPos.RightAscension) * + cos(pltPos.Declination), + 50000.0 * sin(pltPos.Declination) ); + } + 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; + } +} + + +/* Draw the Stars */ +void fgStarsRender() { + struct fgFLIGHT *f; + struct fgVIEW *v; + struct fgLIGHT *l; + struct fgTIME *t; + int i; + + f = ¤t_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/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. + * + */ diff --git a/Astro/stars.h b/Astro/stars.h new file mode 100644 index 00000000..19524e12 --- /dev/null +++ b/Astro/stars.h @@ -0,0 +1,69 @@ +/************************************************************************** + * 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 + + +#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 */ +void fgStarsInit(); + +/* Draw the Stars */ +void fgStarsRender(); +extern struct OrbElements pltOrbElements[9]; +extern struct fgTIME cur_time_params; + +#endif /* STARS_H */ + + +/* $Log$ +/* 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. + * + */ diff --git a/Scenery/sun.c b/Astro/sun.c similarity index 97% rename from Scenery/sun.c rename to Astro/sun.c index d68d179a..43e2c353 100644 --- a/Scenery/sun.c +++ b/Astro/sun.c @@ -190,9 +190,12 @@ void fgSunRender() { /* $Log$ -/* Revision 1.12 1998/01/05 18:44:36 curt -/* Add an option to advance/decrease time from keyboard. +/* 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. diff --git a/Scenery/sun.h b/Astro/sun.h similarity index 87% rename from Scenery/sun.h rename to Astro/sun.h index 9d597d27..260101f7 100644 --- a/Scenery/sun.h +++ b/Astro/sun.h @@ -41,10 +41,13 @@ void fgSunRender(); /* $Log$ -/* 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.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. * diff --git a/Scenery/astro.c b/Scenery/astro.c deleted file mode 100644 index d49af701..00000000 --- a/Scenery/astro.c +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** - * astro.c - * - * Written by Durk Talsma. Started November 1997, for use with 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 -#include -#include -#include - -#include -#include "../XGL/xgl.h" - -#include "astro.h" -#include "moon.h" -#include "orbits.h" -#include "planets.h" -#include "stars.h" -#include "sun.h" - -#include "../Include/constants.h" -#include "../Include/general.h" - -#include "../Main/views.h" -#include "../Aircraft/aircraft.h" -#include "../Time/fg_time.h" - -static double prevUpdate = 0; - - -/* Initialize Astronomical Objects */ -void fgAstroInit() { - struct fgTIME *t; - t = &cur_time_params; - - /* Initialize the orbital elements of sun, moon and mayor planets */ - fgSolarSystemInit(*t); - - /* Initialize the Stars subsystem */ - fgStarsInit(); - - /* Initialize the sun's position */ - fgSunInit(); - - /* Intialize the moon's position */ - fgMoonInit(); -} - - -/* Render Astronomical Objects */ -void fgAstroRender() { - struct fgFLIGHT *f; - struct fgLIGHT *l; - struct fgVIEW *v; - struct fgTIME *t; - double angle; - - f = ¤t_aircraft.flight; - l = &cur_light_params; - t = &cur_time_params; - v = ¤t_view; - - /* a hack: Force sun and moon position to be updated on an hourly basis */ - if (((t->gst - prevUpdate) > 1) || (t->gst < prevUpdate)) { - prevUpdate = t->gst; - fgSunInit(); - fgMoonInit(); - } - - /* set the sun position */ - /* xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv ); */ - - xglPushMatrix(); - - /* Translate to view position */ - xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z ); - - /* Rotate based on gst (side real time) */ - angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/ -#ifdef DEBUG - printf("Rotating astro objects by %.2f degrees\n",angle); -#endif - xglRotatef( angle, 0.0, 0.0, -1.0 ); - - /* render the moon */ - fgMoonRender(); - - /* render the stars */ - fgStarsRender(); - - /* render the sun */ - fgSunRender(); - - xglPopMatrix(); -} - - -/* $Log$ -/* Revision 1.10 1997/12/19 16:45:01 curt -/* Working on scene rendering order and options. -/* - * Revision 1.9 1997/12/18 23:32:35 curt - * First stab at sky dome actually starting to look reasonable. :-) - * - * Revision 1.8 1997/12/15 23:54:57 curt - * Add xgl wrappers for debugging. - * Generate terrain normals on the fly. - * - * Revision 1.7 1997/12/15 20:59:09 curt - * Misc. tweaks. - * - * Revision 1.6 1997/12/12 21:41:27 curt - * More light/material property tweaking ... still a ways off. - * - * Revision 1.5 1997/12/12 19:52:54 curt - * Working on lightling and material properties. - * - * 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/12/10 22:37:49 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.2 1997/12/09 04:25:33 curt - * Working on adding a global lighting params structure. - * - * Revision 1.1 1997/11/25 23:20:22 curt - * Initial revision. - * - */ diff --git a/Scenery/astro.h b/Scenery/astro.h deleted file mode 100644 index 4fa5150a..00000000 --- a/Scenery/astro.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** - * astro.h - * - * Written by Durk Talsma. Started November 1997, for use with 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 _ASTRO_H_ -#define _ASTRO_H_ - -#include -#include "stars.h" - -extern struct CelestialCoord - moonPos; - -extern float xMoon, yMoon, zMoon, xSun, ySun, zSun; -/* extern GLint moon, sun; */ -extern GLint stars[FG_STAR_LEVELS]; - - -/* Initialize Astronomical Objects */ -void fgAstroInit(); - -/* Render Astronomical objects */ -void fgAstroRender(); - - -#endif /* _ASTRO_H_ */ - - -/* $Log$ -/* Revision 1.3 1997/12/17 23:13:46 curt -/* Began working on rendering the sky. -/* - * Revision 1.2 1997/12/11 04:43:56 curt - * Fixed sun vector and lighting problems. I thing the moon is now lit - * correctly. - * - * Revision 1.1 1997/11/25 23:20:23 curt - * Initial revision. - * - */ -- 2.39.5