1
0
Fork 0

Working on intergrating the VRML (subset) parser.

This commit is contained in:
curt 1997-06-22 21:44:40 +00:00
parent 8f22a9681b
commit 189c638b34
5 changed files with 111 additions and 30 deletions

View file

@ -23,6 +23,7 @@
* (Log is kept at end of this file) * (Log is kept at end of this file)
**************************************************************************/ **************************************************************************/
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -65,8 +66,9 @@ extern struct mesh *mesh_ptr;
/* Function prototypes */ /* Function prototypes */
GLint fgSceneryCompile(); GLint fgSceneryCompile();
static void fgSceneryDraw(); static void fgSceneryDraw();
/* pointer to terrain mesh structure */
static GLint terrain, runway; /* pointer to scenery structure */
static GLint scenery, runway;
/* Another hack */ /* Another hack */
double fogDensity = 2000.0; double fogDensity = 2000.0;
@ -202,7 +204,7 @@ static void fgUpdateVisuals( void ) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
/* glLoadIdentity(); */ /* glLoadIdentity(); */
/* draw terrain mesh */ /* draw scenery */
fgSceneryDraw(); fgSceneryDraw();
#ifdef GLUT #ifdef GLUT
@ -271,19 +273,19 @@ void fgInitTimeDepCalcs() {
**************************************************************************/ **************************************************************************/
static void fgSceneryInit() { static void fgSceneryInit() {
/* make terrain mesh */ /* make scenery */
terrain = fgSceneryCompile(); scenery = fgSceneryCompile();
runway = fgRunwayHack(0.69, 53.07); runway = fgRunwayHack(0.69, 53.07);
} }
/* create the terrain mesh */ /* create the scenery */
GLint fgSceneryCompile() { GLint fgSceneryCompile() {
GLint terrain; GLint scenery;
terrain = mesh2GL(mesh_ptr); scenery = mesh2GL(mesh_ptr);
return(terrain); return(scenery);
} }
@ -332,13 +334,13 @@ GLint fgRunwayHack(double width, double length) {
} }
/* draw the terrain mesh */ /* draw the scenery */
static void fgSceneryDraw() { static void fgSceneryDraw() {
static float z = 32.35; static float z = 32.35;
glPushMatrix(); glPushMatrix();
glCallList(terrain); glCallList(scenery);
printf("*** Drawing runway at %.2f\n", z); printf("*** Drawing runway at %.2f\n", z);
@ -405,9 +407,6 @@ int main( int argc, char *argv[] ) {
f = &current_aircraft.flight; f = &current_aircraft.flight;
/* parse the scenery file */
parse_scenery(argv[1]);
#ifdef GLUT #ifdef GLUT
/* initialize GLUT */ /* initialize GLUT */
glutInit(&argc, argv); glutInit(&argc, argv);
@ -419,7 +418,7 @@ int main( int argc, char *argv[] ) {
glutInitWindowSize(640, 480); glutInitWindowSize(640, 480);
/* Initialize the main window */ /* Initialize the main window */
glutCreateWindow("Terrain Demo"); glutCreateWindow("Flight Gear");
#elif MESA_TK #elif MESA_TK
/* Define initial window size */ /* Define initial window size */
tkInitPosition(0, 0, 640, 480); tkInitPosition(0, 0, 640, 480);
@ -428,7 +427,7 @@ int main( int argc, char *argv[] ) {
tkInitDisplayMode( TK_RGB | TK_DEPTH | TK_DOUBLE | TK_DIRECT ); tkInitDisplayMode( TK_RGB | TK_DEPTH | TK_DOUBLE | TK_DIRECT );
/* Initialize the main window */ /* Initialize the main window */
if (tkInitWindow("Terrain Demo") == GL_FALSE) { if (tkInitWindow("Flight Gear") == GL_FALSE) {
tkQuit(); tkQuit();
} }
#endif #endif
@ -494,6 +493,14 @@ int main( int argc, char *argv[] ) {
} }
/* build all objects */ /* build all objects */
/* parse the scenery file, and build the OpenGL call list */
/* this function will eventually move to the scenery management system */
if ( strlen(argv[1]) ) {
parse_scenery(argv[1]);
}
/* initialize the scenery */
fgSceneryInit(); fgSceneryInit();
#ifdef GLUT #ifdef GLUT
@ -537,9 +544,12 @@ int main( int argc, char *argv[] ) {
/* $Log$ /* $Log$
/* Revision 1.20 1997/06/21 17:12:53 curt /* Revision 1.21 1997/06/22 21:44:41 curt
/* Capitalized subdirectory names. /* Working on intergrating the VRML (subset) parser.
/* /*
* Revision 1.20 1997/06/21 17:12:53 curt
* Capitalized subdirectory names.
*
* Revision 1.19 1997/06/18 04:10:31 curt * Revision 1.19 1997/06/18 04:10:31 curt
* A couple more runway tweaks ... * A couple more runway tweaks ...
* *

View file

@ -33,6 +33,23 @@
#include "common.h" #include "common.h"
/* initialize the non-array mesh values */
void mesh_init(struct mesh *m) {
m->originx = 0.0;
m->originy = 0.0;
m->rows = 0;
m->cols = 0;
m->row_step = 0.0;
m->col_step = 0.0;
m->cur_row = 0;
m->cur_col = 0;
m->do_data = 0;
}
/* return a pointer to a new mesh structure (no data array allocated yet) */ /* return a pointer to a new mesh structure (no data array allocated yet) */
struct mesh *(new_mesh)() { struct mesh *(new_mesh)() {
struct mesh *mesh_ptr; struct mesh *mesh_ptr;
@ -76,13 +93,32 @@ void mesh_set_option_name(struct mesh *m, char *name) {
strncpy(m->option_name, name, MAX_IDENT_LEN - 1); strncpy(m->option_name, name, MAX_IDENT_LEN - 1);
m->option_name[MAX_IDENT_LEN - 1] = '\0'; m->option_name[MAX_IDENT_LEN - 1] = '\0';
} }
if ( strcmp(m->option_name, "do_data") == 0 ) {
m->do_data = 1;
} else {
m->do_data = 0;
}
} }
/* set an option value in the mesh data structure */ /* set an option value in the mesh data structure */
void mesh_set_option_value(struct mesh *m, char *value) { void mesh_set_option_value(struct mesh *m, char *value) {
printf("Setting %s to %s\n", m->option_name, value); /* printf("Setting %s to %s\n", m->option_name, value); */
if ( strcmp(m->option_name, "origin_lon") == 0 ) { if ( m->do_data ) {
/* mesh data is a pseudo 2d array */
/* printf("Setting mesh_data[%d][%d] to %s\n", m->cur_row, m->cur_col,
value); */
m->mesh_data[m->cur_row * m->rows + m->cur_col] = atof(value);
m->cur_col++;
if ( m->cur_col >= m->cols ) {
m->cur_col = 0;
m->cur_row++;
if ( m->cur_row > m->rows ) {
m->do_data = 0;
}
}
} else if ( strcmp(m->option_name, "origin_lon") == 0 ) {
m->originx = atof(value); m->originx = atof(value);
} else if ( strcmp(m->option_name, "origin_lat") == 0 ) { } else if ( strcmp(m->option_name, "origin_lat") == 0 ) {
m->originy = atof(value); m->originy = atof(value);
@ -101,10 +137,20 @@ void mesh_set_option_value(struct mesh *m, char *value) {
} }
/* do whatever needs to be done with the mesh now that it's been
loaded, such as generating the OpenGL call list. */
void mesh_do_it(struct mesh *m) {
mesh2GL(m);
}
/* $Log$ /* $Log$
/* Revision 1.4 1997/05/30 19:30:17 curt /* Revision 1.5 1997/06/22 21:44:41 curt
/* The LaRCsim flight model is starting to look like it is working. /* Working on intergrating the VRML (subset) parser.
/* /*
* Revision 1.4 1997/05/30 19:30:17 curt
* The LaRCsim flight model is starting to look like it is working.
*
* Revision 1.3 1997/05/23 15:40:41 curt * Revision 1.3 1997/05/23 15:40:41 curt
* Added GNU copyright headers. * Added GNU copyright headers.
* *

View file

@ -43,6 +43,7 @@ struct mesh {
/* a temporary values for the parser to use */ /* a temporary values for the parser to use */
char option_name[32]; char option_name[32];
int do_data;
int cur_row, cur_col; int cur_row, cur_col;
}; };
@ -50,6 +51,9 @@ struct mesh {
/* return a pointer to a new mesh structure (no data array allocated yet) */ /* return a pointer to a new mesh structure (no data array allocated yet) */
struct mesh *(new_mesh)(); struct mesh *(new_mesh)();
/* initialize the non-array mesh values */
void mesh_init(struct mesh *m);
/* return a pointer to a dynamically allocated array */ /* return a pointer to a dynamically allocated array */
float *(new_mesh_data)(int nrows, int ncols); float *(new_mesh_data)(int nrows, int ncols);
@ -59,13 +63,21 @@ void mesh_set_option_name(struct mesh *m, char *name);
/* set an option value in the mesh data structure */ /* set an option value in the mesh data structure */
void mesh_set_option_value(struct mesh *m, char *value); void mesh_set_option_value(struct mesh *m, char *value);
/* do whatever needs to be done with the mesh now that it's been
loaded, such as generating the OpenGL call list. */
void mesh_do_it(struct mesh *m);
#endif MESH_H #endif MESH_H
/* $Log$ /* $Log$
/* Revision 1.2 1997/05/23 15:40:42 curt /* Revision 1.3 1997/06/22 21:44:41 curt
/* Added GNU copyright headers. /* Working on intergrating the VRML (subset) parser.
/* /*
* Revision 1.2 1997/05/23 15:40:42 curt
* Added GNU copyright headers.
*
* Revision 1.1 1997/05/16 16:07:05 curt * Revision 1.1 1997/05/16 16:07:05 curt
* Initial revision. * Initial revision.
* *

View file

@ -27,7 +27,7 @@
CC = gcc CC = gcc
SUBSUBDIRS = Flight/LaRCsim Flight/Slew Scenery/ParseScn SUBSUBDIRS = Flight/LaRCsim Flight/Slew Scenery/ParseScn Scenery/ParseVrml
SUBDIRS = Aircraft Controls Flight mat3 Scenery Timer SUBDIRS = Aircraft Controls Flight mat3 Scenery Timer
MAIN = OpenGL MAIN = OpenGL
@ -59,6 +59,9 @@ tar: clean
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $Log$
# Revision 1.9 1997/06/22 21:44:40 curt
# Working on intergrating the VRML (subset) parser.
#
# Revision 1.8 1997/06/21 17:52:22 curt # Revision 1.8 1997/06/21 17:52:22 curt
# Continue directory shuffling ... everything should be compilable/runnable # Continue directory shuffling ... everything should be compilable/runnable
# again. # again.

View file

@ -5,18 +5,18 @@ OpenGL/
"main" and OpenGL dependent mouse/keyboard/graphics code. "main" and OpenGL dependent mouse/keyboard/graphics code.
aircraft/ Aircraft/
--------- ---------
Structure and code to tie together all the pieces of an aircraft such Structure and code to tie together all the pieces of an aircraft such
as flight model, engine model, panel, controls, etc. as flight model, engine model, panel, controls, etc.
controls/ Controls/
--------- ---------
Provide a standardized interface to all aircraft controls. Provide a standardized interface to all aircraft controls.
flight/ Flight/
------- -------
Strucures and code to implement various flight models. Provides a Strucures and code to implement various flight models. Provides a
standardized interface to all interesting flight model variabls. standardized interface to all interesting flight model variabls.
@ -27,11 +27,21 @@ mat3/
Contains miscellaneous matrix/vector routines. Contains miscellaneous matrix/vector routines.
scenery/ Scenery/
-------- --------
Scenery parsing/generating code. Scenery parsing/generating code.
timer/ Sound/
------
Sound management code
Timer/
------ ------
Code to handle time and timing of events. Code to handle time and timing of events.
Weather/
--------
Weather management and modeling code.