]> git.mxchange.org Git - flightgear.git/blobdiff - Scenery/mesh.c
Tons of little changes to clean up the code and to remove fatal errors
[flightgear.git] / Scenery / mesh.c
index cf154c72de58436d74b16b0818b9cedd53959904..4cbd2f53dc5bbbbc85eb586e72f013f7df6da758 100644 (file)
@@ -38,8 +38,8 @@
 
 #include <GL/glut.h>
 
-#include "../constants.h"
-#include "../types.h"
+#include "../Include/constants.h"
+#include "../Include/types.h"
 #include "../Math/fg_geodesy.h"
 #include "../Math/fg_random.h"
 #include "../Math/mat3.h"
 
 
 /* Temporary hack until we get the scenery management system running */
-extern GLint mesh_hack;
-extern struct mesh eg;
+extern GLint area_terrain;
+extern struct MESH eg;
 
 /* initialize the non-array mesh values */
-void mesh_init(struct mesh *m) {
+void mesh_init(struct MESH *m) {
     m->originx = 0.0;
     m->originy = 0.0;
 
@@ -72,10 +72,10 @@ void mesh_init(struct mesh *m) {
 
 
 /* return a pointer to a new mesh structure (no data array allocated yet) */
-struct mesh *(new_mesh)() {
-    struct mesh *mesh_ptr;
+struct MESH *(new_mesh)( void ) {
+    struct MESH *mesh_ptr;
 
-    mesh_ptr = (struct mesh *)malloc(sizeof(struct mesh));
+    mesh_ptr = (struct MESH *)malloc(sizeof(struct MESH));
 
     if ( mesh_ptr == 0 ) {
        printf("Virtual memory exceeded\n");
@@ -107,7 +107,7 @@ float *(new_mesh_data)(int nrows, int ncols) {
 
 
 /* set the option name in the mesh data structure */
-void mesh_set_option_name(struct mesh *m, char *name) {
+void mesh_set_option_name(struct MESH *m, char *name) {
     if ( strlen(name) < MAX_IDENT_LEN ) {
        strcpy(m->option_name, name);
     } else {
@@ -123,7 +123,7 @@ void mesh_set_option_name(struct mesh *m, char *name) {
 
 
 /* set an option value in the mesh data structure */
-void mesh_set_option_value(struct mesh *m, char *value) {
+void mesh_set_option_value(struct MESH *m, char *value) {
     /* printf("Setting %s to %s\n", m->option_name, value); */
 
     if ( m->do_data ) {
@@ -160,8 +160,8 @@ void mesh_set_option_value(struct mesh *m, char *value) {
 
 /* do whatever needs to be done with the mesh now that it's been
    loaded, such as generating the OpenGL call list. */
-void mesh_do_it(struct mesh *m) {
-    mesh_hack = mesh_to_OpenGL(m);
+void mesh_do_it(struct MESH *m) {
+    area_terrain = mesh_to_OpenGL(m);
 }
 
 
@@ -227,7 +227,7 @@ double mesh_altitude(double lon, double lat) {
        
        /* printf("  zA = %.2f  zB = %.2f\n", zA, zB); */
 
-       if ( dx > EPSILON ) {
+       if ( dx > FG_EPSILON ) {
            elev = dy * (zB - zA) / dx + zA;
        } else {
            elev = zA;
@@ -259,7 +259,7 @@ double mesh_altitude(double lon, double lat) {
        /* printf("  zA = %.2f  zB = %.2f\n", zA, zB );
        printf("  xB - xA = %.2f\n", eg.col_step * dy / eg.row_step); */
 
-       if ( dy > EPSILON ) {
+       if ( dy > FG_EPSILON ) {
            elev = dx * (zB - zA) / dy    + zA;
        } else {
            elev = zA;
@@ -271,10 +271,11 @@ double mesh_altitude(double lon, double lat) {
 
 
 /* walk through mesh and make opengl calls */
-GLint mesh_to_OpenGL(struct mesh *m) {
+GLint mesh_to_OpenGL(struct MESH *m) {
     GLint mesh;
     /* static GLfloat color[4] = { 0.5, 0.4, 0.25, 1.0 }; */ /* dark desert */
-    static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 };
+    /* static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 }; */
+    static GLfloat color[4] = { 1.0, 0.0, 0.0, 1.0 };
     double centerx, centery;
     double randx, randy;
 
@@ -302,7 +303,8 @@ GLint mesh_to_OpenGL(struct mesh *m) {
     mesh = glGenLists(1);
     glNewList(mesh, GL_COMPILE);
 
-    glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color );
+    /* glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color ); */
+    glColor3fv(color);
 
     iend = m->cols - 1;
     jend = m->rows - 1;
@@ -394,9 +396,32 @@ GLint mesh_to_OpenGL(struct mesh *m) {
 
 
 /* $Log$
-/* Revision 1.19  1997/08/06 00:24:28  curt
-/* Working on correct real time sun lighting.
+/* Revision 1.26  1998/01/19 18:40:36  curt
+/* Tons of little changes to clean up the code and to remove fatal errors
+/* when building with the c++ compiler.
 /*
+ * Revision 1.25  1998/01/07 03:31:27  curt
+ * Miscellaneous tweaks.
+ *
+ * Revision 1.24  1997/12/15 23:54:59  curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
+ * Revision 1.23  1997/10/30 12:38:44  curt
+ * Working on new scenery subsystem.
+ *
+ * Revision 1.22  1997/10/28 21:00:21  curt
+ * Changing to new terrain format.
+ *
+ * Revision 1.21  1997/08/27 03:30:27  curt
+ * Changed naming scheme of basic shared structures.
+ *
+ * Revision 1.20  1997/08/19 23:55:08  curt
+ * Worked on better simulating real lighting.
+ *
+ * Revision 1.19  1997/08/06 00:24:28  curt
+ * Working on correct real time sun lighting.
+ *
  * Revision 1.18  1997/08/02 19:10:14  curt
  * Incorporated mesh2GL.c into mesh.c
  *