1997-06-29 21:16:47 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* geometry.c -- data structures and routines for processing vrml geometry
|
|
|
|
*
|
|
|
|
* Written by Curtis Olson, started June 1997.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
* (Log is kept at end of this file)
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "geometry.h"
|
|
|
|
#include "mesh.h"
|
|
|
|
|
|
|
|
|
|
|
|
static vrmlGeometryType;
|
1997-08-27 03:29:38 +00:00
|
|
|
struct MESH eg;
|
1997-06-29 21:16:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Begin a new vrml geometry statement */
|
|
|
|
int vrmlInitGeometry(char *type) {
|
|
|
|
printf("Beginning geometry item = %s\n", type);
|
|
|
|
|
|
|
|
if ( strcmp(type, "ElevationGrid") == 0 ) {
|
|
|
|
vrmlGeometryType = VRML_ELEV_GRID;
|
|
|
|
mesh_init(&eg);
|
|
|
|
} else {
|
|
|
|
vrmlGeometryType = -1;
|
|
|
|
printf("Unimplemented geometry type = %s\n", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(vrmlGeometryType);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Set current vrml geometry option name */
|
|
|
|
void vrmlGeomOptionName(char *name) {
|
|
|
|
/* printf("Found vrml geometry option = %s\n", name); */
|
|
|
|
|
|
|
|
switch(vrmlGeometryType) {
|
|
|
|
case VRML_ELEV_GRID:
|
1997-07-07 20:59:47 +00:00
|
|
|
if ( strcmp(name, "xOrigin") == 0 ) {
|
|
|
|
mesh_set_option_name(&eg, "origin_lon");
|
|
|
|
} else if ( strcmp(name, "zOrigin") == 0 ) {
|
|
|
|
mesh_set_option_name(&eg, "origin_lat");
|
|
|
|
} else if ( strcmp(name, "xDimension") == 0 ) {
|
1997-06-29 21:16:47 +00:00
|
|
|
mesh_set_option_name(&eg, "rows");
|
|
|
|
} else if ( strcmp(name, "zDimension") == 0 ) {
|
|
|
|
mesh_set_option_name(&eg, "cols");
|
|
|
|
} else if ( strcmp(name, "xSpacing") == 0 ) {
|
|
|
|
mesh_set_option_name(&eg, "row_step");
|
|
|
|
} else if ( strcmp(name, "zSpacing") == 0 ) {
|
|
|
|
mesh_set_option_name(&eg, "col_step");
|
|
|
|
} else if ( strcmp(name, "height") == 0 ) {
|
|
|
|
eg.mesh_data = new_mesh_data(eg.rows, eg.cols);
|
|
|
|
mesh_set_option_name(&eg, "do_data");
|
|
|
|
} else {
|
|
|
|
printf("Unknown ElevationGrid option = %s\n", name);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Set current vrml geometry value */
|
|
|
|
void vrmlGeomOptionsValue(char *value) {
|
|
|
|
/* printf("Found vrml geometry value = %s\n", value); */
|
|
|
|
|
|
|
|
switch(vrmlGeometryType) {
|
|
|
|
case VRML_ELEV_GRID:
|
|
|
|
mesh_set_option_value(&eg, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* We've finished parsing the current geometry. Now do whatever needs
|
|
|
|
* to be done with it (like generating the OpenGL call list for
|
|
|
|
* instance */
|
|
|
|
void vrmlHandleGeometry() {
|
|
|
|
switch(vrmlGeometryType) {
|
|
|
|
case VRML_ELEV_GRID:
|
|
|
|
mesh_do_it(&eg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Finish up the current vrml geometry statement */
|
|
|
|
int vrmlFreeGeometry() {
|
|
|
|
printf("Freeing geometry type = %d\n", vrmlGeometryType);
|
|
|
|
|
|
|
|
switch(vrmlGeometryType) {
|
|
|
|
case VRML_ELEV_GRID:
|
1997-07-08 18:20:11 +00:00
|
|
|
/* We need to rethink this here, we can't just free the data,
|
|
|
|
* because we need it to calculate current ground elevation
|
|
|
|
* ... */
|
|
|
|
/* free(eg.mesh_data); */
|
1998-01-06 01:20:16 +00:00
|
|
|
;
|
1997-06-29 21:16:47 +00:00
|
|
|
}
|
|
|
|
return(vrmlGeometryType);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* $Log$
|
1998-01-06 01:20:16 +00:00
|
|
|
/* Revision 1.5 1998/01/06 01:20:23 curt
|
|
|
|
/* Tweaks to help building with MSVC++
|
1997-06-29 21:16:47 +00:00
|
|
|
/*
|
1998-01-06 01:20:16 +00:00
|
|
|
* Revision 1.4 1997/08/27 03:30:26 curt
|
|
|
|
* Changed naming scheme of basic shared structures.
|
|
|
|
*
|
1997-08-27 03:29:38 +00:00
|
|
|
* Revision 1.3 1997/07/08 18:20:13 curt
|
|
|
|
* Working on establishing a hard ground.
|
|
|
|
*
|
1997-07-08 18:20:11 +00:00
|
|
|
* Revision 1.2 1997/07/07 20:59:51 curt
|
|
|
|
* Working on scenery transformations to enable us to fly fluidly over the
|
|
|
|
* poles with no discontinuity/distortion in scenery.
|
|
|
|
*
|
1997-07-07 20:59:47 +00:00
|
|
|
* Revision 1.1 1997/06/29 21:16:48 curt
|
|
|
|
* More twiddling with the Scenery Management system.
|
|
|
|
*
|
1997-06-29 21:16:47 +00:00
|
|
|
* Revision 1.1 1997/06/22 21:42:35 curt
|
|
|
|
* Initial revision of VRML (subset) parser.
|
|
|
|
*
|
|
|
|
*/
|