]> git.mxchange.org Git - flightgear.git/commitdiff
Tweaked time of day lighting equations. Don't draw stars during the day.
authorcurt <curt>
Tue, 16 Sep 1997 22:14:47 +0000 (22:14 +0000)
committercurt <curt>
Tue, 16 Sep 1997 22:14:47 +0000 (22:14 +0000)
Main/GLUTmain.c
Scenery/stars.c
Simulator/make.inc
Time/fg_time.c

index ea734584fd2287ddbbaa46279a7126b1e28ca9e0..895a91df63c1f39a41d4f163ebe8a40c627ae39e 100644 (file)
@@ -141,7 +141,7 @@ static void fgUpdateViewParams() {
     struct FLIGHT *f;
     struct fgTIME *t;
     struct VIEW *v;
-    double x_2, x_4, x_8;
+    double x_2, x_4, x_8, x_10;
     double ambient, diffuse, sky;
     GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 };
     GLfloat amb[3], diff[3], fog[4], clear[4];
@@ -178,10 +178,19 @@ static void fgUpdateViewParams() {
     x_2 = t->sun_angle * t->sun_angle;
     x_4 = x_2 * x_2;
     x_8 = x_4 * x_4;
+    x_10 = x_8 * x_2;
 
-    ambient = 0.4 * pow(1.5, -x_8 / 20.0);
-    diffuse = 0.4 * cos(0.55 * x_2);
-    sky = 0.85 * pow(1.6, -x_4 / 2.0) + 0.15;
+    ambient = 0.4 * pow(1.2, -x_10 / 30.0);
+
+    /* diffuse = 0.4 * cos(0.3 * x_2);
+    if ( t->sun_angle > FG_PI_2 + 0.05 ) {
+       diffuse = 0.0;
+    }
+    */
+
+    diffuse = ambient;
+
+    sky = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
 
     if ( ambient < 0.1 ) { ambient = 0.1; }
     if ( diffuse < 0.0 ) { diffuse = 0.0; }
@@ -566,9 +575,12 @@ int main( int argc, char *argv[] ) {
 
 
 /* $Log$
-/* Revision 1.17  1997/09/16 15:50:29  curt
-/* Working on star alignment and time issues.
+/* Revision 1.18  1997/09/16 22:14:51  curt
+/* Tweaked time of day lighting equations.  Don't draw stars during the day.
 /*
+ * Revision 1.17  1997/09/16 15:50:29  curt
+ * Working on star alignment and time issues.
+ *
  * Revision 1.16  1997/09/13 02:00:06  curt
  * Mostly working on stars and generating sidereal time for accurate star
  * placement.
index ceb16324628587a1623c9e9d53d666ad42b11d94..5b1ae258f321f101338d3e30ff2ec02c0ac69247 100644 (file)
@@ -203,33 +203,42 @@ void fgStarsRender() {
     t = &cur_time_params;
     v = &current_view;
 
-    printf("RENDERING STARS\n");
+    /* FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise */
 
-    glDisable( GL_FOG );
-    glDisable( GL_LIGHTING );
-    glPushMatrix();
+    if ( t->sun_angle > (FG_PI_2 + 0.1 ) ) {
+       printf("RENDERING STARS (night)\n");
 
-    glTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
+       glDisable( GL_FOG );
+       glDisable( GL_LIGHTING );
+       glPushMatrix();
 
-    angle = FG_2PI * t->lst / 24.0;
-    /* warp += 1.0 * DEG_TO_RAD; */
-    warp = 15.0 * DEG_TO_RAD;
-    glRotatef( -(angle+warp) * RAD_TO_DEG, 0.0, 0.0, 1.0 );
-    printf("Rotating stars by %.2f + %.2f\n", -angle * RAD_TO_DEG,
-       -warp * RAD_TO_DEG);
+       glTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z );
 
-    glCallList(stars);
+       angle = FG_2PI * t->lst / 24.0;
+       /* warp += 1.0 * DEG_TO_RAD; */
+       warp = 15.0 * DEG_TO_RAD;
+       glRotatef( -(angle+warp) * RAD_TO_DEG, 0.0, 0.0, 1.0 );
+       printf("Rotating stars by %.2f + %.2f\n", -angle * RAD_TO_DEG,
+              -warp * RAD_TO_DEG);
 
-    glPopMatrix();
-    glEnable( GL_LIGHTING );
-    glEnable( GL_FOG );
+       glCallList(stars);
+
+       glPopMatrix();
+       glEnable( GL_LIGHTING );
+       glEnable( GL_FOG );
+    } else {
+       printf("not RENDERING STARS (day)\n");
+    }
 }
 
 
 /* $Log$
-/* Revision 1.7  1997/09/16 15:50:31  curt
-/* Working on star alignment and time issues.
+/* Revision 1.8  1997/09/16 22:14:52  curt
+/* Tweaked time of day lighting equations.  Don't draw stars during the day.
 /*
+ * Revision 1.7  1997/09/16 15:50:31  curt
+ * Working on star alignment and time issues.
+ *
  * Revision 1.6  1997/09/05 14:17:31  curt
  * More tweaking with stars.
  *
index 705be7e8382201cd8f127ef91dab058a62cb78b6..19e926ac5452a1b04d31f79649bc3e89818b36fa 100644 (file)
@@ -25,7 +25,7 @@
 #---------------------------------------------------------------------------
 
 
-VERSION = 0.11
+VERSION = 0.12
 
 #---------------------------------------------------------------------------
 # Choose your weapons
@@ -120,6 +120,9 @@ FG_CFLAGS = $(GLOBAL_CFLAGS)
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.14  1997/09/16 22:14:47  curt
+# Tweaked time of day lighting equations.  Don't draw stars during the day.
+#
 # Revision 1.13  1997/09/04 02:17:19  curt
 # Shufflin' stuff.
 #
index 3b9721943b8c035212cd4f13d98ee5f8e011cd68..d5b34c1690e45d9fbe3d9845ac10cf3610c2f6c4 100644 (file)
@@ -149,7 +149,6 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) {
     struct tm mt;
     long int offset;
     double diff, part, days, hours, lst;
-    int i;
 
     printf("COURSE: GMT = %d/%d/%2d %d:%02d:%02d\n", 
            gmt->tm_mon, gmt->tm_mday, gmt->tm_year,
@@ -201,10 +200,14 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) {
 
 void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) {
     double lst_precise, lst_course;
+    static long int warp = 0;
 
     /* get current Unix calendar time (in seconds) */
+    /* warp += 120; */
+    warp = 0;
     t->cur_time = time(NULL);
-    printf("Current Unix calendar time = %ld\n", t->cur_time);
+    t->cur_time += warp;
+    printf("Current Unix calendar time = %ld  warp = %ld\n", t->cur_time, warp);
 
     /* get GMT break down for current time */
     t->gmt = gmtime(&t->cur_time);
@@ -249,9 +252,12 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) {
 
 
 /* $Log$
-/* Revision 1.4  1997/09/16 15:50:31  curt
-/* Working on star alignment and time issues.
+/* 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.