-hud.o: cockpit.c cockpit.h hud.c hud.h ../Aircraft/aircraft.h \
+cockpit.o: cockpit.c cockpit.h hud.h ../Aircraft/aircraft.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
../Aircraft/../Flight/LaRCsim/ls_interface.h \
../Aircraft/../Flight/LaRCsim/../flight.h \
../Aircraft/../Controls/controls.h \
- ../Aircraft/../Controls/../limits.h ../Math/fg_random.h
+ ../Aircraft/../Controls/../limits.h ../Flight/flight.h \
+ ../Controls/controls.h ../constants.h ../Scenery/mesh.h \
+ ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \
+ ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \
+ ../Math/fg_random.h ../Weather/weather.h
+hud.o: hud.c hud.h ../Aircraft/aircraft.h \
+ ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
+ ../Aircraft/../Flight/LaRCsim/ls_interface.h \
+ ../Aircraft/../Flight/LaRCsim/../flight.h \
+ ../Aircraft/../Controls/controls.h \
+ ../Aircraft/../Controls/../limits.h ../Flight/flight.h \
+ ../Controls/controls.h ../constants.h ../Scenery/mesh.h \
+ ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \
+ ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \
+ ../Math/fg_random.h ../Weather/weather.h
+test.o: test.c test.h ../Aircraft/aircraft.h \
+ ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
+ ../Aircraft/../Flight/LaRCsim/ls_interface.h \
+ ../Aircraft/../Flight/LaRCsim/../flight.h \
+ ../Aircraft/../Controls/controls.h \
+ ../Aircraft/../Controls/../limits.h ../Flight/flight.h \
+ ../Controls/controls.h ../constants.h ../Scenery/mesh.h \
+ ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \
+ ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \
+ ../Math/fg_random.h ../Weather/weather.h
#include <GL/glut.h>
-
#include <stdlib.h>
+#ifndef WIN32
+# include <values.h> /* for MAXINT */
+#endif /* not WIN32 */
#include "hud.h"
#include "../constants.h"
bank_angle = (*horizon.load_value)();
- // sin_bank = sin( 2*PI-FG_Phi );
- // cos_bank = cos( 2*PI-FG_Phi );
- sin_bank = sin(2*PI-bank_angle);
- cos_bank = cos(2*PI-bank_angle);
+ // sin_bank = sin( FG_2PI-FG_Phi );
+ // cos_bank = cos( FG_2PI-FG_Phi );
+ sin_bank = sin(FG_2PI-bank_angle);
+ cos_bank = cos(FG_2PI-bank_angle);
x_inc1 = (int)(horizon.scr_width*cos_bank);
y_inc1 = (int)(horizon.scr_width*sin_bank);
x_inc2 = (int)(horizon.scr_hole*cos_bank);
hud->code = 123;
hud->status = 0;
- // For now let's just hardcode a hud here .
+ // For now lets just hardcode a hud here .
// In the future, hud information has to come from the same place
// aircraft information came
fgHUDAddHorizon( hud, 590, 50, 40, 20, get_roll );
fgHUDAddScale( hud, VERTICAL, 220, 100, 280, 5, 10, LEFT, LEFT, 0, 100, get_speed );
- fgHUDAddScale( hud, VERTICAL, 440, 100, 280, 1, 5, RIGHT, RIGHT, -MAXINT, 25, get_aoa );
+ fgHUDAddScale( hud, VERTICAL, 440, 100, 280, 1, 5, RIGHT, RIGHT, -400, 25, get_aoa );
fgHUDAddScale( hud, HORIZONTAL, 280, 220, 440, 5, 10, TOP, TOP, 0, 50, get_heading );
fgHUDAddLabel( hud, 180, 85, SMALL, NOBLINK, RIGHT_JUST, NULL, " Kts", "%5.0f", get_speed );
fgHUDAddLabel( hud, 180, 73, SMALL, NOBLINK, RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
return( hud );
}
-
Hptr fgHUDAddHorizon( Hptr hud, int x_pos, int y_pos, int length, \
int hole_len, double (*load_value)() )
{
ladder = (struct HUD_ladder *)calloc(sizeof(struct HUD_ladder),1);
if( ladder == NULL )
return( NULL );
-
+
instrument->type = LADDER;
instrument->instr = *ladder;
instrument->instr.ladder.type = 0; // Not used.
hud->instruments = instrument;
return( hud );
-
}
/*
/* $Log$
-/* Revision 1.1 1997/08/29 18:03:22 curt
-/* Initial revision.
+/* Revision 1.2 1997/09/04 02:17:30 curt
+/* Shufflin' stuff.
/*
+ * Revision 1.1 1997/08/29 18:03:22 curt
+ * Initial revision.
+ *
*/
#define FG_EXTERN_NET 8
-/* Define a structure containing the shared flight model parameters */
-/* struct flight_params {
- double pos_x, pos_y, pos_z;
- double vel_x, vel_y, vel_z;
-
- double Phi;
- double Theta;
- double Psi;
- double vel_Phi;
- double vel_Theta;
- double vel_Psi;
-}; */
-
-
typedef double FG_VECTOR_3[3];
/* This is based heavily on LaRCsim/ls_generic.h */
/* $Log$
-/* Revision 1.8 1997/08/27 03:30:06 curt
-/* Changed naming scheme of basic shared structures.
+/* Revision 1.9 1997/09/04 02:17:33 curt
+/* Shufflin' stuff.
/*
+ * Revision 1.8 1997/08/27 03:30:06 curt
+ * Changed naming scheme of basic shared structures.
+ *
* Revision 1.7 1997/07/23 21:52:19 curt
* Put comments around the text after an #endif for increased portability.
*
static GLfloat win_ratio = 1.0;
/* sun direction */
-static GLfloat sun_vec[4] = {1.0, 0.0, 0.0, 0.0 };
+/* static GLfloat sun_vec[4] = {1.0, 0.0, 0.0, 0.0 }; */
/* if the 4th field is 0.0, this specifies a direction ... */
/* clear color (sky) */
/* pointer to scenery structure */
/* static GLint scenery, runway; */
-/* Another hack */
-/* double view_offset = 0.0;
-double goal_view_offset = 0.0; */
-
double Simtime;
/* Another hack */
**************************************************************************/
static void fgInitVisuals() {
+ struct fgTIME *t;
struct WEATHER *w;
+ t = &cur_time_params;
w = ¤t_weather;
glEnable( GL_DEPTH_TEST );
to unit length after transformation. See glNormal. */
glEnable( GL_NORMALIZE );
- glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
+ glLightfv( GL_LIGHT0, GL_POSITION, t->sun_vec );
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
struct FLIGHT *f;
struct fgTIME *t;
struct VIEW *v;
- MAT3vec nup, nsun;
- double sun_angle, temp, ambient, diffuse, sky;
+ double ambient, diffuse, sky;
GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 };
GLfloat amb[3], diff[3], fog[4], clear[4];
v->view_up[0], v->view_up[1], v->view_up[2]);
/* set the sun position */
- glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
+ glLightfv( GL_LIGHT0, GL_POSITION, t->sun_vec );
/* calculate lighting parameters based on sun's relative angle to
* local up */
- MAT3_COPY_VEC(nup, v->local_up);
- nsun[0] = t->fg_sunpos.x;
- nsun[1] = t->fg_sunpos.y;
- nsun[2] = t->fg_sunpos.z;
- MAT3_NORMALIZE_VEC(nup, temp);
- MAT3_NORMALIZE_VEC(nsun, temp);
-
- sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
- printf("SUN ANGLE relative to current location = %.3f rads.\n", sun_angle);
-
/* ya kind'a have to plot this to see the magic */
- ambient = 0.4 * pow(2.4, -sun_angle*sun_angle*sun_angle*sun_angle/3.0);
- diffuse = 0.4 * cos(0.6*sun_angle*sun_angle);
- sky = 0.85 * pow(1.6, -sun_angle*sun_angle*sun_angle*sun_angle/2.0) + 0.15;
+ ambient = 0.4 *
+ pow(2.4, -t->sun_angle*t->sun_angle*t->sun_angle*t->sun_angle / 3.0);
+ diffuse = 0.4 * cos(0.6 * t->sun_angle * t->sun_angle);
+ sky = 0.85 *
+ pow(1.6, -t->sun_angle*t->sun_angle*t->sun_angle*t->sun_angle/2.0)
+ + 0.15;
if ( ambient < 0.1 ) { ambient = 0.1; }
if ( diffuse < 0.0 ) { diffuse = 0.0; }
fgSceneryRender();
/* display HUD */
- if( show_hud ) {
+ if( show_hud )
fgCockpitUpdate();
- /* fgUpdateHUD(); */
- }
#ifdef GLUT
glutSwapBuffers();
fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
/* refresh shared sun position and sun_vec */
- fgUpdateSunPos();
-
- /* the sun position has to be translated just like everything else */
- sun_vec[0] = t->fg_sunpos.x - scenery.center.x;
- sun_vec[1] = t->fg_sunpos.y - scenery.center.y;
- sun_vec[2] = t->fg_sunpos.z - scenery.center.z;
- /* make this a directional light source only */
- sun_vec[3] = 0.0;
+ fgUpdateSunPos(scenery.center);
/* update the view angle */
for ( i = 0; i < multi_loop; i++ ) {
f = ¤t_aircraft.flight;
/* Read joystick */
- /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 ); */
- /* printf( "Joystick X %f Y %f B1 %d B2 %d\n",
+ /* fgJoystickRead( &joy_x, &joy_y, &joy_b1, &joy_b2 );
+ printf( "Joystick X %f Y %f B1 %d B2 %d\n",
joy_x, joy_y, joy_b1, joy_b2 );
fgElevSet( -joy_y );
fgAileronSet( joy_x ); */
/* $Log$
-/* Revision 1.12 1997/08/27 21:32:24 curt
-/* Restructured view calculation code. Added stars.
+/* Revision 1.13 1997/09/04 02:17:34 curt
+/* Shufflin' stuff.
/*
+ * Revision 1.12 1997/08/27 21:32:24 curt
+ * Restructured view calculation code. Added stars.
+ *
* Revision 1.11 1997/08/27 03:30:16 curt
* Changed naming scheme of basic shared structures.
*
../Controls/libControls.a ../Flight/libFlight.a \
../Joystick/libJoystick.a ../Flight/LaRCsim/libLaRCsim.a \
../Flight/Slew/libSlew.a ../Scenery/libScenery.a \
- ../Time/libTime.a ../Weather/libWeather.a ../Math/libMath.a
+ ../Time/libTime.a ../Weather/libWeather.a ../Math/libMath.a
include ../make.inc
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.33 1997/09/04 02:17:35 curt
+# Shufflin' stuff.
+#
# Revision 1.32 1997/08/27 21:31:27 curt
# Added views.[ch]
#
-GLUTkey.o: GLUTkey.c GLUTkey.h ../constants.h ../Aircraft/aircraft.h \
- ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
- ../Aircraft/../Flight/LaRCsim/ls_interface.h \
- ../Aircraft/../Flight/LaRCsim/../flight.h \
- ../Aircraft/../Controls/controls.h \
- ../Aircraft/../Controls/../limits.h ../Weather/weather.h
-GLUTmain.o: GLUTmain.c fg_init.h ../constants.h ../general.h \
+GLUTkey.o: GLUTkey.c GLUTkey.h views.h ../types.h ../Flight/flight.h \
+ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \
+ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \
../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
- ../Aircraft/../Flight/Slew/slew.h \
- ../Aircraft/../Flight/LaRCsim/ls_interface.h \
- ../Aircraft/../Flight/LaRCsim/../flight.h \
../Aircraft/../Controls/controls.h \
+ ../Aircraft/../Controls/../limits.h ../Weather/weather.h
+GLUTmain.o: GLUTmain.c GLUTkey.h fg_init.h views.h ../types.h \
+ ../Flight/flight.h ../Flight/Slew/slew.h \
+ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \
+ ../Math/mat3.h ../constants.h ../general.h ../Aircraft/aircraft.h \
+ ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../limits.h ../Cockpit/cockpit.h \
../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \
../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \
- ../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/mat3.h \
- ../Math/polar.h ../Math/../types.h ../Scenery/mesh.h \
- ../Scenery/scenery.h ../Scenery/../types.h ../Time/fg_time.h \
- ../Time/../types.h ../Time/fg_timer.h ../Time/sunpos.h \
- ../Weather/weather.h
-fg_init.o: fg_init.c fg_init.h ../constants.h ../general.h \
- ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
- ../Aircraft/../Flight/Slew/slew.h \
- ../Aircraft/../Flight/LaRCsim/ls_interface.h \
- ../Aircraft/../Flight/LaRCsim/../flight.h \
+ ../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/polar.h \
+ ../Math/../types.h ../Scenery/mesh.h ../Scenery/scenery.h \
+ ../Scenery/../types.h ../Time/fg_time.h ../Time/../types.h \
+ ../Time/fg_timer.h ../Time/sunpos.h ../Weather/weather.h
+fg_init.o: fg_init.c fg_init.h views.h ../types.h ../Flight/flight.h \
+ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \
+ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \
+ ../general.h ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../limits.h ../Cockpit/cockpit.h \
../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \
../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \
../Joystick/joystick.h ../Math/fg_random.h ../Scenery/mesh.h \
../Scenery/scenery.h ../Scenery/../types.h ../Scenery/stars.h \
- ../Time/sunpos.h ../Weather/weather.h
-views.o: views.c views.h ../types.h
+ ../Time/sunpos.h ../Time/../types.h ../Weather/weather.h
+views.o: views.c views.h ../types.h ../Flight/flight.h \
+ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \
+ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \
+ ../Math/polar.h ../Math/../types.h ../Scenery/scenery.h \
+ ../Scenery/../types.h
FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
FG_Altitude = FG_Runway_altitude + 3.758099;
-
+ /* FG_Altitude = 20000; */
+
/* Initial Position north of the city of Globe */
/* FG_Latitude = ( 120625.64 / 3600.0 ) * DEG_TO_RAD; */
/* FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; */
/* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
/* Initialize shared sun position and sun_vec */
- fgUpdateSunPos();
+ fgUpdateSunPos(scenery.center);
/* Initialize view parameters */
fgViewInit(v);
fgWeatherInit();
/* Initialize the Cockpit subsystem */
- fgCockpitInit( current_aircraft );
+ if( fgCockpitInit( current_aircraft ) == NULL )
+ {
+ printf( "Error in Cockpit initialization!\n" );
+ exit( 1 );
+ }
/* Initialize the Stars subsystem */
fgStarsInit();
/* $Log$
-/* Revision 1.4 1997/08/27 21:32:26 curt
-/* Restructured view calculation code. Added stars.
+/* Revision 1.5 1997/09/04 02:17:36 curt
+/* Shufflin' stuff.
/*
+ * Revision 1.4 1997/08/27 21:32:26 curt
+ * Restructured view calculation code. Added stars.
+ *
* Revision 1.3 1997/08/27 03:30:19 curt
* Changed naming scheme of basic shared structures.
*
parser.o: parser.c parsevrml.h geometry.h common.h mesh.h scenery.h \
../types.h
scanner.o: scanner.c parser.h
-scenery.o: scenery.c ../general.h scenery.h ../types.h parsevrml.h
-stars.o: stars.c stars.h ../general.h
+scenery.o: scenery.c ../general.h scenery.h ../types.h parsevrml.h \
+ stars.h
+stars.o: stars.c stars.h ../constants.h ../general.h ../GLUT/views.h \
+ ../GLUT/../types.h ../GLUT/../Flight/flight.h \
+ ../GLUT/../Flight/Slew/slew.h \
+ ../GLUT/../Flight/LaRCsim/ls_interface.h \
+ ../GLUT/../Flight/LaRCsim/../flight.h ../GLUT/../Math/mat3.h \
+ ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
+ ../Aircraft/../Controls/controls.h \
+ ../Aircraft/../Controls/../limits.h
/* center of current scenery chunk */
struct fgCartesianPoint center;
+
+ /* angle of sun relative to current local horizontal */
+ double sun_angle;
};
extern struct SCENERY scenery;
/* $Log$
-/* Revision 1.9 1997/08/27 03:30:33 curt
-/* Changed naming scheme of basic shared structures.
+/* Revision 1.10 1997/09/04 02:17:37 curt
+/* Shufflin' stuff.
/*
+ * Revision 1.9 1997/08/27 03:30:33 curt
+ * Changed naming scheme of basic shared structures.
+ *
* Revision 1.8 1997/08/06 00:24:30 curt
* Working on correct real time sun lighting.
*
glDisable( GL_LIGHTING );
glPushMatrix();
- /* set lighting parameters for stars */
- /* amb[0] = amb[1] = amb[2] = 1.0;
- diff[0] = diff[1] = diff[2] = 1.0;
- glLightfv(GL_LIGHT0, GL_AMBIENT, amb );
- glLightfv(GL_LIGHT0, GL_DIFFUSE, diff ); */
-
glTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
angle = FG_2PI * fmod(DaysSinceEpoch(time(NULL)), 1.0);
/* $Log$
-/* Revision 1.3 1997/08/29 17:55:28 curt
-/* Worked on properly aligning the stars.
+/* 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.
*
done
-tar: clean
+source-tar: clean
(cd ../..; \
- tar cvf source-$(VERSION).tar FlightGear/COPYING FlightGear/Docs \
- FlightGear/Src FlightGear/Thanks)
+ tar cvzf source-$(VERSION).tar.gz FlightGear/fgtop FlightGear/COPYING \
+ FlightGear/Docs FlightGear/Src FlightGear/Thanks)
-zip: clean
+source-zip: clean
(cd ../..; \
- zip -r source-$(VERSION).zip FlightGear/COPYING FlightGear/Docs \
- FlightGear/Src FlightGear/Thanks)
+ zip -r source-$(VERSION).zip FlightGear/fgtop FlightGear/COPYING \
+ FlightGear/Docs FlightGear/Src FlightGear/Thanks)
+
+scenery-tar:
+ (cd ../..; \
+ tar cvzf scenery-$(VERSION).tar.gz FlightGear/Scenery)
+
+scenery-zip:
+ (cd ../..; \
+ zip -r scenery-$(VERSION).zip FlightGear/Scenery)
+
+bin-tar: all
+ cp GLUT/fg0 GLUT/runfg ..
+ (cd ../..; \
+ tar cvzf bin-$(VERSION).tar.gz FlightGear/fgtop FlightGear/fg0 \
+ FlightGear/runfg FlightGear/COPYING FlightGear/Docs FlightGear/Thanks)
+
+bin-zip: all
+ cp GLUT/fg0.exe GLUT/runfg.bat GLUT/cygwin.dll ..
+ (cd ../..; \
+ zip -r bin-$(VERSION).zip FlightGear/fgtop FlightGear/fg0.exe \
+ FlightGear/runfg.bat FlightGear/cygwin.dll FlightGear/COPYING \
+ FlightGear/Docs FlightGear/Thanks)
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.26 1997/09/04 02:17:18 curt
+# Shufflin' stuff.
+#
# Revision 1.25 1997/08/25 20:27:21 curt
# Merged in initial HUD and Joystick code.
#
#---------------------------------------------------------------------------
-VERSION = 0.10
+VERSION = 0.11
#---------------------------------------------------------------------------
# Choose your weapons
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.13 1997/09/04 02:17:19 curt
+# Shufflin' stuff.
+#
# Revision 1.12 1997/08/25 20:27:21 curt
# Merged in initial HUD and Joystick code.
#
fg_time.o: fg_time.c fg_time.h ../types.h
fg_timer.o: fg_timer.c fg_timer.h
-sunpos.o: sunpos.c sunpos.h fg_time.h ../types.h ../constants.h \
- ../Math/fg_geodesy.h ../Math/polar.h ../Math/../types.h
+sunpos.o: sunpos.c sunpos.h ../types.h fg_time.h ../constants.h \
+ ../GLUT/views.h ../GLUT/../types.h ../GLUT/../Flight/flight.h \
+ ../GLUT/../Flight/Slew/slew.h \
+ ../GLUT/../Flight/LaRCsim/ls_interface.h \
+ ../GLUT/../Flight/LaRCsim/../flight.h ../GLUT/../Math/mat3.h \
+ ../Math/fg_geodesy.h ../Math/mat3.h ../Math/polar.h \
+ ../Math/../types.h
#define FG_TIME_H
+#ifdef WIN32
+# include <windows.h>
+#endif
+
+#include <GL/glut.h>
+
#include "../types.h"
struct fgTIME {
/* the point on the earth's surface above which the sun is directly
* overhead */
- struct fgCartesianPoint fg_sunpos; /* in cartesian coordiantes */
double sun_lon, sun_gc_lat; /* in geocentric coordinates */
+ struct fgCartesianPoint fg_sunpos; /* in cartesian coordiantes */
+ GLfloat sun_vec[4]; /* in view coordinates */
+ double sun_angle; /* the angle between the sun and the
+ local horizontal */
};
extern struct fgTIME cur_time_params;
/* $Log$
-/* Revision 1.2 1997/08/27 03:30:36 curt
-/* Changed naming scheme of basic shared structures.
+/* Revision 1.3 1997/09/04 02:17:39 curt
+/* Shufflin' stuff.
/*
+ * Revision 1.2 1997/08/27 03:30:36 curt
+ * Changed naming scheme of basic shared structures.
+ *
* Revision 1.1 1997/08/13 21:56:00 curt
* Initial revision.
*
#include "sunpos.h"
#include "fg_time.h"
#include "../constants.h"
+#include "../GLUT/views.h"
#include "../Math/fg_geodesy.h"
+#include "../Math/mat3.h"
#include "../Math/polar.h"
#undef E
/* update the cur_time_params structure with the current sun position */
-void fgUpdateSunPos() {
+void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
struct fgTIME *t;
- double sun_gd_lat, sl_radius;
+ struct VIEW *v;
+ MAT3vec nup, nsun;
+ double sun_gd_lat, sl_radius, temp;
static int time_warp = 0;
t = &cur_time_params;
+ v = ¤t_view;
time_warp += 200; /* increase this to make the world spin real fast */
/* printf("Geodetic lat = %.5f Geocentric lat = %.5f\n", sun_gd_lat,
t->sun_gc_lat); */
+
+ /* the sun position has to be translated just like everything else */
+ t->sun_vec[0] = t->fg_sunpos.x - scenery_center.x;
+ t->sun_vec[1] = t->fg_sunpos.y - scenery_center.y;
+ t->sun_vec[2] = t->fg_sunpos.z - scenery_center.z;
+ /* make this a directional light source only */
+ t->sun_vec[3] = 0.0;
+
+ /* calculate thesun's relative angle to local up */
+ MAT3_COPY_VEC(nup, v->local_up);
+ nsun[0] = t->fg_sunpos.x;
+ nsun[1] = t->fg_sunpos.y;
+ nsun[2] = t->fg_sunpos.z;
+ MAT3_NORMALIZE_VEC(nup, temp);
+ MAT3_NORMALIZE_VEC(nsun, temp);
+
+ t->sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
+ printf("SUN ANGLE relative to current location = %.3f rads.\n",
+ t->sun_angle);
}
/* $Log$
-/* Revision 1.6 1997/08/27 03:30:37 curt
-/* Changed naming scheme of basic shared structures.
+/* 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.
*
#include <time.h>
+#include "../types.h"
/* update the cur_time_params structure with the current sun position */
-void fgUpdateSunPos();
+void fgUpdateSunPos(struct fgCartesianPoint scenery_center);
void fgSunPosition(time_t ssue, double *lon, double *lat);