]> git.mxchange.org Git - flightgear.git/blob - Tri2obj/tri2obj.c
f5a1a09f15af57c037e768d6fd28daf48362f1cc
[flightgear.git] / Tri2obj / tri2obj.c
1 /* tri2obj.c -- read in a .ele/.node file pair generated by the triangle 
2  *              program and output a simple Wavefront .obj file.
3  *
4  * Written by Curtis Olson, started October 1997.
5  *
6  * Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  */
25
26
27 #include <stdio.h>
28 #include <stdlib.h>   /* for atoi() */
29 #include <string.h>
30 #include <sys/stat.h> /* for stat() */
31 #include <unistd.h>   /* for stat() */
32
33 #include "tri2obj.h"
34
35 #include <Include/fg_constants.h>
36 #include <Include/fg_types.h>
37 #include <Bucket/bucketutils.h>
38
39 #include <Math/fg_geodesy.h>
40 #include <Math/mat3.h>
41 #include <Math/polar3d.h>
42
43
44 int nodecount, tricount;
45 int normalcount = 0;
46 static fgCartesianPoint3d nodes[MAX_NODES];
47 static int tris[MAX_TRIS][3];
48
49 static double normals[MAX_NODES][3];
50
51 fgBUCKET my_index;
52 fgBUCKET ne_index, nw_index, sw_index, se_index;
53 fgBUCKET north_index, south_index, east_index, west_index;
54
55 /* convert a geodetic point lon(arcsec), lat(arcsec), elev(meter) to
56  * a cartesian point */
57 fgCartesianPoint3d geod_to_cart(double geod[3]) {
58     fgCartesianPoint3d cp;
59     fgPolarPoint3d pp;
60     double gc_lon, gc_lat, sl_radius;
61
62     /* printf("A geodetic point is (%.2f, %.2f, %.2f)\n", 
63            geod[0], geod[1], geod[2]); */
64
65     gc_lon = geod[0]*ARCSEC_TO_RAD;
66     fgGeodToGeoc(geod[1]*ARCSEC_TO_RAD, geod[2], &sl_radius, &gc_lat);
67
68     /* printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, 
69            gc_lat, sl_radius+geod[2]); */
70
71     pp.lon = gc_lon;
72     pp.lat = gc_lat;
73     pp.radius = sl_radius+geod[2];
74     cp = fgPolarToCart3d(pp);
75     
76     /* printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z); */
77
78     return(cp);
79 }
80
81
82 /* given three points defining a triangle, calculate the normal */
83 void calc_normal(fgCartesianPoint3d p1, fgCartesianPoint3d p2, 
84                  fgCartesianPoint3d p3, double normal[3])
85 {
86     double v1[3], v2[3];
87     double temp;
88
89     v1[0] = p2.x - p1.x; v1[1] = p2.y - p1.y; v1[2] = p2.z - p1.z;
90     v2[0] = p3.x - p1.x; v2[1] = p3.y - p1.y; v2[2] = p3.z - p1.z;
91
92     MAT3cross_product(normal, v1, v2);
93     MAT3_NORMALIZE_VEC(normal, temp);
94
95 /*  printf("  Normal = %.2f %.2f %.2f\n", normal[0], normal[1], normal[2]); */
96 }
97
98
99 /* return the index of all triangles containing the specified node */
100 void find_tris(int n, int *t1, int *t2, int *t3, int *t4, int *t5) {
101     int i;
102
103     *t1 = *t2 = *t3 = *t4 = *t5 = 0;
104
105     i = 1;
106     while ( i <= tricount ) {
107         if ( (n == tris[i][0]) || (n == tris[i][1]) || (n == tris[i][2]) ) {
108             if ( *t1 == 0 ) {
109                 *t1 = i;
110             } else if ( *t2 == 0 ) {
111                 *t2 = i;
112             } else if ( *t3 == 0 ) {
113                 *t3 = i;
114             } else if ( *t4 == 0 ) {
115                 *t4 = i;
116             } else {
117                 *t5 = i;
118             }
119         }
120         i++;
121     }
122 }
123
124
125 /* return the file base name ( foo/bar/file.ext = file.ext ) */
126 void extract_file(char *in, char *base) {
127     int len, i;
128
129     len = strlen(in);
130
131     i = len - 1;
132     while ( (i >= 0) && (in[i] != '/') ) {
133         i--;
134     }
135
136     in += (i + 1);
137     strcpy(base, in);
138 }
139
140
141 /* return the file path name ( foo/bar/file.ext = foo/bar ) */
142 void extract_path(char *in, char *base) {
143     int len, i;
144
145     len = strlen(in);
146     strcpy(base, in);
147
148     i = len - 1;
149     while ( (i >= 0) && (in[i] != '/') ) {
150         i--;
151     }
152
153     base[i] = '\0';
154 }
155
156
157 /* check if a file exists */
158 int file_exists(char *file) {
159     struct stat stat_buf;
160     int result;
161
162     printf("checking %s ... ", file);
163
164     result = stat(file, &stat_buf);
165
166     if ( result != 0 ) {
167         /* stat failed, no file */
168         printf("not found.\n");
169         return(0);
170     } else {
171         /* stat succeeded, file exists */
172         printf("exists.\n");
173         return(1);
174     }
175 }
176
177
178 /* check to see if a shared object exists */
179 int shared_object_exists(char *basepath, char *ext, char *file) {
180     char scene_path[256];
181     long int index;
182
183     if ( strcmp(ext, ".sw") == 0 ) {
184         fgBucketGenBasePath(&my_index, scene_path);
185         index = fgBucketGenIndex(&my_index);
186         sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
187         if ( file_exists(file) ) {
188             return(1);
189         }
190         fgBucketGenBasePath(&west_index, scene_path);
191         index = fgBucketGenIndex(&west_index);
192         sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
193         if ( file_exists(file) ) {
194             return(1);
195         }
196         fgBucketGenBasePath(&sw_index, scene_path);
197         index = fgBucketGenIndex(&sw_index);
198         sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
199         if ( file_exists(file) ) {
200             return(1);
201         }
202         fgBucketGenBasePath(&south_index, scene_path);
203         index = fgBucketGenIndex(&south_index);
204         sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
205         if ( file_exists(file) ) {
206             return(1);
207         }
208     }
209
210     if ( strcmp(ext, ".se") == 0 ) {
211         fgBucketGenBasePath(&my_index, scene_path);
212         index = fgBucketGenIndex(&my_index);
213         sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
214         if ( file_exists(file) ) {
215             return(1);
216         }
217         fgBucketGenBasePath(&east_index, scene_path);
218         index = fgBucketGenIndex(&east_index);
219         sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
220         if ( file_exists(file) ) {
221             return(1);
222         }
223         fgBucketGenBasePath(&se_index, scene_path);
224         index = fgBucketGenIndex(&se_index);
225         sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
226         if ( file_exists(file) ) {
227             return(1);
228         }
229         fgBucketGenBasePath(&south_index, scene_path);
230         index = fgBucketGenIndex(&south_index);
231         sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
232         if ( file_exists(file) ) {
233             return(1);
234         }
235     }
236
237     if ( strcmp(ext, ".ne") == 0 ) {
238         fgBucketGenBasePath(&my_index, scene_path);
239         index = fgBucketGenIndex(&my_index);
240         sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
241         if ( file_exists(file) ) {
242             return(1);
243         }
244         fgBucketGenBasePath(&east_index, scene_path);
245         index = fgBucketGenIndex(&east_index);
246         sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
247         if ( file_exists(file) ) {
248             return(1);
249         }
250         fgBucketGenBasePath(&ne_index, scene_path);
251         index = fgBucketGenIndex(&ne_index);
252         sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
253         if ( file_exists(file) ) {
254             return(1);
255         }
256         fgBucketGenBasePath(&north_index, scene_path);
257         index = fgBucketGenIndex(&north_index);
258         sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
259         if ( file_exists(file) ) {
260             return(1);
261         }
262     }
263
264     if ( strcmp(ext, ".nw") == 0 ) {
265         fgBucketGenBasePath(&my_index, scene_path);
266         index = fgBucketGenIndex(&my_index);
267         sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
268         if ( file_exists(file) ) {
269             return(1);
270         }
271         fgBucketGenBasePath(&west_index, scene_path);
272         index = fgBucketGenIndex(&west_index);
273         sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
274         if ( file_exists(file) ) {
275             return(1);
276         }
277         fgBucketGenBasePath(&nw_index, scene_path);
278         index = fgBucketGenIndex(&nw_index);
279         sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
280         if ( file_exists(file) ) {
281             return(1);
282         }
283         fgBucketGenBasePath(&north_index, scene_path);
284         index = fgBucketGenIndex(&north_index);
285         sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
286         if ( file_exists(file) ) {
287             return(1);
288         }
289     }
290
291     if ( strcmp(ext, ".south") == 0 ) {
292         fgBucketGenBasePath(&my_index, scene_path);
293         index = fgBucketGenIndex(&my_index);
294         sprintf(file, "%s/%s/%ld.1.south", basepath, scene_path, index);
295         if ( file_exists(file) ) {
296             return(1);
297         }
298         fgBucketGenBasePath(&south_index, scene_path);
299         index = fgBucketGenIndex(&south_index);
300         sprintf(file, "%s/%s/%ld.1.north", basepath, scene_path, index);
301         if ( file_exists(file) ) {
302             return(1);
303         }
304     }
305
306     if ( strcmp(ext, ".north") == 0 ) {
307         fgBucketGenBasePath(&my_index, scene_path);
308         index = fgBucketGenIndex(&my_index);
309         sprintf(file, "%s/%s/%ld.1.north", basepath, scene_path, index);
310         if ( file_exists(file) ) {
311             return(1);
312         }
313         fgBucketGenBasePath(&north_index, scene_path);
314         index = fgBucketGenIndex(&north_index);
315         sprintf(file, "%s/%s/%ld.1.south", basepath, scene_path, index);
316         if ( file_exists(file) ) {
317             return(1);
318         }
319     }
320
321     if ( strcmp(ext, ".west") == 0 ) {
322         fgBucketGenBasePath(&my_index, scene_path);
323         index = fgBucketGenIndex(&my_index);
324         sprintf(file, "%s/%s/%ld.1.west", basepath, scene_path, index);
325         if ( file_exists(file) ) {
326             return(1);
327         }
328         fgBucketGenBasePath(&west_index, scene_path);
329         index = fgBucketGenIndex(&west_index);
330         sprintf(file, "%s/%s/%ld.1.east", basepath, scene_path, index);
331         if ( file_exists(file) ) {
332             return(1);
333         }
334     }
335
336     if ( strcmp(ext, ".east") == 0 ) {
337         fgBucketGenBasePath(&my_index, scene_path);
338         index = fgBucketGenIndex(&my_index);
339         sprintf(file, "%s/%s/%ld.1.east", basepath, scene_path, index);
340         if ( file_exists(file) ) {
341             return(1);
342         }
343         fgBucketGenBasePath(&east_index, scene_path);
344         index = fgBucketGenIndex(&east_index);
345         sprintf(file, "%s/%s/%ld.1.west", basepath, scene_path, index);
346         if ( file_exists(file) ) {
347             return(1);
348         }
349     }
350
351     if ( strcmp(ext, ".body") == 0 ) {
352         fgBucketGenBasePath(&my_index, scene_path);
353         index = fgBucketGenIndex(&my_index);
354         sprintf(file, "%s/%s/%ld.1.body", basepath, scene_path, index);
355         if ( file_exists(file) ) {
356             return(1);
357         }
358     }
359
360     return(0);
361 }
362
363
364 /* given a file pointer, read all the vn (normals from it) */
365 void read_normals(FILE *fp) {
366     char line[256];
367
368     while ( fgets(line, 250, fp) != NULL ) {
369         if ( strncmp(line, "vn ", 3) == 0 ) {
370             sscanf( line, "vn %lf %lf %lf\n", 
371                     &normals[normalcount][0], 
372                     &normals[normalcount][1], 
373                     &normals[normalcount][2] );
374             /*
375             printf("read_normals(%d) %.2f %.2f %.2f %s", normalcount, 
376                    normals[normalcount][0], normals[normalcount][1], 
377                    normals[normalcount][2], line);
378                    */
379             normalcount++;
380         }
381     }
382 }
383
384
385 /* my custom file opening routine ... don't open if a shared edge or
386  * vertex alread exists */
387 FILE *my_open(char *basename, char *basepath, char *ext) {
388     FILE *fp;
389     char filename[256];
390
391     /* check if a shared object already exists */
392     if ( shared_object_exists(basepath, ext, filename) ) {
393         /* not an actual file open error, but we've already got the
394          * shared edge, so we don't want to create another one */
395         fp = fopen(filename, "r");
396         printf("Opening %s\n", filename);
397         return(fp);
398     } else {
399         /* open the file */
400         printf("not opening\n");
401         return(NULL);
402     }
403 }
404
405
406 /* Initialize a new mesh structure */
407 void triload(char *basename, char *basepath) {
408     char nodename[256], elename[256];
409     double n[3];
410     FILE *ne, *nw, *se, *sw, *north, *south, *east, *west;
411     FILE *node, *ele;
412     int dim, junk1, junk2;
413     int i;
414
415     ne = my_open(basename, basepath, ".ne");
416     read_normals(ne);
417     fclose(ne);
418
419     nw = my_open(basename, basepath, ".nw");
420     read_normals(nw);
421     fclose(nw);
422
423     se = my_open(basename, basepath, ".se");
424     read_normals(se);
425     fclose(se);
426
427     sw = my_open(basename, basepath, ".sw");
428     read_normals(sw);
429     fclose(sw);
430
431     north = my_open(basename, basepath, ".north");
432     read_normals(north);
433     fclose(north);
434
435     south = my_open(basename, basepath, ".south");
436     read_normals(south);
437     fclose(south);
438
439     east = my_open(basename, basepath, ".east");
440     read_normals(east);
441     fclose(east);
442
443     west = my_open(basename, basepath, ".west");
444     read_normals(west);
445     fclose(west);
446
447     strcpy(nodename, basename);
448     strcat(nodename, ".node");
449     strcpy(elename, basename);
450     strcat(elename, ".ele");
451
452     printf("Loading node file:  %s ...\n", nodename);
453     if ( (node = fopen(nodename, "r")) == NULL ) {
454         printf("Cannot open file '%s'\n", nodename);
455         exit(-1);
456     }
457
458     fscanf(node, "%d %d %d %d", &nodecount, &dim, &junk1, &junk2);
459
460     if ( nodecount > MAX_NODES - 1 ) {
461         printf("Error, too many nodes, need to increase array size\n");
462         exit(-1);
463     } else {
464         printf("    Expecting %d nodes\n", nodecount);
465     }
466
467     for ( i = 1; i <= nodecount; i++ ) {
468         fscanf(node, "%d %lf %lf %lf %d\n", &junk1, 
469                &n[0], &n[1], &n[2], &junk2);
470         /* printf("%d %.2f %.2f %.2f\n", junk1, n[0], n[1], n[2]); */
471         nodes[i] = geod_to_cart(n);
472         /* printf("%d %.2f %.2f %.2f\n", 
473                junk1, nodes[i].x, nodes[i].y, nodes[i].z); */
474     }
475
476     fclose(node);
477
478     printf("Loading element file:  %s ...\n", elename);
479     if ( (ele = fopen(elename, "r")) == NULL ) {
480         printf("Cannot open file '%s'\n", elename);
481         exit(-1);
482     }
483
484     fscanf(ele, "%d %d %d", &tricount, &junk1, &junk2);
485
486     if ( tricount > MAX_TRIS - 1 ) {
487         printf("Error, too many elements, need to increase array size\n");
488         exit(-1);
489     } else {
490         printf("    Expecting %d elements\n", tricount);
491     }
492
493     for ( i = 1; i <= tricount; i++ ) {
494         fscanf(ele, "%d %d %d %d\n", &junk1, 
495                &tris[i][0], &tris[i][1], &tris[i][2]);
496         /* printf("%d %d %d %d\n", junk1, tris[i][0], tris[i][1], tris[i][2]);*/
497     }
498
499     fclose(ele);
500 }
501
502
503 /* dump in WaveFront .obj format */
504 void dump_obj(char *basename) {
505     char objname[256];
506     double n1[3], n2[3], n3[3], n4[3], n5[3], norm[3], temp;
507     FILE *obj;
508     int i, t1, t2, t3, t4, t5, count;
509
510     strcpy(objname, basename);
511     strcat(objname, ".obj");
512
513     printf("Dumping to file:  %s ...\n", objname);
514
515     obj = fopen(objname, "w");
516
517     /* dump vertices */
518     printf("  writing vertices\n");
519     for ( i = 1; i <= nodecount; i++ ) {
520         fprintf(obj, "v %.6f %.6f %.6f\n", 
521                 nodes[i].x, nodes[i].y, nodes[i].z);
522     }
523
524     printf("  calculating and writing normals\n");
525     printf("  First %d normals taken from shared files.\n", normalcount);
526                                                      
527     /* calculate and generate normals */
528     for ( i = 1; i <= nodecount; i++ ) {
529
530         if ( i <= normalcount ) {
531             /* use precalculated (shared) normal */
532             norm[0] = normals[i-1][0];
533             norm[1] = normals[i-1][1];
534             norm[2] = normals[i-1][2];
535         } else {
536             /* printf("Finding normal\n"); */
537
538             find_tris(i, &t1, &t2, &t3, &t4, &t5);
539
540             n1[0] = n1[1] = n1[2] = 0.0;
541             n2[0] = n2[1] = n2[2] = 0.0;
542             n3[0] = n3[1] = n3[2] = 0.0;
543             n4[0] = n4[1] = n4[2] = 0.0;
544             n5[0] = n5[1] = n5[2] = 0.0;
545
546             count = 1;
547             calc_normal(nodes[tris[t1][0]], nodes[tris[t1][1]], 
548                         nodes[tris[t1][2]], n1);
549
550             if ( t2 > 0 ) {
551                 calc_normal(nodes[tris[t2][0]], nodes[tris[t2][1]], 
552                             nodes[tris[t2][2]], n2);
553                 count = 2;
554             }
555
556             if ( t3 > 0 ) {
557                 calc_normal(nodes[tris[t3][0]], nodes[tris[t3][1]],
558                             nodes[tris[t3][2]], n3);
559                 count = 3;
560             }
561
562             if ( t4 > 0 ) {
563                 calc_normal(nodes[tris[t4][0]], nodes[tris[t4][1]],
564                             nodes[tris[t4][2]], n4);
565                 count = 4;
566             }
567
568             if ( t5 > 0 ) {
569                 calc_normal(nodes[tris[t5][0]], nodes[tris[t5][1]],
570                             nodes[tris[t5][2]], n5);
571                 count = 5;
572             }
573
574             /* printf("  norm[2] = %.2f %.2f %.2f\n", n1[2], n2[2], n3[2]); */
575
576             norm[0] = ( n1[0] + n2[0] + n3[0] + n4[0] + n5[0] ) / (double)count;
577             norm[1] = ( n1[1] + n2[1] + n3[1] + n4[1] + n5[1] ) / (double)count;
578             norm[2] = ( n1[2] + n2[2] + n3[2] + n4[2] + n5[2] ) / (double)count;
579         
580             /*  printf("  count = %d\n", count); */
581             /*  printf("  Ave. normal = %.4f %.4f %.4f\n", 
582                        norm[0], norm[1], norm[2]);*/
583             MAT3_NORMALIZE_VEC(norm, temp);
584             /*  printf("  Normalized ave. normal = %.4f %.4f %.4f\n",  */
585             /*         norm[0], norm[1], norm[2]); */
586         }
587         /* printf("%d vn %.4f %.4f %.4f\n", i, norm[0], norm[1], norm[2]); */
588         fprintf(obj, "vn %.4f %.4f %.4f\n", norm[0], norm[1], norm[2]);
589     }
590
591     /* dump faces */
592     printf("  writing faces\n");
593     for ( i = 1; i <= tricount; i++ ) {
594         fprintf(obj, "f %d %d %d\n", tris[i][0], tris[i][1], tris[i][2]);
595     }
596
597     fclose(obj);
598 }
599
600 int main(int argc, char **argv) {
601     char basename[256], basepath[256], temp[256];
602     long int tmp_index;
603     int len;
604
605     strcpy(basename, argv[1]);
606
607     /* find the base path of the file */
608     extract_path(basename, basepath);
609     extract_path(basepath, basepath);
610     extract_path(basepath, basepath);
611     printf("%s\n", basepath);
612
613     /* find the index of the current file */
614     extract_file(basename, temp);
615     len = strlen(temp);
616     if ( len >= 2 ) {
617         temp[len-2] = '\0';
618     }
619     tmp_index = atoi(temp);
620     printf("%ld\n", tmp_index);
621     fgBucketParseIndex(tmp_index, &my_index);
622
623     printf("bucket = %d %d %d %d\n", 
624            my_index.lon, my_index.lat, my_index.x, my_index.y);
625     /* generate the indexes of the neighbors */
626     fgBucketOffset(&my_index, &ne_index,  1,  1);
627     fgBucketOffset(&my_index, &nw_index, -1,  1);
628     fgBucketOffset(&my_index, &se_index,  1, -1);
629     fgBucketOffset(&my_index, &sw_index, -1, -1);
630
631     fgBucketOffset(&my_index, &north_index,  0,  1);
632     fgBucketOffset(&my_index, &south_index,  0, -1);
633     fgBucketOffset(&my_index, &east_index,  1,  0);
634     fgBucketOffset(&my_index, &west_index, -1,  0);
635
636     /* load the input data files */
637     triload(basename, basepath);
638
639     /* dump in WaveFront .obj format */
640     dump_obj(basename);
641
642     return(0);
643 }
644
645
646 /* $Log$
647 /* Revision 1.17  1998/07/04 00:56:40  curt
648 /* typedef'd struct fgBUCKET.
649 /*
650  * Revision 1.16  1998/05/23 15:20:41  curt
651  * Output more digits after the decimal place.
652  *
653  * Revision 1.15  1998/05/02 01:54:39  curt
654  * Converting to polar3d.h routines.
655  *
656  * Revision 1.14  1998/04/18 04:01:32  curt
657  * Now use libMath rather than having local copies of math routines.
658  *
659  * Revision 1.13  1998/04/14 02:26:11  curt
660  * Code reorganizations.  Added a Lib/ directory for more general libraries.
661  *
662  * Revision 1.12  1998/04/08 23:22:18  curt
663  * Adopted Gnu automake/autoconf system.
664  *
665  * Revision 1.11  1998/03/03 16:01:00  curt
666  * More c++ compile tweaks.
667  *
668  * Revision 1.10  1998/01/31 00:41:27  curt
669  * Made a few changes converting floats to doubles.
670  *
671  * Revision 1.9  1998/01/27 18:37:04  curt
672  * Lots of updates to get back in sync with changes made over in .../Src/
673  *
674  * Revision 1.8  1998/01/17 01:25:39  curt
675  * Added support for shared normals.
676  *
677  * Revision 1.7  1998/01/12 02:42:00  curt
678  * Average up to five triangles per vertex instead of three.
679  *
680  * Revision 1.6  1998/01/09 23:03:15  curt
681  * Restructured to split 1deg x 1deg dem's into 64 subsections.
682  *
683  * Revision 1.5  1997/12/08 19:17:50  curt
684  * Fixed a type in the normal generation code.
685  *
686  * Revision 1.4  1997/12/02 13:13:32  curt
687  * Fixed problem with averaged vertex normals.
688  *
689  * Revision 1.3  1997/11/15 18:05:05  curt
690  * minor tweaks ...
691  *
692  * Revision 1.2  1997/11/14 00:29:13  curt
693  * Transform scenery coordinates at this point in pipeline when scenery is
694  * being translated to .obj format, not when it is being loaded into the end
695  * renderer.  Precalculate normals for each node as average of the normals
696  * of each containing polygon so Garoude shading is now supportable.
697  *
698  * Revision 1.1  1997/10/29 23:05:15  curt
699  * Initial revision.
700  *
701  */