]> git.mxchange.org Git - flightgear.git/commitdiff
Cleaned up initialization sequence to eliminate interdependencies
authorcurt <curt>
Sat, 25 Apr 1998 20:24:00 +0000 (20:24 +0000)
committercurt <curt>
Sat, 25 Apr 1998 20:24:00 +0000 (20:24 +0000)
between sun position, lighting, and view position.  This creates a
valid single pass initialization path.

Main/GLUTkey.cxx
Main/GLUTmain.cxx
Main/fg_init.cxx
Main/views.cxx
Simulator/Done
Simulator/Todo
Time/fg_time.cxx
Time/fg_time.hxx
Time/fg_timer.cxx
Time/sunpos.cxx
Time/sunpos.hxx

index f6218e6333ce6ce94becb4f3d6a889d324295d19..ab5d164327648bb00c14bfca23d975b751886acd 100644 (file)
@@ -174,13 +174,12 @@ void GLUTkey(unsigned char k, int x, int y) {
                      "Fog density = %.4f\n", w->visibility);
            return;
        case 27: /* ESC */
-           if( fg_DebugOutput ) {
-               fclose( fg_DebugOutput );
-           }
+           // if( fg_DebugOutput ) {
+           //   fclose( fg_DebugOutput );
+           // }
            exit(0);
        }
     }
-
 }
 
 
