]> git.mxchange.org Git - flightgear.git/commitdiff
Testing/playing -- placed objects randomly across the entire terrain.
authorcurt <curt>
Mon, 14 Jul 1997 16:26:03 +0000 (16:26 +0000)
committercurt <curt>
Mon, 14 Jul 1997 16:26:03 +0000 (16:26 +0000)
Main/mesh2GL.c
Scenery/depend
Scenery/mesh.c
Scenery/scenery.c
Simulator/constants.h
Time/Makefile

index b6f7106ca70e2589271684b17568688794a8782d..a671816d9c136a5930ee231afb36bcaa749afd27 100644 (file)
@@ -30,6 +30,8 @@
 
 #include <GL/glut.h>
 
+#include <stdlib.h>         /* for random(), srandom() */
+
 #include "../constants.h"
 #include "../Scenery/mesh.h"
 #include "../Scenery/scenery.h"
@@ -59,15 +61,23 @@ void mesh_make_test_object(double lon, double lat) {
     origin = fgRotateCartesianPoint(origin);
     printf("Center of structure is:  (%.4f, %.4f\n", origin.y, origin.z);
 
-    glBegin(GL_TRIANGLE_STRIP);
-    glVertex3d(origin.y + b, origin.z-b, elev);
-    glVertex3d(origin.y - b, origin.z-b, elev);
+    glBegin(GL_TRIANGLES);
+    glVertex3d(origin.y - b, origin.z - b, elev);
+    glVertex3d(origin.y + b, origin.z - b, elev);
+    glVertex3d(origin.y, origin.z, elev+h);
+
+    glVertex3d(origin.y + b, origin.z - b, elev);
+    glVertex3d(origin.y + b, origin.z + b, elev);
     glVertex3d(origin.y, origin.z, elev+h);
-    glVertex3d(origin.y - b, origin.z+b, elev);
-    glVertex3d(origin.y + b, origin.z+b, elev);
-    glVertex3d(origin.y + b, origin.z-b, elev);
-    glEnd();
 
+    glVertex3d(origin.y + b, origin.z + b, elev);
+    glVertex3d(origin.y - b, origin.z + b, elev);
+    glVertex3d(origin.y, origin.z, elev+h);
+
+    glVertex3d(origin.y - b, origin.z + b, elev);
+    glVertex3d(origin.y - b, origin.z - b, elev);
+    glVertex3d(origin.y, origin.z, elev+h);
+    glEnd();
 }
 
 /* walk through mesh and make ogl calls */
@@ -166,7 +176,19 @@ GLint mesh2GL(struct mesh *m) {
     }
 
     /* this will go, it's only here for testing/debugging */
-    mesh_make_test_object(-398391.28, 120070.41);
+
+    /*
+    for ( i = m->originy; i < m->originy + (m->row_step * iend); i += 120 ) {
+       for ( j = m->originx; j < m->originx + (m->col_step * jend); j += 120) {
+           mesh_make_test_object(j, i);
+       }
+    }
+    */
+
+    for ( i = 0; i < 800; i++ ) {
+       mesh_make_test_object(m->originx + (random() * 3600.0 / RAND_MAX) ,
+                             m->originy + (random() * 3600.0 / RAND_MAX) );
+    }
 
     glEndList();
 
