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;
36 static struct mesh eg;
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, "xDimension") == 0 ) {
62 mesh_set_option_name(&eg, "rows");
63 } else if ( strcmp(name, "zDimension") == 0 ) {
64 mesh_set_option_name(&eg, "cols");
65 } else if ( strcmp(name, "xSpacing") == 0 ) {
66 mesh_set_option_name(&eg, "row_step");
67 } else if ( strcmp(name, "zSpacing") == 0 ) {
68 mesh_set_option_name(&eg, "col_step");
69 } else if ( strcmp(name, "height") == 0 ) {
70 eg.mesh_data = new_mesh_data(eg.rows, eg.cols);
71 mesh_set_option_name(&eg, "do_data");
73 printf("Unknown ElevationGrid option = %s\n", name);
80 /* Set current vrml geometry value */
81 void vrmlGeomOptionsValue(char *value) {
82 /* printf("Found vrml geometry value = %s\n", value); */
84 switch(vrmlGeometryType) {
86 mesh_set_option_value(&eg, value);
91 /* We've finished parsing the current geometry. Now do whatever needs
92 * to be done with it (like generating the OpenGL call list for
94 void vrmlHandleGeometry() {
95 switch(vrmlGeometryType) {
102 /* Finish up the current vrml geometry statement */
103 int vrmlFreeGeometry() {
104 printf("Freeing geometry type = %d\n", vrmlGeometryType);
106 switch(vrmlGeometryType) {
110 return(vrmlGeometryType);
115 /* Revision 1.1 1997/06/29 21:16:48 curt
116 /* More twiddling with the Scenery Management system.
118 * Revision 1.1 1997/06/22 21:42:35 curt
119 * Initial revision of VRML (subset) parser.