]> git.mxchange.org Git - flightgear.git/blob - Scenery/geometry.c
Changed naming scheme of basic shared structures.
[flightgear.git] / Scenery / geometry.c
1 /**************************************************************************
2  * geometry.c -- data structures and routines for processing vrml geometry
3  *
4  * Written by Curtis Olson, started June 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
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * 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>
29 #include <string.h>
30
31 #include "geometry.h"
32 #include "mesh.h"
33
34
35 static vrmlGeometryType;
36 struct MESH eg;
37
38
39 /* Begin a new vrml geometry statement */
40 int vrmlInitGeometry(char *type) {
41     printf("Beginning geometry item = %s\n", type);
42
43     if ( strcmp(type, "ElevationGrid") == 0 ) {
44         vrmlGeometryType = VRML_ELEV_GRID;
45         mesh_init(&eg);
46     } else {
47         vrmlGeometryType = -1;
48         printf("Unimplemented geometry type = %s\n", type);
49     }
50
51     return(vrmlGeometryType);
52 }
53
54
55 /* Set current vrml geometry option name */
56 void vrmlGeomOptionName(char *name) {
57     /* printf("Found vrml geometry option = %s\n", name); */
58
59     switch(vrmlGeometryType) {
60     case VRML_ELEV_GRID:
61         if ( strcmp(name, "xOrigin") == 0 ) {
62             mesh_set_option_name(&eg, "origin_lon");
63         } else if ( strcmp(name, "zOrigin") == 0 ) {
64             mesh_set_option_name(&eg, "origin_lat");
65         } else if ( strcmp(name, "xDimension") == 0 ) {
66             mesh_set_option_name(&eg, "rows");
67         } else if ( strcmp(name, "zDimension") == 0 ) {
68             mesh_set_option_name(&eg, "cols");
69         } else if ( strcmp(name, "xSpacing") == 0 ) {
70             mesh_set_option_name(&eg, "row_step");
71         } else if ( strcmp(name, "zSpacing") == 0 ) {
72             mesh_set_option_name(&eg, "col_step");
73         } else if ( strcmp(name, "height") == 0 ) {
74             eg.mesh_data = new_mesh_data(eg.rows, eg.cols);
75             mesh_set_option_name(&eg, "do_data");
76         } else {
77             printf("Unknown ElevationGrid option = %s\n", name);
78         }
79         break;
80     }
81 }
82
83
84 /* Set current vrml geometry value */
85 void vrmlGeomOptionsValue(char *value) {
86     /* printf("Found vrml geometry value = %s\n", value); */
87
88     switch(vrmlGeometryType) {
89     case VRML_ELEV_GRID:
90         mesh_set_option_value(&eg, value);
91     }
92 }
93
94
95 /* We've finished parsing the current geometry.  Now do whatever needs
96  * to be done with it (like generating the OpenGL call list for
97  * instance */
98 void vrmlHandleGeometry() {
99     switch(vrmlGeometryType) {
100     case VRML_ELEV_GRID:
101         mesh_do_it(&eg);
102     }
103 }
104
105
106 /* Finish up the current vrml geometry statement */
107 int vrmlFreeGeometry() {
108     printf("Freeing geometry type = %d\n", vrmlGeometryType);
109
110     switch(vrmlGeometryType) {
111     case VRML_ELEV_GRID:
112         /* We need to rethink this here, we can't just free the data,
113          * because we need it to calculate current ground elevation
114          * ... */
115         /* free(eg.mesh_data); */
116     }
117     return(vrmlGeometryType);
118 }
119
120
121 /* $Log$
122 /* Revision 1.4  1997/08/27 03:30:26  curt
123 /* Changed naming scheme of basic shared structures.
124 /*
125  * Revision 1.3  1997/07/08 18:20:13  curt
126  * Working on establishing a hard ground.
127  *
128  * Revision 1.2  1997/07/07 20:59:51  curt
129  * Working on scenery transformations to enable us to fly fluidly over the
130  * poles with no discontinuity/distortion in scenery.
131  *
132  * Revision 1.1  1997/06/29 21:16:48  curt
133  * More twiddling with the Scenery Management system.
134  *
135  * Revision 1.1  1997/06/22 21:42:35  curt
136  * Initial revision of VRML (subset) parser.
137  *
138  */