]> git.mxchange.org Git - flightgear.git/blob - Simulator/Time/fg_time.hxx
Initial revision
[flightgear.git] / Simulator / Time / fg_time.hxx
1 //
2 // fg_time.hxx -- data structures and routines for managing time related stuff.
3 //
4 // Written by Curtis Olson, started August 1997.
5 //
6 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23 // (Log is kept at end of this file)
24
25
26 #ifndef _FG_TIME_HXX
27 #define _FG_TIME_HXX
28
29
30 #ifndef __cplusplus                                                          
31 # error This library requires C++
32 #endif                                   
33
34
35 #ifdef HAVE_CONFIG_H
36 #  include <config.h>
37 #endif
38
39 #ifdef HAVE_WINDOWS_H
40 #  include <windows.h>
41 #endif
42
43 #include <GL/glut.h>
44
45 #include "Include/compiler.h"
46 #ifdef FG_HAVE_STD_INCLUDES
47 #  include <ctime>
48 #else
49 #  include <time.h>
50 #endif
51
52 #include <FDM/flight.hxx>
53
54
55 // Define a structure containing global time parameters
56 typedef struct {
57     // the date/time in various forms
58     // Unix "calendar" time in seconds
59     time_t cur_time;
60
61     // Break down of GMT time
62     struct tm *gmt;
63
64     // Julian date
65     double jd;
66
67     // modified Julian date
68     double mjd;
69
70     // side real time at prime meridian
71     double gst;
72
73     // local side real time
74     double lst;
75
76     // the difference between the precise sidereal time algorithm
77     // result and the course result.  
78     // course + diff has good accuracy for the short term
79     double gst_diff;
80
81     // An offset in seconds from the true time.  Allows us to adjust
82     // the effective time of day.
83     long int warp;
84
85     // How much to change the value of warp each iteration.  Allows us
86     // to make time progress faster than normal.
87     long int warp_delta; 
88
89     // Paused (0 = no, 1 = yes)
90     int pause;
91 } fgTIME;
92
93 extern fgTIME cur_time_params;
94
95
96 // Update time variables such as gmt, julian date, and sidereal time
97 void fgTimeInit(fgTIME *t);
98
99
100 // Update the time dependent variables
101 void fgTimeUpdate(FGInterface *f, fgTIME *t);
102
103
104 #endif // _FG_TIME_HXX
105
106
107 // $Log$
108 // Revision 1.1  1999/04/05 21:32:47  curt
109 // Initial revision
110 //
111 // Revision 1.14  1999/02/05 21:29:19  curt
112 // Modifications to incorporate Jon S. Berndts flight model code.
113 //
114 // Revision 1.13  1999/02/01 21:33:39  curt
115 // Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
116 // Jon accepted my offer to do this and thought it was a good idea.
117 //
118 // Revision 1.12  1999/01/07 20:25:35  curt
119 // Portability changes and updates from Bernie Bright.
120 //
121 // Revision 1.11  1998/12/05 15:54:29  curt
122 // Renamed class fgFLIGHT to class FGState as per request by JSB.
123 //
124 // Revision 1.10  1998/12/05 14:21:31  curt
125 // Moved struct fg_timestamp to class fgTIMESTAMP and moved it's definition
126 // to it's own file, timestamp.hxx.
127 //
128 // Revision 1.9  1998/12/04 01:32:50  curt
129 // Converted "struct fg_timestamp" to "class fgTIMESTAMP" and added some
130 // convenience inline operators.
131 //
132 // Revision 1.8  1998/10/16 23:28:00  curt
133 // C++-ifying.
134 //
135 // Revision 1.7  1998/10/16 00:56:09  curt
136 // Converted to Point3D class.
137 //
138 // Revision 1.6  1998/07/27 18:42:22  curt
139 // Added a pause option.
140 //
141 // Revision 1.5  1998/05/22 21:14:54  curt
142 // Rewrote event.cxx in C++ as a class using STL for the internal event list
143 // and run queue this removes the arbitrary list sizes and makes things much
144 // more dynamic.  Because this is C++-classified we can now have multiple
145 // event_tables if we'd ever want them.
146 //
147 // Revision 1.4  1998/04/28 01:22:17  curt
148 // Type-ified fgTIME and fgVIEW.
149 //
150 // Revision 1.3  1998/04/25 22:06:34  curt
151 // Edited cvs log messages in source files ... bad bad bad!
152 //
153 // Revision 1.2  1998/04/25 20:24:03  curt
154 // Cleaned up initialization sequence to eliminate interdependencies
155 // between sun position, lighting, and view position.  This creates a
156 // valid single pass initialization path.
157 //
158 // Revision 1.1  1998/04/24 00:52:28  curt
159 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
160 // Fog color fixes.
161 // Separated out lighting calcs into their own file.
162 //
163 // Revision 1.20  1998/04/22 13:24:05  curt
164 // C++ - ifiing the code a bit.
165 // Starting to reorginize some of the lighting calcs to use a table lookup.
166 //
167 // Revision 1.19  1998/04/21 17:01:44  curt
168 // Fixed a problems where a pointer to a function was being passed around.  In
169 // one place this functions arguments were defined as ( void ) while in another
170 // place they were defined as ( int ).  The correct answer was ( int ).
171 //
172 // Prepairing for C++ integration.
173 //
174 // Revision 1.18  1998/04/08 23:35:40  curt
175 // Tweaks to Gnu automake/autoconf system.
176 //
177 // Revision 1.17  1998/04/03 22:12:56  curt
178 // Converting to Gnu autoconf system.
179 // Centralized time handling differences.
180 //
181 // Revision 1.16  1998/02/07 15:29:47  curt
182 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
183 // <chotchkiss@namg.us.anritsu.com>
184 //
185 // Revision 1.15  1998/01/27 00:48:06  curt
186 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
187 // system and commandline/config file processing code.
188 //
189 // Revision 1.14  1998/01/22 02:59:43  curt
190 // Changed #ifdef FILE_H to #ifdef _FILE_H
191 //
192 // Revision 1.13  1998/01/19 19:27:20  curt
193 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
194 // This should simplify things tremendously.
195 //
196 // Revision 1.12  1998/01/05 18:44:37  curt
197 // Add an option to advance/decrease time from keyboard.
198 //
199 // Revision 1.11  1997/12/19 23:35:07  curt
200 // Lot's of tweaking with sky rendering and lighting.
201 //
202 // Revision 1.10  1997/12/15 23:55:07  curt
203 // Add xgl wrappers for debugging.
204 // Generate terrain normals on the fly.
205 //
206 // Revision 1.9  1997/12/10 22:37:55  curt
207 // Prepended "fg" on the name of all global structures that didn't have it yet.
208 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
209 //
210 // Revision 1.8  1997/12/09 04:25:38  curt
211 // Working on adding a global lighting params structure.
212 //
213 // Revision 1.7  1997/11/25 19:25:41  curt
214 // Changes to integrate Durk's moon/sun code updates + clean up.
215 //
216 // Revision 1.6  1997/09/20 03:34:35  curt
217 // Still trying to get those durned stars aligned properly.
218 //
219 // Revision 1.5  1997/09/16 15:50:31  curt
220 // Working on star alignment and time issues.
221 //
222 // Revision 1.4  1997/09/13 02:00:08  curt
223 // Mostly working on stars and generating sidereal time for accurate star
224 // placement.
225 //
226 // Revision 1.3  1997/09/04 02:17:39  curt
227 // Shufflin' stuff.
228 //
229 // Revision 1.2  1997/08/27 03:30:36  curt
230 // Changed naming scheme of basic shared structures.
231 //
232 // Revision 1.1  1997/08/13 21:56:00  curt
233 // Initial revision.
234 //