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)
**************************************************************************/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@ -65,8 +66,9 @@ extern struct mesh *mesh_ptr;
/* Function prototypes */
GLint fgSceneryCompile();
static void fgSceneryDraw();
/* pointer to terrain mesh structure */
static GLint terrain, runway;
/* pointer to scenery structure */
static GLint scenery, runway;
/* Another hack */
double fogDensity = 2000.0;
@ -202,7 +204,7 @@ static void fgUpdateVisuals( void ) {
glMatrixMode(GL_MODELVIEW);
/* glLoadIdentity(); */
/* draw terrain mesh */
/* draw scenery */
fgSceneryDraw();
#ifdef GLUT
@ -271,19 +273,19 @@ void fgInitTimeDepCalcs() {
**************************************************************************/
static void fgSceneryInit() {
/* make terrain mesh */
terrain = fgSceneryCompile();
/* make scenery */
scenery = fgSceneryCompile();
runway = fgRunwayHack(0.69, 53.07);
}
/* create the terrain mesh */
/* create the scenery */
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 float z = 32.35;
glPushMatrix();
glCallList(terrain);
glCallList(scenery);
printf("*** Drawing runway at %.2f\n", z);
@ -405,9 +407,6 @@ int main( int argc, char *argv[] ) {
f = &current_aircraft.flight;
/* parse the scenery file */
parse_scenery(argv[1]);
#ifdef GLUT
/* initialize GLUT */
glutInit(&argc, argv);
@ -419,7 +418,7 @@ int main( int argc, char *argv[] ) {
glutInitWindowSize(640, 480);
/* Initialize the main window */
glutCreateWindow("Terrain Demo");
glutCreateWindow("Flight Gear");
#elif MESA_TK
/* Define initial window size */
tkInitPosition(0, 0, 640, 480);
@ -428,7 +427,7 @@ int main( int argc, char *argv[] ) {
tkInitDisplayMode( TK_RGB | TK_DEPTH | TK_DOUBLE | TK_DIRECT );
/* Initialize the main window */
if (tkInitWindow("Terrain Demo") == GL_FALSE) {
if (tkInitWindow("Flight Gear") == GL_FALSE) {
tkQuit();
}
#endif
@ -494,6 +493,14 @@ int main( int argc, char *argv[] ) {
}
/* 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();
#ifdef GLUT
@ -537,9 +544,12 @@ int main( int argc, char *argv[] ) {
/* $Log$
/* Revision 1.20 1997/06/21 17:12:53 curt
/* Capitalized subdirectory names.
/* Revision 1.21 1997/06/22 21:44:41 curt
/* 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
* A couple more runway tweaks ...
*

View file

@ -33,6 +33,23 @@
#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) */
struct mesh *(new_mesh)() {
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);
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 */
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);
} else if ( strcmp(m->option_name, "origin_lat") == 0 ) {
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$
/* Revision 1.4 1997/05/30 19:30:17 curt
/* The LaRCsim flight model is starting to look like it is working.
/* Revision 1.5 1997/06/22 21:44:41 curt
/* 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
* Added GNU copyright headers.
*

View file

@ -43,6 +43,7 @@ struct mesh {
/* a temporary values for the parser to use */
char option_name[32];
int do_data;
int cur_row, cur_col;
};
@ -50,6 +51,9 @@ struct mesh {
/* return a pointer to a new mesh structure (no data array allocated yet) */
struct mesh *(new_mesh)();
/* initialize the non-array mesh values */
void mesh_init(struct mesh *m);
/* return a pointer to a dynamically allocated array */
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 */
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
/* $Log$
/* Revision 1.2 1997/05/23 15:40:42 curt
/* Added GNU copyright headers.
/* Revision 1.3 1997/06/22 21:44:41 curt
/* 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
* Initial revision.
*

View file

@ -27,7 +27,7 @@
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
MAIN = OpenGL
@ -59,6 +59,9 @@ tar: clean
#---------------------------------------------------------------------------
# $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
# Continue directory shuffling ... everything should be compilable/runnable
# again.

View file

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