@@ -266,9 +265,14 @@ void GLUTspecialkey(int k, int x, int y) {
 
 
 /* $Log$
-/* Revision 1.3  1998/04/24 14:19:29  curt
-/* Fog tweaks.
+/* Revision 1.4  1998/04/25 20:24:00  curt
+/* Cleaned up initialization sequence to eliminate interdependencies
+/* between sun position, lighting, and view position.  This creates a
+/* valid single pass initialization path.
 /*
+ * Revision 1.3  1998/04/24 14:19:29  curt
+ * Fog tweaks.
+ *
  * Revision 1.2  1998/04/24 00:49:17  curt
  * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
  * Trying out some different option parsing code.
index d20bf55a66709de611e1df9ef2e869dda1eb6342..af89baedee531896c80b241204dbcc95a3fd777e 100644 (file)
@@ -322,7 +322,6 @@ static void fgRenderFrame( void ) {
     struct fgVIEW *v;
     double angle;
     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
-    GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
 
     l = &cur_light_params;
     o = &current_options;
@@ -694,6 +693,11 @@ extern "C" {
 
 
 // $Log$
+// Revision 1.5  1998/04/25 20:24:01  curt
+// Cleaned up initialization sequence to eliminate interdependencies
+// between sun position, lighting, and view position.  This creates a
+// valid single pass initialization path.
+//
 // Revision 1.4  1998/04/24 14:19:30  curt
 // Fog tweaks.
 //
index 39c12580ec040ef14a5c6e86621e5114cc8a6a1e..3c9bc5f0694a2d53669e353042b99bc53f27fd1e 100644 (file)
@@ -71,48 +71,13 @@ int fgInitPosition( void ) {
     f = current_aircraft.flight;
     o = &current_options;
 
-    // Initial Position at (P13) Globe, AZ
+    // If nothing else is specified, default initial position is
+    // Globe, AZ (P13)
     FG_Longitude = ( -110.6642444 ) * DEG_TO_RAD;
     FG_Latitude  = (  33.3528917 ) * DEG_TO_RAD;
     FG_Runway_altitude = (3234.5 + 300);
     FG_Altitude = FG_Runway_altitude + 3.758099;
 
-    // Initial Position at (E81) Superior, AZ
-    // FG_Longitude = ( -111.1270650 ) * DEG_TO_RAD;
-    // FG_Latitude  = (  33.2778339 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = (2646 + 100);
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-
-    // Initial Position at (TUS) Tucson, AZ
-    // FG_Longitude = ( -110.9412597 ) * DEG_TO_RAD;
-    // FG_Latitude  = (  32.1162439 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = (2641 + 0);
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-
-    // Initial Position at (SEZ) SEDONA airport
-    // FG_Longitude = (-111.7884614 + 0.01) * DEG_TO_RAD;
-    // FG_Latitude  = (  34.8486289 - 0.015) * DEG_TO_RAD;
-    // FG_Runway_altitude = (4827 + 450);
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-        
-    // Initial Position at near Anchoraze, AK
-    // FG_Longitude = ( -152.00 ) * DEG_TO_RAD;
-    // FG_Latitude  = (  61.17 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = (0);
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-
-    // Initial Position at (HSP) Hot Springs, VA
-    // FG_Longitude = (-79.8338964 + 0.01) * DEG_TO_RAD;
-    // FG_Latitude  = ( 37.9514564 + 0.008) * DEG_TO_RAD;
-    // FG_Runway_altitude = (3792 + 1300);
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-    
-    // Initial Position at (ANE) Anoka County airport
-    // FG_Longitude = -93.2113889 * DEG_TO_RAD;
-    // FG_Latitude  = 45.145 * DEG_TO_RAD;
-    // FG_Runway_altitude = 912;
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-
     // Initial Position north of the city of Globe
     // FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD;
     // FG_Latitude  = (  120625.64 / 3600.0 ) * DEG_TO_RAD;
@@ -138,12 +103,6 @@ int fgInitPosition( void ) {
     // FG_Runway_altitude = 8000.0;
     // FG_Altitude = FG_Runway_altitude + 3.758099;
 
-    // Initial Position: (GCN) Grand Canyon Airport, AZ
-    // FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
-    // FG_Latitude  = (   35.9523539 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = 6606.0;
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-
     // Initial Position: Jim Brennon's Kingmont Observatory
     // FG_Longitude = ( -121.1131667 ) * DEG_TO_RAD;
     // FG_Latitude  = (   38.8293917 ) * DEG_TO_RAD;
@@ -153,18 +112,6 @@ int fgInitPosition( void ) {
     // probably interesting for european team members
     // That is: If I can get the scenery to work -;) (Durk)
  
-    // Initial Position: Groningen Airport Eelde, the netherlands
-    // FG_Longitude = ( 6.583333 ) * DEG_TO_RAD;
-    // FG_Latitude  = (   53.125 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = 920.0;
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-    // Initial Position: Schiphol Amsterdam Airport, the netherlands
-    // FG_Longitude = ( -4.7641667 ) * DEG_TO_RAD;
-    // FG_Latitude  = (   52.308056 ) * DEG_TO_RAD;
-    // FG_Runway_altitude = 920.0;
-    // FG_Altitude = FG_Runway_altitude + 3.758099;
-
     // Eclipse Watching w73.5 n10 (approx) 18:00 UT
     // FG_Longitude = ( -73.5 ) * DEG_TO_RAD;
     // FG_Latitude  = (  10.0 ) * DEG_TO_RAD;
@@ -188,7 +135,7 @@ int fgInitPosition( void ) {
        airports.load("Airports");
        a = airports.search(o->airport_id);
        if ( strcmp(a.id, "none") == 0 ) {
-           fgPrintf( FG_GENERAL, FG_INFO
+           fgPrintf( FG_GENERAL, FG_EXIT
                      "Failed to find %s in database.\n", o->airport_id);
        } else {
            FG_Longitude = ( a.longitude ) * DEG_TO_RAD;
@@ -202,6 +149,8 @@ int fgInitPosition( void ) {
              "Initial position is: (%.4f, %.4f, %.2f)\n", 
              FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, 
              FG_Altitude * FEET_TO_METER);
+
+    return(1);
 }
 
 
@@ -211,6 +160,9 @@ int fgInitGeneral( void ) {
 
     g = &general;
 
+    fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" );
+    fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" );
+
     // determine the fg root path.  
     if( !(g->root_dir) ) { 
        // If not set by command line test for environmental var..
@@ -225,12 +177,6 @@ int fgInitGeneral( void ) {
     }
     fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", g->root_dir);
 
-    fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" );
-    fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" );
-
-    // seed the random number generater
-    fg_srandom();
-
     return ( 1 ); 
 }
 
@@ -254,6 +200,9 @@ int fgInitSubsystems( void ) {
     fgPrintf( FG_GENERAL, FG_INFO, "Initialize Subsystems\n");
     fgPrintf( FG_GENERAL, FG_INFO, "========== ==========\n");
 
+    // seed the random number generater
+    fg_srandom();
+
     // The following section sets up the flight model EOM parameters
     // and should really be read in from one or more files.
 
@@ -295,33 +244,49 @@ int fgInitSubsystems( void ) {
     FG_Dy_cg = 0.000000E+00;
     FG_Dz_cg = 0.000000E+00;
 
-    // Set initial position and slew parameters
-    // fgSlewInit(-398391.3, 120070.41, 244, 3.1415);  // GLOBE Airport
-    // fgSlewInit(-335340,162540, 15, 4.38);
-    // fgSlewInit(-398673.28,120625.64, 53, 4.38);
-
     // Initialize the event manager
     fgEventInit();
 
-    // Dump event stats every 60 seconds
+    // Output event stats every 60 seconds
     fgEventRegister( "fgEventPrintStats()", fgEventPrintStats,
                     FG_EVENT_READY, 60000 );
 
-    // Initialize "time"
+    // Initialize the time dependent variables
     fgTimeInit(t);
     fgTimeUpdate(f, t);
 
-    // fgViewUpdate() needs the sun in the right place, while
-    // fgUpdateSunPos() needs to know the view position.  I'll get
-    // around this interdependency for now by calling fgUpdateSunPos()
-    // once, then moving on with normal initialization.
-    fgUpdateSunPos();
-
     // Initialize view parameters
+    // ---->
     fgViewInit(v);
     fgViewUpdate(f, v, l);
 
+    // Initialize the orbital elements of sun, moon and mayor planets
+    fgSolarSystemInit(*t);
+
+    // Initialize the Stars subsystem
+    if( fgStarsInit() ) {
+       // Stars initialized ok.
+    } else {
+       fgPrintf( FG_GENERAL, FG_EXIT, "Error in Stars initialization!\n" );
+    }
+
+    // Initialize the planetary subsystem
+    fgEventRegister("fgPlanetsInit()", fgPlanetsInit, FG_EVENT_READY, 600000);
+
+    // Initialize the sun's position 
+    fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 30000 );
+
+    // Intialize the moon's position
+    fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 );
+
+    // fgUpdateSunPos() needs a few position and view parameters set
+    // so it can calculate local relative sun angle and a few other
+    // things for correctly orienting the sky.
+    // ---->
+    fgUpdateSunPos();
+
     // Initialize Lighting interpolation tables
+    // ---->
     fgLightInit();
 
     // update the lighting parameters (based on sun angle)
@@ -342,26 +307,8 @@ int fgInitSubsystems( void ) {
        fgPrintf( FG_GENERAL, FG_EXIT, "Error in Cockpit initialization!\n" );
     }
 
-    // Initialize the orbital elements of sun, moon and mayor planets
-    fgSolarSystemInit(*t);
-
-    // Initialize the Stars subsystem
-    if( fgStarsInit() ) {
-       // Stars initialized ok.
-    } else {
-       fgPrintf( FG_GENERAL, FG_EXIT, "Error in Stars initialization!\n" );
-    }
-
-    // Initialize the planetary subsystem
-    fgEventRegister("fgPlanetsInit()", fgPlanetsInit, FG_EVENT_READY, 600000);
-
-    // Initialize the sun's position 
-    fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 30000 );
-
-    // Intialize the moon's position
-    fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 );
-
     // Initialize the "sky"
+    // ---->
     fgSkyInit();
 
     // Initialize the Scenery Management subsystem
@@ -382,26 +329,19 @@ int fgInitSubsystems( void ) {
 
     // I'm just sticking this here for now, it should probably move
     // eventually
-    // cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
-    //           FG_Latitude  * RAD_TO_DEG * 3600.0);
-    // fgPrintf( FG_GENERAL, FG_INFO,
-    //   "True ground elevation is %.2f meters here.\n",
-    //   cur_elev);
-
-    cur_elev = FG_Runway_altitude * FEET_TO_METER;
-    if ( cur_elev > -9990.0 ) {
-       FG_Runway_altitude = cur_elev * METER_TO_FEET;
-    }
+        cur_elev = FG_Runway_altitude * FEET_TO_METER;
+        if ( cur_elev > -9990.0 ) {
+           FG_Runway_altitude = cur_elev * METER_TO_FEET;
+        }
 
-    if ( FG_Altitude < FG_Runway_altitude ) {
-       FG_Altitude = FG_Runway_altitude + 3.758099;
-    }
+        if ( FG_Altitude < FG_Runway_altitude ) {
+           FG_Altitude = FG_Runway_altitude + 3.758099;
+        }
 
-    fgPrintf(FG_GENERAL, FG_INFO,
+        fgPrintf( FG_GENERAL, FG_INFO,
             "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
             FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
             FG_Altitude * FEET_TO_METER);
-
     // end of thing that I just stuck in that I should probably move
                
     // Initialize the flight model subsystem data structures base on
@@ -409,9 +349,6 @@ int fgInitSubsystems( void ) {
 
     fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
 
-    // To HUD or not to HUD  - Now a command line issue
-    //              show_hud = 0;
-
     // Let's not show the instrument panel
     displayInstruments = 0;
 
@@ -425,9 +362,6 @@ int fgInitSubsystems( void ) {
     // Autopilot init added here, by Jeff Goeke-Smith
     fgAPInit(&current_aircraft);
     
-    // One more try here to get the sky synced up
-    fgSkyColorsInit();
-
     fgPrintf(FG_GENERAL, FG_INFO,"\n");
 
     return(1);
@@ -435,6 +369,11 @@ int fgInitSubsystems( void ) {
 
 
 // $Log$
+// Revision 1.4  1998/04/25 20:24:01  curt
+// Cleaned up initialization sequence to eliminate interdependencies
+// between sun position, lighting, and view position.  This creates a
+// valid single pass initialization path.
+//
 // Revision 1.3  1998/04/25 15:11:11  curt
 // Added an command line option to set starting position based on airport ID.
 //
index 4c3b0062cc0b366afdf1ddb7bc6e4442c3ab0715..c1243904bdcba56e6d7f8102335936442303f8ab 100644 (file)
@@ -1,27 +1,27 @@
-/**************************************************************************
- * views.c -- data structures and routines for managing and view parameters.
- *
- * 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)
- **************************************************************************/
+//
+// views.cxx -- data structures and routines for managing and view parameters.
+//
+// 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 HAVE_CONFIG_H
 #include "views.hxx"
 
 
-/* This is a record containing current view parameters */
+// This is a record containing current view parameters
 struct fgVIEW current_view;
 
 
-/* Initialize a view structure */
+// Initialize a view structure
 void fgViewInit(struct fgVIEW *v) {
     fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n");
 
@@ -53,7 +53,7 @@ void fgViewInit(struct fgVIEW *v) {
 }
 
 
-/* Update the view parameters */
+// Update the view parameters
 void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l) {
     MAT3vec vec, forward, v0, minus_z;
     MAT3mat R, TMP, UP, LOCAL, VIEW;
@@ -63,14 +63,14 @@ void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l) {
     scenery.center.y = scenery.next_center.y;
     scenery.center.z = scenery.next_center.z;
 
-    /* calculate the cartesion coords of the current lat/lon/0 elev */
+    // calculate the cartesion coords of the current lat/lon/0 elev
     v->cur_zero_elev = fgPolarToCart(FG_Longitude, FG_Lat_geocentric, 
                                     FG_Sea_level_radius * FEET_TO_METER);
     v->cur_zero_elev.x -= scenery.center.x;
     v->cur_zero_elev.y -= scenery.center.y;
     v->cur_zero_elev.z -= scenery.center.z;
 
-    /* calculate view position in current FG view coordinate system */
+    // calculate view position in current FG view coordinate system
     v->abs_view_pos = fgPolarToCart(FG_Longitude, FG_Lat_geocentric, 
                             FG_Radius_to_vehicle * FEET_TO_METER + 1.0);
     v->view_pos.x = v->abs_view_pos.x - scenery.center.x;
@@ -82,177 +82,163 @@ void fgViewUpdate(fgFLIGHT *f, struct fgVIEW *v, fgLIGHT *l) {
     fgPrintf( FG_VIEW, FG_DEBUG, "Relative view pos = %.4f, %.4f, %.4f\n", 
           v->view_pos.x, v->view_pos.y, v->view_pos.z);
 
-    /* make a vector to the current view position */
-    MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
-
-    /* calculate vector to sun's position on the earth's surface */
-    v->to_sun[0] = l->fg_sunpos.x - (v->view_pos.x + scenery.center.x);
-    v->to_sun[1] = l->fg_sunpos.y - (v->view_pos.y + scenery.center.y);
-    v->to_sun[2] = l->fg_sunpos.z - (v->view_pos.z + scenery.center.z);
-    /* printf("Vector to sun = %.2f %.2f %.2f\n",
-          v->to_sun[0], v->to_sun[1], v->to_sun[2]); */
-
-    /* Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw) */
+    // Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
     MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
     MAT3rotate(R, vec, FG_Phi);
-    /* printf("Roll matrix\n"); */
-    /* MAT3print(R, stdout); */
+    // printf("Roll matrix\n");
+    // MAT3print(R, stdout);
 
     MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
-    /* MAT3mult_vec(vec, vec, R); */
+    // MAT3mult_vec(vec, vec, R);
     MAT3rotate(TMP, vec, FG_Theta);
-    /* printf("Pitch matrix\n"); */
-    /* MAT3print(TMP, stdout); */
+    // printf("Pitch matrix\n");
+    // MAT3print(TMP, stdout);
     MAT3mult(R, R, TMP);
 
     MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
-    /* MAT3mult_vec(vec, vec, R); */
-    /* MAT3rotate(TMP, vec, FG_Psi - FG_PI_2); */
+    // MAT3mult_vec(vec, vec, R);
+    // MAT3rotate(TMP, vec, FG_Psi - FG_PI_2);
     MAT3rotate(TMP, vec, -FG_Psi);
-    /* printf("Yaw matrix\n");
-    MAT3print(TMP, stdout); */
+    // printf("Yaw matrix\n");
+    // MAT3print(TMP, stdout);
     MAT3mult(LOCAL, R, TMP);
-    /* printf("LOCAL matrix\n"); */
-    /* MAT3print(LOCAL, stdout); */
+    // printf("LOCAL matrix\n");
+    // MAT3print(LOCAL, stdout);
 
-    /* Derive the local UP transformation matrix based on *geodetic*
-     * coordinates */
+    // Derive the local UP transformation matrix based on *geodetic*
+    // coordinates
     MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
-    MAT3rotate(R, vec, FG_Longitude);     /* R = rotate about Z axis */
-    /* printf("Longitude matrix\n"); */
-    /* MAT3print(R, stdout); */
+    MAT3rotate(R, vec, FG_Longitude);     // R = rotate about Z axis
+    // printf("Longitude matrix\n");
+    // MAT3print(R, stdout);
 
     MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
     MAT3mult_vec(vec, vec, R);
-    MAT3rotate(TMP, vec, -FG_Latitude);  /* TMP = rotate about X axis */
-    /* printf("Latitude matrix\n"); */
-    /* MAT3print(TMP, stdout); */
+    MAT3rotate(TMP, vec, -FG_Latitude);  // TMP = rotate about X axis
+    // printf("Latitude matrix\n");
+    // MAT3print(TMP, stdout);
 
     MAT3mult(UP, R, TMP);
-    /* printf("Local up matrix\n"); */
-    /* MAT3print(UP, stdout); */
+    // printf("Local up matrix\n");
+    // MAT3print(UP, stdout);
 
     MAT3_SET_VEC(v->local_up, 1.0, 0.0, 0.0);
     MAT3mult_vec(v->local_up, v->local_up, UP);
 
-    /* printf("Local Up = (%.4f, %.4f, %.4f)\n",
-          v->local_up[0], v->local_up[1], v->local_up[2]); */
+    // printf( "Local Up = (%.4f, %.4f, %.4f)\n",
+    //         v->local_up[0], v->local_up[1], v->local_up[2]);
     
-    /* Alternative method to Derive local up vector based on
-     * *geodetic* coordinates */
-    /* alt_up = fgPolarToCart(FG_Longitude, FG_Latitude, 1.0); */
-    /* printf("    Alt Up = (%.4f, %.4f, %.4f)\n", 
-       alt_up.x, alt_up.y, alt_up.z); */
+    // Alternative method to Derive local up vector based on
+    // *geodetic* coordinates
+    // alt_up = fgPolarToCart(FG_Longitude, FG_Latitude, 1.0);
+    // printf( "    Alt Up = (%.4f, %.4f, %.4f)\n", 
+    //         alt_up.x, alt_up.y, alt_up.z);
 
-    /* Calculate the VIEW matrix */
+    // Calculate the VIEW matrix
     MAT3mult(VIEW, LOCAL, UP);
-    /* printf("VIEW matrix\n"); */
-    /* MAT3print(VIEW, stdout); */
+    // printf("VIEW matrix\n");
+    // MAT3print(VIEW, stdout);
 
-    /* generate the current up, forward, and fwrd-view vectors */
+    // generate the current up, forward, and fwrd-view vectors
     MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
     MAT3mult_vec(v->view_up, vec, VIEW);
 
     MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
     MAT3mult_vec(forward, vec, VIEW);
-    /* printf("Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1], 
-          forward[2]); */
+    // printf( "Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1], 
+    //         forward[2]);
 
     MAT3rotate(TMP, v->view_up, v->view_offset);
     MAT3mult_vec(v->view_forward, forward, TMP);
 
-    /* Given a vector from the view position to the point on the
-     * earth's surface the sun is directly over, map into onto the
-     * local plane representing "horizontal". */
-    map_vec_onto_cur_surface_plane(v->local_up, v0, v->to_sun, 
-                                  v->surface_to_sun);
-    MAT3_NORMALIZE_VEC(v->surface_to_sun, ntmp);
-    /* printf("Surface direction to sun is %.2f %.2f %.2f\n",
-          v->surface_to_sun[0], v->surface_to_sun[1], v->surface_to_sun[2]); */
-    /* printf("Should be close to zero = %.2f\n", 
-          MAT3_DOT_PRODUCT(v->local_up, v->surface_to_sun)); */
-
-    /* Given a vector pointing straight down (-Z), map into onto the
-     * local plane representing "horizontal".  This should give us the
-     * local direction for moving "south". */
+    // make a vector to the current view position
+    MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
+
+    // Given a vector pointing straight down (-Z), map into onto the
+    // local plane representing "horizontal".  This should give us the
+    // local direction for moving "south".
     MAT3_SET_VEC(minus_z, 0.0, 0.0, -1.0);
     map_vec_onto_cur_surface_plane(v->local_up, v0, minus_z, v->surface_south);
     MAT3_NORMALIZE_VEC(v->surface_south, ntmp);
-    /* printf("Surface direction directly south %.2f %.2f %.2f\n",
-          v->surface_south[0], v->surface_south[1], v->surface_south[2]); */
+    // printf( "Surface direction directly south %.2f %.2f %.2f\n",
+    //         v->surface_south[0], v->surface_south[1], v->surface_south[2]);
 
-    /* now calculate the surface east vector */
+    // now calculate the surface east vector
     MAT3rotate(TMP, v->view_up, FG_PI_2);
     MAT3mult_vec(v->surface_east, v->surface_south, TMP);
-    /* printf("Surface direction directly east %.2f %.2f %.2f\n",
-          v->surface_east[0], v->surface_east[1], v->surface_east[2]); */
-    /* printf("Should be close to zero = %.2f\n", 
-          MAT3_DOT_PRODUCT(v->surface_south, v->surface_east)); */
+    // printf( "Surface direction directly east %.2f %.2f %.2f\n",
+    //         v->surface_east[0], v->surface_east[1], v->surface_east[2]);
+    // printf( "Should be close to zero = %.2f\n", 
+    //         MAT3_DOT_PRODUCT(v->surface_south, v->surface_east));
 }
 
 
-/* $Log$
-/* Revision 1.2  1998/04/24 00:49:22  curt
-/* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
-/* Trying out some different option parsing code.
-/* Some code reorganization.
-/*
- * Revision 1.1  1998/04/22 13:25:45  curt
- * C++ - ifing the code.
- * Starting a bit of reorganization of lighting code.
- *
- * Revision 1.16  1998/04/18 04:11:29  curt
- * Moved fg_debug to it's own library, added zlib support.
- *
- * Revision 1.15  1998/02/20 00:16:24  curt
- * Thursday's tweaks.
- *
- * Revision 1.14  1998/02/09 15:07:50  curt
- * Minor tweaks.
- *
- * Revision 1.13  1998/02/07 15:29:45  curt
- * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
- * <chotchkiss@namg.us.anritsu.com>
- *
- * Revision 1.12  1998/01/29 00:50:28  curt
- * Added a view record field for absolute x, y, z position.
- *
- * Revision 1.11  1998/01/27 00:47:58  curt
- * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.10  1998/01/19 19:27:09  curt
- * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
- * This should simplify things tremendously.
- *
- * Revision 1.9  1998/01/13 00:23:09  curt
- * Initial changes to support loading and management of scenery tiles.  Note,
- * there's still a fair amount of work left to be done.
- *
- * Revision 1.8  1997/12/30 22:22:33  curt
- * Further integration of event manager.
- *
- * Revision 1.7  1997/12/30 20:47:45  curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.6  1997/12/22 04:14:32  curt
- * Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
- *
- * Revision 1.5  1997/12/18 04:07:02  curt
- * Worked on properly translating and positioning the sky dome.
- *
- * Revision 1.4  1997/12/17 23:13:36  curt
- * Began working on rendering a sky.
- *
- * Revision 1.3  1997/12/15 23:54:50  curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.2  1997/12/10 22:37:48  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.1  1997/08/27 21:31:17  curt
- * Initial revision.
- *
- */
+// $Log$
+// Revision 1.3  1998/04/25 20:24:02  curt
+// Cleaned up initialization sequence to eliminate interdependencies
+// between sun position, lighting, and view position.  This creates a
+// valid single pass initialization path.
+//
+// Revision 1.2  1998/04/24 00:49:22  curt
+// Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
+// Trying out some different option parsing code.
+// Some code reorganization.
+//
+// Revision 1.1  1998/04/22 13:25:45  curt
+// C++ - ifing the code.
+// Starting a bit of reorganization of lighting code.
+//
+// Revision 1.16  1998/04/18 04:11:29  curt
+// Moved fg_debug to it's own library, added zlib support.
+//
+// Revision 1.15  1998/02/20 00:16:24  curt
+// Thursday's tweaks.
+//
+// Revision 1.14  1998/02/09 15:07:50  curt
+// Minor tweaks.
+//
+// Revision 1.13  1998/02/07 15:29:45  curt
+// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+// <chotchkiss@namg.us.anritsu.com>
+//
+// Revision 1.12  1998/01/29 00:50:28  curt
+// Added a view record field for absolute x, y, z position.
+//
+// Revision 1.11  1998/01/27 00:47:58  curt
+// Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+// system and commandline/config file processing code.
+//
+// Revision 1.10  1998/01/19 19:27:09  curt
+// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+// This should simplify things tremendously.
+//
+// Revision 1.9  1998/01/13 00:23:09  curt
+// Initial changes to support loading and management of scenery tiles.  Note,
+// there's still a fair amount of work left to be done.
+//
+// Revision 1.8  1997/12/30 22:22:33  curt
+// Further integration of event manager.
+//
+// Revision 1.7  1997/12/30 20:47:45  curt
+// Integrated new event manager with subsystem initializations.
+//
+// Revision 1.6  1997/12/22 04:14:32  curt
+// Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
+//
+// Revision 1.5  1997/12/18 04:07:02  curt
+// Worked on properly translating and positioning the sky dome.
+//
+// Revision 1.4  1997/12/17 23:13:36  curt
+// Began working on rendering a sky.
+//
+// Revision 1.3  1997/12/15 23:54:50  curt
+// Add xgl wrappers for debugging.
+// Generate terrain normals on the fly.
+//
+// Revision 1.2  1997/12/10 22:37:48  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.1  1997/08/27 21:31:17  curt
+// Initial revision.
+//
index 1715ea12b27c9c1316df4b6d6c708353c39ce794..91c578a4964cc4622e1098e4f6c491e4db22e4d5 100644 (file)
@@ -2,6 +2,9 @@
 | Done
 --------------------------------------------------------------------------
 
+4/25/98 -  Clean up initialization sequence and eliminate
+           interdependencies between lighting and position.
+
 4/23/98 -  encapsulate all #include <config.h>'s with #ifdef HAVE_CONFIG_H
 
 4/23/98 -  Give all textured polygons ambient and diffuse glMaterial()
index a591d01ac119b5e34d7be6cc509e1953e4a6d0db..6a378b28c8165edd78c2d9cd87f8fa523f512a58 100644 (file)
@@ -2,8 +2,11 @@
 | Todo 
 --------------------------------------------------------------------------
 
-4/24/98 -  Clean up initialization sequence and eliminate
-           interdependencies between lighting and position.
+4/25/98 -  Roll all of Time/sunpos.cxx into Astro/sun.cxx
+
+4/25/98 -  Overhaul view parameter generation ... see if we can piggy
+           back off of larcsim calcs, and consolate potentially
+           redundant code
 
 4/21/98 -  Tweak lighting parameter interpolation tables to better fit
            "perceived" reality
index e7a41e36686b99457beb16ddd0a8fbd4351509d9..a21925aa9b64dd4bb7eb58e997b3824fe483eaa9 100644 (file)
@@ -79,7 +79,7 @@ void timestamp(fg_timestamp *timestamp) {
 #if defined( HAVE_GETTIMEOFDAY )
     struct timeval current;
     struct timezone tz;
-    fg_timestamp currtime;
+    // fg_timestamp currtime;
     gettimeofday(&current, &tz);
     timestamp->seconds = current.tv_sec;
     timestamp->millis = current.tv_usec / 1000;
@@ -311,8 +311,7 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) {
 }
 
 
-// Update the time dependent variables
-
+// Update time variables such as gmt, julian date, and sidereal time
 void fgTimeUpdate(fgFLIGHT *f, struct fgTIME *t) {
     double gst_precise, gst_course;
 
@@ -376,6 +375,11 @@ void fgTimeUpdate(fgFLIGHT *f, struct fgTIME *t) {
 
 
 // $Log$
+// Revision 1.2  1998/04/25 20:24:02  curt
+// Cleaned up initialization sequence to eliminate interdependencies
+// between sun position, lighting, and view position.  This creates a
+// valid single pass initialization path.
+//
 // Revision 1.1  1998/04/24 00:52:27  curt
 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
 // Fog color fixes.
index 45e37ee906d14a9597e14f3916c4d9d22d5d5c73..edad9a79569413bf56d1cf360e7a6cc2ddcd7616 100644 (file)
@@ -103,7 +103,7 @@ long timediff(fg_timestamp *first, fg_timestamp *last);
 void timesum(fg_timestamp *res, fg_timestamp *start, long millis);
 
 
-// Initialize the time dependent variables
+// Update time variables such as gmt, julian date, and sidereal time
 void fgTimeInit(struct fgTIME *t);
 
 
@@ -115,6 +115,11 @@ void fgTimeUpdate(fgFLIGHT *f, struct fgTIME *t);
 
 
 // $Log$
+// Revision 1.2  1998/04/25 20:24:03  curt
+// Cleaned up initialization sequence to eliminate interdependencies
+// between sun position, lighting, and view position.  This creates a
+// valid single pass initialization path.
+//
 // Revision 1.1  1998/04/24 00:52:28  curt
 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
 // Fog color fixes.
index dfa79164e314ac45044c93c537f268382ee9eff5..ebd397cbffc51c303efb839cabc6083580b2f70e 100644 (file)
@@ -48,6 +48,11 @@ unsigned long int fgSimTime;
 
 /* This routine catches the SIGALRM */
 void fgTimerCatch( int dummy ) {
+    int warning_avoider;
+
+    // get past a compiler warning
+    warning_avoider = dummy;
+
     /* ignore any SIGALRM's until we come back from our EOM iteration */
     signal(SIGALRM, SIG_IGN);
 
@@ -112,11 +117,16 @@ int fgGetTimeInterval( void ) {
 
 
 /* $Log$
-/* Revision 1.1  1998/04/24 00:52:29  curt
-/* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
-/* Fog color fixes.
-/* Separated out lighting calcs into their own file.
+/* Revision 1.2  1998/04/25 20:24:03  curt
+/* Cleaned up initialization sequence to eliminate interdependencies
+/* between sun position, lighting, and view position.  This creates a
+/* valid single pass initialization path.
 /*
+ * Revision 1.1  1998/04/24 00:52:29  curt
+ * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
+ * Fog color fixes.
+ * Separated out lighting calcs into their own file.
+ *
  * Revision 1.12  1998/04/21 17:01:44  curt
  * Fixed a problems where a pointer to a function was being passed around.  In
  * one place this functions arguments were defined as ( void ) while in another
index 65f0b70b22091f31e96e0dd637bd511d332051d3..b0144b1cc47aee1b5d233dd477f4139f4b5f75c9 100644 (file)
@@ -1,42 +1,40 @@
-/*
- * sunpos.c
- * kirk johnson
- * july 1993
- *
- * code for calculating the position on the earth's surface for which
- * the sun is directly overhead (adapted from _practical astronomy
- * with your calculator, third edition_, peter duffett-smith,
- * cambridge university press, 1988.)
- *
- * RCS $Id$
- *
- * Copyright (C) 1989, 1990, 1993, 1994, 1995 Kirk Lauritz Johnson
- *
- * Parts of the source code (as marked) are:
- *   Copyright (C) 1989, 1990, 1991 by Jim Frost
- *   Copyright (C) 1992 by Jamie Zawinski <jwz@lucid.com>
- *
- * Permission to use, copy, modify and freely distribute xearth for
- * non-commercial and not-for-profit purposes is hereby granted
- * without fee, provided that both the above copyright notice and this
- * permission notice appear in all copies and in supporting
- * documentation.
- *
- * The author makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT
- * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * $Id$
- * (Log is kept at end of this file)
- */
+// sunpos.c (taken from XEarth)
+// kirk johnson
+// july 1993
+//
+// code for calculating the position on the earth's surface for which
+// the sun is directly overhead (adapted from _practical astronomy
+// with your calculator, third edition_, peter duffett-smith,
+// cambridge university press, 1988.)
+//
+// RCS $Id$
+//
+// Copyright (C) 1989, 1990, 1993, 1994, 1995 Kirk Lauritz Johnson
+//
+// Parts of the source code (as marked) are:
+//   Copyright (C) 1989, 1990, 1991 by Jim Frost
+//   Copyright (C) 1992 by Jamie Zawinski <jwz@lucid.com>
+//
+// Permission to use, copy, modify and freely distribute xearth for
+// non-commercial and not-for-profit purposes is hereby granted
+// without fee, provided that both the above copyright notice and this
+// permission notice appear in all copies and in supporting
+// documentation.
+//
+// The author makes no representations about the suitability of this
+// software for any purpose. It is provided "as is" without express or
+// implied warranty.
+//
+// THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT
+// OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+// NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+//
+// $Id$
+// (Log is kept at end of this file)
 
 
 #ifdef HAVE_CONFIG_H
@@ -53,6 +51,8 @@
 #include <Math/fg_geodesy.h>
 #include <Math/mat3.h>
 #include <Math/polar.h>
+#include <Math/vector.h>
+#include <Scenery/scenery.h>
 
 #include "fg_time.hxx"
 #include "sunpos.hxx"
@@ -270,22 +270,14 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) {
 }
 
 
-/* update the cur_time_params structure with the current sun position */
+// update the cur_time_params structure with the current sun position
 void fgUpdateSunPos( void ) {
     struct fgLIGHT *l;
     struct fgTIME *t;
     struct fgVIEW *v;
-    MAT3vec nup, nsun;
-    /* if the 4th field is 0.0, this specifies a direction ... */
-    GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
-    /* base sky color */
-    GLfloat base_sky_color[4] =        {0.60, 0.60, 0.90, 1.0};
-    /* base fog color */
-    GLfloat base_fog_color[4] = {0.70, 0.70, 0.70, 1.0};
-    double sun_gd_lat, sl_radius, temp;
-    double x_2, x_4, x_8, x_10;
-    double light, ambient, diffuse, sky_brightness;
-    static int time_warp = 0;
+    MAT3vec nup, nsun, v0;
+    double sun_gd_lat, sl_radius;
+    double ntmp;
 
     l = &cur_light_params;
     t = &cur_time_params;
@@ -293,153 +285,171 @@ void fgUpdateSunPos( void ) {
 
     printf("  Updating Sun position\n");
 
-    time_warp += 0; /* increase this to make the world spin real fast */
-
-    fgSunPosition(t->cur_time + time_warp, &l->sun_lon, &sun_gd_lat);
+    fgSunPosition(t->cur_time, &l->sun_lon, &sun_gd_lat);
+    fgSunPosition(t->cur_time, &l->sun_lon, &sun_gd_lat);
 
     fgGeodToGeoc(sun_gd_lat, 0.0, &sl_radius, &l->sun_gc_lat);
 
     l->fg_sunpos = fgPolarToCart(l->sun_lon, l->sun_gc_lat, sl_radius);
 
-    /* printf("  Geodetic lat = %.5f Geocentric lat = %.5f\n", sun_gd_lat,
-       t->sun_gc_lat); */
+    printf( "    t->cur_time = %ld\n", t->cur_time);
+    printf( "    Sun Geodetic lat = %.5f Geocentric lat = %.5f\n",
+           sun_gd_lat, l->sun_gc_lat);
 
-    /* FALSE! (?> the sun position has to be translated just like
-     * everything else */
-    /* l->sun_vec_inv[0] = l->fg_sunpos.x - scenery_center.x;  */
-    /* l->sun_vec_inv[1] = l->fg_sunpos.y - scenery_center.y; */
-    /* l->sun_vec_inv[2] = l->fg_sunpos.z - scenery_center.z; */
-    /* MAT3_SCALE_VEC(l->sun_vec, l->sun_vec_inv, -1.0); */
-
-    /* I think this will work better for generating the sun light vector */
+    // I think this will work better for generating the sun light vector
     l->sun_vec[0] = l->fg_sunpos.x;
     l->sun_vec[1] = l->fg_sunpos.y;
     l->sun_vec[2] = l->fg_sunpos.z;
-    MAT3_NORMALIZE_VEC(l->sun_vec, temp);
+    MAT3_NORMALIZE_VEC(l->sun_vec, ntmp);
     MAT3_SCALE_VEC(l->sun_vec_inv, l->sun_vec, -1.0);
 
-    /* make these are directional light sources only */
+    // make sure these are directional light sources only
     l->sun_vec[3] = 0.0;
     l->sun_vec_inv[3] = 0.0;
 
     printf("  l->sun_vec = %.2f %.2f %.2f\n", l->sun_vec[0], l->sun_vec[1],
           l->sun_vec[2]);
 
-    /* calculate the sun's relative angle to local up */
+    // calculate the sun's relative angle to local up
     MAT3_COPY_VEC(nup, v->local_up);
     nsun[0] = l->fg_sunpos.x; 
     nsun[1] = l->fg_sunpos.y;
     nsun[2] = l->fg_sunpos.z;
-    MAT3_NORMALIZE_VEC(nup, temp);
-    MAT3_NORMALIZE_VEC(nsun, temp);
+    MAT3_NORMALIZE_VEC(nup, ntmp);
+    MAT3_NORMALIZE_VEC(nsun, ntmp);
 
     l->sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
     printf("  SUN ANGLE relative to current location = %.3f rads.\n", 
           l->sun_angle);
+    
+    // calculate vector to sun's position on the earth's surface
+    v->to_sun[0] = l->fg_sunpos.x - (v->view_pos.x + scenery.center.x);
+    v->to_sun[1] = l->fg_sunpos.y - (v->view_pos.y + scenery.center.y);
+    v->to_sun[2] = l->fg_sunpos.z - (v->view_pos.z + scenery.center.z);
+    // printf( "Vector to sun = %.2f %.2f %.2f\n",
+    //         v->to_sun[0], v->to_sun[1], v->to_sun[2]);
+
+    // make a vector to the current view position
+    MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
+
+    // Given a vector from the view position to the point on the
+    // earth's surface the sun is directly over, map into onto the
+    // local plane representing "horizontal".
+    map_vec_onto_cur_surface_plane(v->local_up, v0, v->to_sun, 
+                                  v->surface_to_sun);
+    MAT3_NORMALIZE_VEC(v->surface_to_sun, ntmp);
+    // printf("Surface direction to sun is %.2f %.2f %.2f\n",
+    //        v->surface_to_sun[0], v->surface_to_sun[1], v->surface_to_sun[2]);
+    // printf("Should be close to zero = %.2f\n", 
+    //        MAT3_DOT_PRODUCT(v->local_up, v->surface_to_sun));
 }
 
 
-/* $Log$
-/* Revision 1.2  1998/04/24 00:52:31  curt
-/* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
-/* Fog color fixes.
-/* Separated out lighting calcs into their own file.
-/*
- * Revision 1.1  1998/04/22 13:24:07  curt
- * C++ - ifiing the code a bit.
- * Starting to reorginize some of the lighting calcs to use a table lookup.
- *
- * Revision 1.27  1998/04/03 22:12:57  curt
- * Converting to Gnu autoconf system.
- * Centralized time handling differences.
- *
- * Revision 1.26  1998/02/23 19:08:00  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.25  1998/02/09 15:07:53  curt
- * Minor tweaks.
- *
- * Revision 1.24  1998/01/27 00:48:07  curt
- * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.23  1998/01/19 19:27:21  curt
- * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
- * This should simplify things tremendously.
- *
- * Revision 1.22  1998/01/19 18:40:40  curt
- * Tons of little changes to clean up the code and to remove fatal errors
- * when building with the c++ compiler.
- *
- * Revision 1.21  1997/12/30 23:10:19  curt
- * Calculate lighting parameters here.
- *
- * Revision 1.20  1997/12/30 22:22:43  curt
- * Further integration of event manager.
- *
- * Revision 1.19  1997/12/30 20:47:59  curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.18  1997/12/23 04:58:40  curt
- * Tweaked the sky coloring a bit to build in structures to allow finer rgb
- * control.
- *
- * Revision 1.17  1997/12/15 23:55:08  curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.16  1997/12/11 04:43:57  curt
- * Fixed sun vector and lighting problems.  I thing the moon is now lit
- * correctly.
- *
- * Revision 1.15  1997/12/10 22:37:55  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.14  1997/12/09 04:25:39  curt
- * Working on adding a global lighting params structure.
- *
- * Revision 1.13  1997/11/25 19:25:42  curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.12  1997/11/15 18:15:39  curt
- * Reverse direction of sun vector, so object normals can be more normal.
- *
- * Revision 1.11  1997/10/28 21:07:21  curt
- * Changed GLUT/ -> Main/
- *
- * Revision 1.10  1997/09/13 02:00:09  curt
- * Mostly working on stars and generating sidereal time for accurate star
- * placement.
- *
- * Revision 1.9  1997/09/05 14:17:31  curt
- * More tweaking with stars.
- *
- * Revision 1.8  1997/09/05 01:36:04  curt
- * Working on getting stars right.
- *
- * Revision 1.7  1997/09/04 02:17:40  curt
- * Shufflin' stuff.
- *
- * Revision 1.6  1997/08/27 03:30:37  curt
- * Changed naming scheme of basic shared structures.
- *
- * Revision 1.5  1997/08/22 21:34:41  curt
- * Doing a bit of reorganizing and house cleaning.
- *
- * Revision 1.4  1997/08/19 23:55:09  curt
- * Worked on better simulating real lighting.
- *
- * Revision 1.3  1997/08/13 20:23:49  curt
- * The interface to sunpos now updates a global structure rather than returning
- * current sun position.
- *
- * Revision 1.2  1997/08/06 00:24:32  curt
- * Working on correct real time sun lighting.
- *
- * Revision 1.1  1997/08/01 15:27:56  curt
- * Initial revision.
- *
- */
+// $Log$
+// Revision 1.3  1998/04/25 20:24:03  curt
+// Cleaned up initialization sequence to eliminate interdependencies
+// between sun position, lighting, and view position.  This creates a
+// valid single pass initialization path.
+//
+// Revision 1.2  1998/04/24 00:52:31  curt
+// Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
+// Fog color fixes.
+// Separated out lighting calcs into their own file.
+//
+// Revision 1.1  1998/04/22 13:24:07  curt
+// C++ - ifiing the code a bit.
+// Starting to reorginize some of the lighting calcs to use a table lookup.
+//
+// Revision 1.27  1998/04/03 22:12:57  curt
+// Converting to Gnu autoconf system.
+// Centralized time handling differences.
+//
+// Revision 1.26  1998/02/23 19:08:00  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.25  1998/02/09 15:07:53  curt
+// Minor tweaks.
+//
+// Revision 1.24  1998/01/27 00:48:07  curt
+// Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+// system and commandline/config file processing code.
+//
+// Revision 1.23  1998/01/19 19:27:21  curt
+// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+// This should simplify things tremendously.
+//
+// Revision 1.22  1998/01/19 18:40:40  curt
+// Tons of little changes to clean up the code and to remove fatal errors
+// when building with the c++ compiler.
+//
+// Revision 1.21  1997/12/30 23:10:19  curt
+// Calculate lighting parameters here.
+//
+// Revision 1.20  1997/12/30 22:22:43  curt
+// Further integration of event manager.
+//
+// Revision 1.19  1997/12/30 20:47:59  curt
+// Integrated new event manager with subsystem initializations.
+//
+// Revision 1.18  1997/12/23 04:58:40  curt
+// Tweaked the sky coloring a bit to build in structures to allow finer rgb
+// control.
+//
+// Revision 1.17  1997/12/15 23:55:08  curt
+// Add xgl wrappers for debugging.
+// Generate terrain normals on the fly.
+//
+// Revision 1.16  1997/12/11 04:43:57  curt
+// Fixed sun vector and lighting problems.  I thing the moon is now lit
+// correctly.
+//
+// Revision 1.15  1997/12/10 22:37:55  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.14  1997/12/09 04:25:39  curt
+// Working on adding a global lighting params structure.
+//
+// Revision 1.13  1997/11/25 19:25:42  curt
+// Changes to integrate Durk's moon/sun code updates + clean up.
+//
+// Revision 1.12  1997/11/15 18:15:39  curt
+// Reverse direction of sun vector, so object normals can be more normal.
+//
+// Revision 1.11  1997/10/28 21:07:21  curt
+// Changed GLUT/ -> Main/
+//
+// Revision 1.10  1997/09/13 02:00:09  curt
+// Mostly working on stars and generating sidereal time for accurate star
+// placement.
+//
+// Revision 1.9  1997/09/05 14:17:31  curt
+// More tweaking with stars.
+//
+// Revision 1.8  1997/09/05 01:36:04  curt
+// Working on getting stars right.
+//
+// Revision 1.7  1997/09/04 02:17:40  curt
+// Shufflin' stuff.
+//
+// Revision 1.6  1997/08/27 03:30:37  curt
+// Changed naming scheme of basic shared structures.
+//
+// Revision 1.5  1997/08/22 21:34:41  curt
+// Doing a bit of reorganizing and house cleaning.
+//
+// Revision 1.4  1997/08/19 23:55:09  curt
+// Worked on better simulating real lighting.
+//
+// Revision 1.3  1997/08/13 20:23:49  curt
+// The interface to sunpos now updates a global structure rather than returning
+// current sun position.
+//
+// Revision 1.2  1997/08/06 00:24:32  curt
+// Working on correct real time sun lighting.
+//
+// Revision 1.1  1997/08/01 15:27:56  curt
+// Initial revision.
+//
index 8719ef994f14517264e996747d6d3bc89d687450..fec2686584c9b41214b7a50565f2cc238c1fcb95 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * sunpos.hxx
+ * sunpos.hxx (taken from XEarth)
  * kirk johnson
  * july 1993
  *