1 /**************************************************************************
2 * geometry.c -- data structures and routines for processing vrml geometry
4 * Written by Curtis Olson, started June 1997.
6 * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
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.
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.
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.
23 * (Log is kept at end of this file)
24 **************************************************************************/
35 static vrmlGeometryType;
39 /* Begin a new vrml geometry statement */
40 int vrmlInitGeometry(char *type) {
41 printf("Beginning geometry item = %s\n", type);
43 if ( strcmp(type, "ElevationGrid") == 0 ) {
44 vrmlGeometryType = VRML_ELEV_GRID;
47 vrmlGeometryType = -1;
48 printf("Unimplemented geometry type = %s\n", type);
51 return(vrmlGeometryType);
55 /* Set current vrml geometry option name */
56 void vrmlGeomOptionName(char *name) {
57 /* printf("Found vrml geometry option = %s\n", name); */
59 switch(vrmlGeometryType) {
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");
77 printf("Unknown ElevationGrid option = %s\n", name);
84 /* Set current vrml geometry value */
85 void vrmlGeomOptionsValue(char *value) {
86 /* printf("Found vrml geometry value = %s\n", value); */
88 switch(vrmlGeometryType) {
90 mesh_set_option_value(&eg, value);
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
98 void vrmlHandleGeometry() {
99 switch(vrmlGeometryType) {
106 /* Finish up the current vrml geometry statement */
107 int vrmlFreeGeometry() {
108 printf("Freeing geometry type = %d\n", vrmlGeometryType);
110 switch(vrmlGeometryType) {
112 /* We need to rethink this here, we can't just free the data,
113 * because we need it to calculate current ground elevation
115 /* free(eg.mesh_data); */
117 return(vrmlGeometryType);
122 /* Revision 1.3 1997/07/08 18:20:13 curt
123 /* Working on establishing a hard ground.
125 * Revision 1.2 1997/07/07 20:59:51 curt
126 * Working on scenery transformations to enable us to fly fluidly over the
127 * poles with no discontinuity/distortion in scenery.
129 * Revision 1.1 1997/06/29 21:16:48 curt
130 * More twiddling with the Scenery Management system.
132 * Revision 1.1 1997/06/22 21:42:35 curt
133 * Initial revision of VRML (subset) parser.