-//
// fg_time.cxx -- data structures and routines for managing time related stuff.
//
// Written by Curtis Olson, started August 1997.
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
-// (Log is kept at end of this file)
#ifdef HAVE_CONFIG_H
}
-// $Log$
-// Revision 1.1 1999/04/05 21:32:47 curt
-// Initial revision
-//
-// Revision 1.32 1999/02/26 22:10:10 curt
-// Added initial support for native SGI compilers.
-//
-// Revision 1.31 1999/02/05 21:29:18 curt
-// Modifications to incorporate Jon S. Berndts flight model code.
-//
-// Revision 1.30 1999/02/01 21:33:37 curt
-// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
-// Jon accepted my offer to do this and thought it was a good idea.
-//
-// Revision 1.29 1999/01/19 20:57:08 curt
-// MacOS portability changes contributed by "Robert Puyol" <puyol@abvent.fr>
-//
-// Revision 1.28 1999/01/07 20:25:34 curt
-// Portability changes and updates from Bernie Bright.
-//
-// Revision 1.27 1998/12/11 20:26:55 curt
-// #include tweaks.
-//
-// Revision 1.26 1998/12/05 15:54:28 curt
-// Renamed class fgFLIGHT to class FGState as per request by JSB.
-//
-// Revision 1.25 1998/12/05 14:21:30 curt
-// Moved struct fg_timestamp to class fgTIMESTAMP and moved it's definition
-// to it's own file, timestamp.hxx.
-//
-// Revision 1.24 1998/12/04 01:32:49 curt
-// Converted "struct fg_timestamp" to "class fgTIMESTAMP" and added some
-// convenience inline operators.
-//
-// Revision 1.23 1998/12/03 01:18:40 curt
-// Converted fgFLIGHT to a class.
-//
-// Revision 1.22 1998/11/16 14:00:28 curt
-// FG_LOG() message tweaks.
-//
-// Revision 1.21 1998/11/06 21:18:26 curt
-// Converted to new logstream debugging facility. This allows release
-// builds with no messages at all (and no performance impact) by using
-// the -DFG_NDEBUG flag.
-//
-// Revision 1.20 1998/11/02 18:25:38 curt
-// Check for __CYGWIN__ (b20) as well as __CYGWIN32__ (pre b20 compilers)
-// Other misc. tweaks.
-//
-// Revision 1.19 1998/10/17 01:34:29 curt
-// C++ ifying ...
-//
-// Revision 1.18 1998/10/02 21:36:09 curt
-// Fixes to try to break through the win95/98 18.3 fps barrier.
-//
-// Revision 1.17 1998/09/15 04:27:49 curt
-// Changes for new astro code.
-//
-// Revision 1.16 1998/08/29 13:11:32 curt
-// Bernie Bright writes:
-// I've created some new classes to enable pointers-to-functions and
-// pointers-to-class-methods to be treated like objects. These objects
-// can be registered with fgEVENT_MGR.
-//
-// File "Include/fg_callback.hxx" contains the callback class defns.
-//
-// Modified fgEVENT and fgEVENT_MGR to use the callback classes. Also
-// some minor tweaks to STL usage.
-//
-// Added file "Include/fg_stl_config.h" to deal with STL portability
-// issues. I've added an initial config for egcs (and probably gcc-2.8.x).
-// I don't have access to Visual C++ so I've left that for someone else.
-// This file is influenced by the stl_config.h file delivered with egcs.
-//
-// Added "Include/auto_ptr.hxx" which contains an implementation of the
-// STL auto_ptr class which is not provided in all STL implementations
-// and is needed to use the callback classes.
-//
-// Deleted fgLightUpdate() which was just a wrapper to call
-// fgLIGHT::Update().
-//
-// Modified fg_init.cxx to register two method callbacks in place of the
-// old wrapper functions.
-//
-// Revision 1.15 1998/08/24 20:12:16 curt
-// Rewrote sidereal_course with simpler parameters.
-//
-// Revision 1.14 1998/08/05 00:20:07 curt
-// Added a local routine to update lighting params every frame when time is
-// accelerated.
-//
-// Revision 1.13 1998/07/30 23:48:55 curt
-// Sgi build tweaks.
-// Pause support.
-//
-// Revision 1.12 1998/07/27 18:42:22 curt
-// Added a pause option.
-//
-// Revision 1.11 1998/07/22 21:45:37 curt
-// fg_time.cxx: Removed call to ctime() in a printf() which should be harmless
-// but seems to be triggering a bug.
-// light.cxx: Added code to adjust fog color based on sunrise/sunset effects
-// and view orientation. This is an attempt to match the fog color to the
-// sky color in the center of the screen. You see discrepancies at the
-// edges, but what else can be done?
-// sunpos.cxx: Caculate local direction to sun here. (what compass direction
-// do we need to face to point directly at sun)
-//
-// Revision 1.10 1998/07/13 21:02:07 curt
-// Wrote access functions for current fgOPTIONS.
-//
-// Revision 1.9 1998/06/12 00:59:53 curt
-// Build only static libraries.
-// Declare memmove/memset for Sloaris.
-// Rewrote fg_time.c routine to get LST start seconds to better handle
-// Solaris, and be easier to port, and understand the GMT vs. local
-// timezone issues.
-//
-// Revision 1.8 1998/06/05 18:18:13 curt
-// Incorporated some automake conditionals to try to support mktime() correctly
-// on a wider variety of platforms.
-// Added the declaration of memmove needed by the stl which apparently
-// solaris only defines for cc compilations and not for c++ (__STDC__)
-//
-// Revision 1.7 1998/05/30 01:57:25 curt
-// misc updates.
-//
-// Revision 1.6 1998/05/02 01:53:17 curt
-// Fine tuning mktime() support because of varying behavior on different
-// platforms.
-//
-// Revision 1.5 1998/04/28 21:45:34 curt
-// Fixed a horible bug that cause the time to be *WAY* off when compiling
-// with the CygWin32 compiler. This may not yet completely address other
-// Win32 compilers, but we'll have to take them on a case by case basis.
-//
-// Revision 1.4 1998/04/28 01:22:16 curt
-// Type-ified fgTIME and fgVIEW.
-//
-// Revision 1.3 1998/04/25 22:06:33 curt
-// Edited cvs log messages in source files ... bad bad bad!
-//
-// 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.
-// Separated out lighting calcs into their own file.
-//
-// Revision 1.41 1998/04/22 13:24:05 curt
-// C++ - ifiing the code a bit.
-// Starting to reorginize some of the lighting calcs to use a table lookup.
-//
-// Revision 1.40 1998/04/18 04:14:09 curt
-// Moved fg_debug.c to it's own library.
-//
-// Revision 1.39 1998/04/09 18:40:14 curt
-// We had unified some of the platform disparate time handling code, and
-// there was a bug in timesum() which calculated a new time stamp based on
-// the current time stamp + offset. This hosed the periodic event processing
-// logic because you'd never arrive at the time the event was scheduled for.
-// Sky updates and lighting changes are handled via this event mechanism so
-// they never changed ... it is fixed now.
-//
-// Revision 1.38 1998/04/08 23:35:40 curt
-// Tweaks to Gnu automake/autoconf system.
-//
-// Revision 1.37 1998/04/03 22:12:55 curt
-// Converting to Gnu autoconf system.
-// Centralized time handling differences.
-//
-// Revision 1.36 1998/03/09 22:48:09 curt
-// Debug message tweaks.
-//
-// Revision 1.35 1998/02/09 15:07:52 curt
-// Minor tweaks.
-//
-// Revision 1.34 1998/02/07 15:29:47 curt
-// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
-// <chotchkiss@namg.us.anritsu.com>
-//
-// Revision 1.33 1998/02/02 20:54:04 curt
-// Incorporated Durk's changes.
-//
-// Revision 1.32 1998/02/01 03:39:56 curt
-// Minor tweaks.
-//
-// Revision 1.31 1998/01/27 00:48:06 curt
-// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
-// system and commandline/config file processing code.
-//
-// Revision 1.30 1998/01/21 21:11:35 curt
-// Misc. tweaks.
-//
-// Revision 1.29 1998/01/19 19:27:20 curt
-// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
-// This should simplify things tremendously.
-//
-// Revision 1.28 1998/01/19 18:35:49 curt
-// Minor tweaks and fixes for cygwin32.
-//
-// Revision 1.27 1998/01/13 00:23:13 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.26 1998/01/05 18:44:36 curt
-// Add an option to advance/decrease time from keyboard.
-//
-// Revision 1.25 1997/12/31 17:46:50 curt
-// Tweaked fg_time.c to be able to use ftime() instead of gettimeofday()
-//
-// Revision 1.24 1997/12/30 22:22:42 curt
-// Further integration of event manager.
-//
-// Revision 1.23 1997/12/30 20:47:58 curt
-// Integrated new event manager with subsystem initializations.
-//
-// Revision 1.22 1997/12/30 01:38:47 curt
-// Switched back to per vertex normals and smooth shading for terrain.
-//
-// Revision 1.21 1997/12/23 04:58:39 curt
-// Tweaked the sky coloring a bit to build in structures to allow finer rgb
-// control.
-//
-// Revision 1.20 1997/12/15 23:55:06 curt
-// Add xgl wrappers for debugging.
-// Generate terrain normals on the fly.
-//
-// Revision 1.19 1997/12/15 20:59:10 curt
-// Misc. tweaks.
-//
-// Revision 1.18 1997/12/12 21:41:31 curt
-// More light/material property tweaking ... still a ways off.
-//
-// Revision 1.17 1997/12/12 19:53:04 curt
-// Working on lightling and material properties.
-//
-// 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:54 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/10 01:19:52 curt
-// Tweaks for verion 0.15 release.
-//
-// Revision 1.13 1997/12/09 05:11:56 curt
-// Working on tweaking lighting.
-//
-// Revision 1.12 1997/12/09 04:25:37 curt
-// Working on adding a global lighting params structure.
-//
-// Revision 1.11 1997/11/25 19:25:40 curt
-// Changes to integrate Durk's moon/sun code updates + clean up.
-//
-// Revision 1.10 1997/11/15 18:16:42 curt
-// minor tweaks.
-//
-// Revision 1.9 1997/11/14 00:26:50 curt
-// Transform scenery coordinates earlier in pipeline when scenery is being
-// created, not when it is being loaded. Precalculate normals for each node
-// as average of the normals of each containing polygon so Garoude shading is
-// now supportable.
-//
-// Revision 1.8 1997/10/25 03:30:08 curt
-// Misc. tweaks.
-//
-// Revision 1.7 1997/09/23 00:29:50 curt
-// Tweaks to get things to compile with gcc-win32.
-//
-// Revision 1.6 1997/09/20 03:34:34 curt
-// Still trying to get those durned stars aligned properly.
-//
-// Revision 1.5 1997/09/16 22:14:52 curt
-// Tweaked time of day lighting equations. Don't draw stars during the day.
-//
-// Revision 1.4 1997/09/16 15:50:31 curt
-// Working on star alignment and time issues.
-//
-// Revision 1.3 1997/09/13 02:00:08 curt
-// Mostly working on stars and generating sidereal time for accurate star
-// placement.
-//
-// Revision 1.2 1997/08/27 03:30:35 curt
-// Changed naming scheme of basic shared structures.
-//
-// Revision 1.1 1997/08/13 21:55:59 curt
-// Initial revision.
-//