@@ -176,9 +198,12 @@ GLint mesh2GL(struct mesh *m) {
 
 
 /* $Log$
-/* Revision 1.32  1997/07/12 03:50:21  curt
-/* Added an #include <Windows32/Base.h> to help compiling for Win32
+/* Revision 1.33  1997/07/14 16:26:04  curt
+/* Testing/playing -- placed objects randomly across the entire terrain.
 /*
+ * Revision 1.32  1997/07/12 03:50:21  curt
+ * Added an #include <Windows32/Base.h> to help compiling for Win32
+ *
  * Revision 1.31  1997/07/12 02:27:07  curt
  * Looking at potential scenery transformation/coordinate system problems.
  *
index 0dbd7ff05e1bf4fc1c51c5d979c8d08b9aa30357..463f07901842f0f3c4109b733983eb2092594a94 100644 (file)
@@ -1,6 +1,6 @@
 common.o: common.c common.h
 geometry.o: geometry.c geometry.h mesh.h
-mesh.o: mesh.c scenery.h mesh.h common.h
+mesh.o: mesh.c ../constants.h scenery.h mesh.h common.h
 parser.o: parser.c parsevrml.h geometry.h common.h mesh.h scenery.h
 scanner.o: scanner.c parser.h
 scenery.o: scenery.c scenery.h parsevrml.h
index f9ecdc35a44ad36afbd23b18b6f7e2a45b0b3f7c..0e3d93f79d6b82b61459676bba34434d824ce98f 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <GL/glut.h>
 
+#include "../constants.h"
 #include "scenery.h"
 #include "mesh.h"
 #include "common.h"
@@ -196,7 +197,7 @@ double mesh_altitude(double lon, double lat) {
 
     if ( dx > dy ) {
        /* lower triangle */
-       /* printf("  Lower triangle\n"); */
+       printf("  Lower triangle\n");
 
        x1 = xindex; 
        y1 = yindex; 
@@ -210,20 +211,24 @@ double mesh_altitude(double lon, double lat) {
        y3 = yindex + skip; 
        z3 = eg.mesh_data[y3 * eg.cols + x3];
 
-       /* printf("  dx = %.2f  dy = %.2f\n", dx, dy);
+       printf("  dx = %.2f  dy = %.2f\n", dx, dy);
        printf("  (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
        printf("  (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
-       printf("  (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3); */
+       printf("  (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
 
        zA = dx * (z2 - z1) / skip + z1;
        zB = dx * (z3 - z1) / skip + z1;
        
-       /* printf("  zA = %.2f  zB = %.2f\n", zA, zB); */
+       printf("  zA = %.2f  zB = %.2f\n", zA, zB);
 
-       elev = dy * (zB - zA) / dx + zA;
+       if ( dx > EPSILON ) {
+           elev = dy * (zB - zA) / dx + zA;
+       } else {
+           elev = zA;
+       }
     } else {
        /* upper triangle */
-       /* printf("  Upper triangle\n"); */
+       printf("  Upper triangle\n");
 
        x1 = xindex; 
        y1 = yindex; 
@@ -237,18 +242,22 @@ double mesh_altitude(double lon, double lat) {
        y3 = yindex + skip; 
        z3 = eg.mesh_data[y3 * eg.cols + x3];
 
-       /* printf("  dx = %.2f  dy = %.2f\n", dx, dy);
+       printf("  dx = %.2f  dy = %.2f\n", dx, dy);
        printf("  (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
        printf("  (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
-       printf("  (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3); */
+       printf("  (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
  
        zA = dy * (z2 - z1) / skip + z1;
        zB = dy * (z3 - z1) / skip + z1;
        
-       /* printf("  zA = %.2f  zB = %.2f\n", zA, zB );
-       printf("  xB - xA = %.2f\n", eg.col_step * dy / eg.row_step); */
+       printf("  zA = %.2f  zB = %.2f\n", zA, zB );
+       printf("  xB - xA = %.2f\n", eg.col_step * dy / eg.row_step);
 
-       elev = dx * (zB - zA) / dy    + zA;
+       if ( dy > EPSILON ) {
+           elev = dx * (zB - zA) / dy    + zA;
+       } else {
+           elev = zA;
+       }
     }
 
     return(elev);
@@ -256,9 +265,12 @@ double mesh_altitude(double lon, double lat) {
 
 
 /* $Log$
-/* Revision 1.14  1997/07/12 04:01:14  curt
-/* Added #include <Windows32/Base.h> to help Win32 compiling.
+/* Revision 1.15  1997/07/14 16:26:04  curt
+/* Testing/playing -- placed objects randomly across the entire terrain.
 /*
+ * Revision 1.14  1997/07/12 04:01:14  curt
+ * Added #include <Windows32/Base.h> to help Win32 compiling.
+ *
  * Revision 1.13  1997/07/12 02:27:11  curt
  * Looking at potential scenery transformation/coordinate system problems.
  *
index 922dbe429e277dde26b3073a969cfabc2e6c5f46..c474910abec717c754012368a8db5622fd8f97ca 100644 (file)
@@ -41,7 +41,7 @@ struct scenery_params cur_scenery_params;
 /* Initialize the Scenery Management system */
 void fgSceneryInit() {
     /* set the default terrain detail level */
-    cur_scenery_params.terrain_skip = 4;
+    cur_scenery_params.terrain_skip = 5;
 }
 
 
@@ -65,10 +65,13 @@ void fgSceneryRender() {
 
 
 /* $Log$
-/* Revision 1.5  1997/07/11 03:23:19  curt
-/* Solved some scenery display/orientation problems.  Still have a positioning
-/* (or transformation?) problem.
+/* Revision 1.6  1997/07/14 16:26:05  curt
+/* Testing/playing -- placed objects randomly across the entire terrain.
 /*
+ * Revision 1.5  1997/07/11 03:23:19  curt
+ * Solved some scenery display/orientation problems.  Still have a positioning
+ * (or transformation?) problem.
+ *
  * Revision 1.4  1997/07/11 01:30:03  curt
  * More tweaking of terrian floor.
  *
index a06d76e6c910e0242f8c6df50afd7948f46cb007..c735bfcaeabb5a53b61e92b91c705a7895e7523c 100644 (file)
 #define METER_TO_FEET    3.28083989501312335958  
 
 
+/* For divide by zero avoidance, this will be close enough to zero */
+#define EPSILON 0.000001
+
+
 #endif CONSTANTS_H
 
 
 /* $Log$
-/* Revision 1.2  1997/07/08 18:20:11  curt
-/* Working on establishing a hard ground.
+/* Revision 1.3  1997/07/14 16:26:03  curt
+/* Testing/playing -- placed objects randomly across the entire terrain.
 /*
+ * Revision 1.2  1997/07/08 18:20:11  curt
+ * Working on establishing a hard ground.
+ *
  * Revision 1.1  1997/07/07 21:02:36  curt
  * Initial revision.
  * */
index 47af6b17acabbf4641bd385f8f6ff4d6e28bdbb9..e19d2555372ab8245a3b39d1e1641f8dc117345e 100644 (file)
@@ -58,11 +58,14 @@ clean:
 include depend
 
 fg_timer.o:
-       $(CC) $(CFLAGS) $(INCLUDES) -c fg_timer.c
+       $(CC) $(CFLAGS) -c fg_timer.c
 
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.8  1997/07/14 16:26:05  curt
+# Testing/playing -- placed objects randomly across the entire terrain.
+#
 # Revision 1.7  1997/07/12 02:24:48  curt
 # Added ranlib.
 #