]> git.mxchange.org Git - flightgear.git/commitdiff
Working on adding a global lighting params structure.
authorcurt <curt>
Tue, 9 Dec 1997 04:25:25 +0000 (04:25 +0000)
committercurt <curt>
Tue, 9 Dec 1997 04:25:25 +0000 (04:25 +0000)
Main/GLUTmain.c
Scenery/astro.c
Scenery/stars.c
Simulator/README
Simulator/make.inc
Time/fg_time.c
Time/fg_time.h
Time/sunpos.c

index fb50cef96939e691b4ea254c4cc4b7a8448232bc..89873966344e5b84545c8a834ba47439febd7a33 100644 (file)
@@ -100,9 +100,11 @@ int show_hud;
  **************************************************************************/
 
 static void fgInitVisuals() {
+    struct fgLIGHT *l;
     struct fgTIME *t;
     struct WEATHER *w;
 
+    l = &cur_light_params;
     t = &cur_time_params;
     w = &current_weather;
 
@@ -114,7 +116,7 @@ static void fgInitVisuals() {
        to unit length after transformation.  See glNormal. */
     glEnable( GL_NORMALIZE );
 
-    glLightfv( GL_LIGHT0, GL_POSITION, t->sun_vec );
+    glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
     glEnable( GL_LIGHTING );
     glEnable( GL_LIGHT0 );
 
@@ -139,6 +141,7 @@ static void fgInitVisuals() {
 
 static void fgUpdateViewParams() {
     struct FLIGHT *f;
+    struct fgLIGHT *l;
     struct fgTIME *t;
     struct VIEW *v;
     double x_2, x_4, x_8, x_10;
@@ -147,6 +150,7 @@ static void fgUpdateViewParams() {
     GLfloat amb[3], diff[3], fog[4], clear[4];
 
     f = &current_aircraft.flight;
+    l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
 
@@ -168,14 +172,14 @@ static void fgUpdateViewParams() {
              v->view_up[0], v->view_up[1], v->view_up[2]);
 
     /* set the sun position */
-    glLightfv( GL_LIGHT0, GL_POSITION, t->sun_vec );
+    glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
 
     /* calculate lighting parameters based on sun's relative angle to
      * local up */
     /* ya kind'a have to plot this to see the magic */
 
     /* x = t->sun_angle^8 */
-    x_2 = t->sun_angle * t->sun_angle;
+    x_2 = l->sun_angle * l->sun_angle;
     x_4 = x_2 * x_2;
     x_8 = x_4 * x_4;
     x_10 = x_8 * x_2;
@@ -577,9 +581,12 @@ int main( int argc, char *argv[] ) {
 
 
 /* $Log$
-/* Revision 1.25  1997/12/08 22:54:09  curt
-/* Enabled GL_CULL_FACE.
+/* Revision 1.26  1997/12/09 04:25:29  curt
+/* Working on adding a global lighting params structure.
 /*
+ * Revision 1.25  1997/12/08 22:54:09  curt
+ * Enabled GL_CULL_FACE.
+ *
  * Revision 1.24  1997/11/25 19:25:32  curt
  * Changes to integrate Durk's moon/sun code updates + clean up.
  *
index a9534696352defea479b873ddc0cc67ee87d764c..8ebe0623a56381f5cc3771b72d6c71ec6243bb06 100644 (file)
@@ -69,11 +69,13 @@ void fgAstroInit() {
 /* Render Astronomical Objects */
 void fgAstroRender() {
     struct FLIGHT *f;
+    struct fgLIGHT *l;
     struct VIEW *v;
     struct fgTIME *t;
     double angle;
 
     f = &current_aircraft.flight;
+    l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
 
@@ -88,7 +90,7 @@ void fgAstroRender() {
     glDisable( GL_FOG );
 
     /* reverse light direction so the moon is displayed properly */
-    glLightfv( GL_LIGHT0, GL_POSITION, t->sun_vec_inv );
+    glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv );
 
     glPushMatrix();
 
@@ -119,7 +121,10 @@ void fgAstroRender() {
 
 
 /* $Log$
-/* Revision 1.1  1997/11/25 23:20:22  curt
-/* Initial revision.
+/* 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.
+ *
  */
index be1f5434be0dee6cd2d3c51bf06502930f096440..3b79a271df284a209a5f2de53dd917639c9e989f 100644 (file)
@@ -218,10 +218,12 @@ void fgStarsInit() {
 void fgStarsRender() {
     struct FLIGHT *f;
     struct VIEW *v;
+    struct fgLIGHT *l;
     struct fgTIME *t;
     int i;
 
     f = &current_aircraft.flight;
+    l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
 
@@ -230,13 +232,13 @@ void fgStarsRender() {
     /* t->sun_angle = 3.0; */ /* to force stars to be drawn (for testing) */
 
     /* render the stars */
-    if ( t->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
+    if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
        /* determine which star structure to draw */
-       if ( t->sun_angle > (FG_PI_2 + 7.25 * DEG_TO_RAD ) ) {
+       if ( l->sun_angle > (FG_PI_2 + 7.25 * DEG_TO_RAD ) ) {
            i = 0;
-       } else if ( t->sun_angle > (FG_PI_2 + 6.50 * DEG_TO_RAD ) ) {
+       } else if ( l->sun_angle > (FG_PI_2 + 6.50 * DEG_TO_RAD ) ) {
            i = 1;
-       } else if ( t->sun_angle > (FG_PI_2 + 5.75 * DEG_TO_RAD ) ) {
+       } else if ( l->sun_angle > (FG_PI_2 + 5.75 * DEG_TO_RAD ) ) {
            i = 2;
        } else {
            i = 3;
@@ -254,9 +256,12 @@ void fgStarsRender() {
 
 
 /* $Log$
-/* Revision 1.16  1997/11/25 19:25:38  curt
-/* Changes to integrate Durk's moon/sun code updates + clean up.
+/* 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.
  *
index 739f94697e26ea1fb7632dda07509fce57e9b596..d91d101375baa3a0f52e69ae5a2c9243fca43046 100644 (file)
@@ -1,58 +1,49 @@
-majordomo writes:
-Subdirectories
-==============
-Main/
--------
-"main()" and GLUT dependent mouse/keyboard/graphics code.
+Welcome to the Flight Gear project.
 
 
-Aircraft/
----------
-Structure and code to tie together all the pieces of an aircraft such
-as flight model, engine model, panel, controls, etc.
+Starting the executable
+=======================
 
+Unix:    runfg
+Windows: runfg.bat
 
-Controls/
----------
-Provide a standardized interface to all aircraft controls.
+"runfg" is a script which sets the FG_ROOT environment variable, then
+runs the flight gear executable.
 
 
-Flight/
--------
-Strucures and code to implement various flight models.  Provides a 
-standardized interface to all interesting flight model variabls.
+Keyboard controls
+=================
 
+Flying is mainly done via the numeric keypad.  There is some
+unresolved wierdness with the GLUT libraries and keyboard input, so
+for now, the state of the "Num Lock" key is important.
 
-Math/
------
-Contains miscellaneous matrix/vector routines.
+Num Lock Active
+---------------
 
+    Pg Up/Pg Dn             Throttle
+    Left Arrow/Right Arrow  Aileron
+    Up Arrow/Down Arrow     Elevator
+    Ins/Del                 Rudder
+    "5"                     Center aileron/elevator/rudder
+    Home/End                Elevator Trim
 
-Scenery/
---------
-Scenery parsing/generating code.
+Num Lock Inactive
+-----------------
+    Shift + <Numeric Keypad Key>   Change view
 
+    where key is one of:
 
-Sound/
-------
-Sound management code
+    8 = forward
+    7 = left/forward
+    4 = left
+    1 = left/back
+    2 = back
+    3 = right/back
+    6 = right
+    9 = right/forward
 
 
-Timer/
-------
-Code to handle time and timing of events.
+    
 
-
-Utils/
-------
-Miscellaneous utility routines such as a general random number generator
-
-
-Weather/
---------
-Weather management and modeling code.
-
-
-Win32/
-------
-Win32 support stuff
+    
\ No newline at end of file
index 048d79555dde77bf70c048d67503538fc9c89745..96be415d144a4cab09393f0ef2e3aa457e37419e 100644 (file)
@@ -30,7 +30,7 @@
 #---------------------------------------------------------------------------
 
 VERSION_MAJOR = 0
-VERSION_MINOR = 14
+VERSION_MINOR = 15
 VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
 
 
@@ -131,6 +131,9 @@ FG_CFLAGS = $(GLOBAL_CFLAGS)
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.20  1997/12/09 04:25:25  curt
+# Working on adding a global lighting params structure.
+#
 # Revision 1.19  1997/11/25 19:25:27  curt
 # Changes to integrate Durk's moon/sun code updates + clean up.
 #
index 3e74a933960d2738a0a4c5c7980aaf5651e289fc..d7bc63e7e911f26ea6573df39f4d5aa45d9b7326 100644 (file)
@@ -45,6 +45,7 @@
 
 
 struct fgTIME cur_time_params;
+struct fgLIGHT cur_light_params;
 
 
 /* Initialize the time dependent variables */
@@ -284,9 +285,12 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) {
 
 
 /* $Log$
-/* Revision 1.11  1997/11/25 19:25:40  curt
-/* Changes to integrate Durk's moon/sun code updates + clean up.
+/* 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.
  *
index 5e6bed61d38ad8156f936b2de8426ca40296c682..bb734686d1285e1c43b7ae431b1fe3945a1b595f 100644 (file)
@@ -55,7 +55,14 @@ struct fgTIME {
                            sidereal time algorithm result and the
                            course result.  course + diff has good
                            accuracy for the short term */
+};
+
+extern struct fgTIME cur_time_params;
+
 
+/* Lighting is time dependent so it shows up here */
+/* Define a structure containing the global lighting parameters */
+struct fgLIGHT {
     /* position of the sun in various forms */
     double sun_lon, sun_gc_lat;         /* in geocentric coordinates */
     struct fgCartesianPoint fg_sunpos;  /* in cartesian coordiantes */
@@ -63,9 +70,15 @@ struct fgTIME {
     GLfloat sun_vec_inv[4];             /* inverse (in view coordinates) */
     double sun_angle;                   /* the angle between the sun and the 
                                           local horizontal */
+
+    /* Derived lighting values */
+    GLfloat scene_ambient[3];           /* ambient component */
+    GLfloat scene_diffuse[3];           /* diffuse component */
+    GLfloat scene_fog[4];               /* fog color */
+    GLfloat scene_clear[4];             /* clear screen color */
 };
 
-extern struct fgTIME cur_time_params;
+extern struct fgLIGHT cur_light_params;
 
 
 /* Initialize the time dependent variables */
@@ -79,9 +92,12 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t);
 
 
 /* $Log$
-/* Revision 1.7  1997/11/25 19:25:41  curt
-/* Changes to integrate Durk's moon/sun code updates + clean up.
+/* Revision 1.8  1997/12/09 04:25:38  curt
+/* Working on adding a global lighting params structure.
 /*
+ * Revision 1.7  1997/11/25 19:25:41  curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
  * Revision 1.6  1997/09/20 03:34:35  curt
  * Still trying to get those durned stars aligned properly.
  *
index 15bbe90856107dfdf6ac2714ac57f386b8a6ec95..63db4936e7e687c62a1b53eaf6e58466e7039b5c 100644 (file)
@@ -261,54 +261,59 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) {
 
 /* update the cur_time_params structure with the current sun position */
 void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
+    struct fgLIGHT *l;
     struct fgTIME *t;
     struct VIEW *v;
     MAT3vec nup, nsun;
     double sun_gd_lat, sl_radius, temp;
     static int time_warp = 0;
 
+    l = &cur_light_params;
     t = &cur_time_params;
     v = &current_view;
 
     time_warp += 0; /* increase this to make the world spin real fast */
 
-    fgSunPosition(t->cur_time + time_warp, &t->sun_lon, &sun_gd_lat);
+    fgSunPosition(t->cur_time + time_warp, &l->sun_lon, &sun_gd_lat);
 
-    fgGeodToGeoc(sun_gd_lat, 0.0, &sl_radius, &t->sun_gc_lat);
+    fgGeodToGeoc(sun_gd_lat, 0.0, &sl_radius, &l->sun_gc_lat);
 
-    t->fg_sunpos = fgPolarToCart(t->sun_lon, t->sun_gc_lat, sl_radius);
+    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); */
 
     /* the sun position has to be translated just like everything else */
-    t->sun_vec_inv[0] = t->fg_sunpos.x - scenery_center.x; 
-    t->sun_vec_inv[1] = t->fg_sunpos.y - scenery_center.y;
-    t->sun_vec_inv[2] = t->fg_sunpos.z - scenery_center.z;
-    MAT3_SCALE_VEC(t->sun_vec, t->sun_vec_inv, -1.0);
+    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);
 
     /* make these are directional light sources only */
-    t->sun_vec[3] = 0.0;
-    t->sun_vec_inv[3] = 0.0;
+    l->sun_vec[3] = 0.0;
+    l->sun_vec_inv[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;
+    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);
 
-    t->sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
+    l->sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
     printf("SUN ANGLE relative to current location = %.3f rads.\n", 
-          t->sun_angle);
+          l->sun_angle);
 }
 
 
 /* $Log$
-/* Revision 1.13  1997/11/25 19:25:42  curt
-/* Changes to integrate Durk's moon/sun code updates + clean up.
+/* 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.
  *