Hacked in a runway
This commit is contained in:
parent
226ef4335a
commit
e41db26287
3 changed files with 93 additions and 25 deletions
|
@ -73,10 +73,10 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
} else {
|
} else {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case 50: /* numeric keypad 2 */
|
case 50: /* numeric keypad 2 */
|
||||||
fgElevMove(-0.01);
|
fgElevMove(-0.02);
|
||||||
return;
|
return;
|
||||||
case 56: /* numeric keypad 8 */
|
case 56: /* numeric keypad 8 */
|
||||||
fgElevMove(0.01);
|
fgElevMove(0.02);
|
||||||
return;
|
return;
|
||||||
case 49: /* numeric keypad 1 */
|
case 49: /* numeric keypad 1 */
|
||||||
fgElevTrimMove(-0.001);
|
fgElevTrimMove(-0.001);
|
||||||
|
@ -85,16 +85,16 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
fgElevTrimMove(0.001);
|
fgElevTrimMove(0.001);
|
||||||
return;
|
return;
|
||||||
case 52: /* numeric keypad 4 */
|
case 52: /* numeric keypad 4 */
|
||||||
fgAileronMove(-0.01);
|
fgAileronMove(-0.02);
|
||||||
return;
|
return;
|
||||||
case 54: /* numeric keypad 6 */
|
case 54: /* numeric keypad 6 */
|
||||||
fgAileronMove(0.01);
|
fgAileronMove(0.02);
|
||||||
return;
|
return;
|
||||||
case 48: /* numeric keypad Ins */
|
case 48: /* numeric keypad Ins */
|
||||||
fgRudderMove(-0.01);
|
fgRudderMove(-0.02);
|
||||||
return;
|
return;
|
||||||
case 13: /* numeric keypad Enter */
|
case 13: /* numeric keypad Enter */
|
||||||
fgRudderMove(0.01);
|
fgRudderMove(0.02);
|
||||||
return;
|
return;
|
||||||
case 53: /* numeric keypad 5 */
|
case 53: /* numeric keypad 5 */
|
||||||
fgAileronSet(0.0);
|
fgAileronSet(0.0);
|
||||||
|
@ -135,16 +135,16 @@ void GLUTspecialkey(int k, int x, int y) {
|
||||||
|
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case GLUT_KEY_UP:
|
case GLUT_KEY_UP:
|
||||||
fgElevMove(0.01);
|
fgElevMove(0.02);
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_DOWN:
|
case GLUT_KEY_DOWN:
|
||||||
fgElevMove(-0.01);
|
fgElevMove(-0.02);
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_LEFT:
|
case GLUT_KEY_LEFT:
|
||||||
fgAileronMove(-0.01);
|
fgAileronMove(-0.02);
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_RIGHT:
|
case GLUT_KEY_RIGHT:
|
||||||
fgAileronMove(0.01);
|
fgAileronMove(0.02);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +152,12 @@ void GLUTspecialkey(int k, int x, int y) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.9 1997/06/02 03:40:06 curt
|
/* Revision 1.10 1997/06/18 02:21:23 curt
|
||||||
/* A tiny bit more view tweaking.
|
/* Hacked in a runway
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.9 1997/06/02 03:40:06 curt
|
||||||
|
* A tiny bit more view tweaking.
|
||||||
|
*
|
||||||
* Revision 1.8 1997/06/02 03:01:38 curt
|
* Revision 1.8 1997/06/02 03:01:38 curt
|
||||||
* Working on views (side, front, back, transitions, etc.)
|
* Working on views (side, front, back, transitions, etc.)
|
||||||
*
|
*
|
||||||
|
|
|
@ -66,7 +66,7 @@ extern struct mesh *mesh_ptr;
|
||||||
GLint fgSceneryCompile();
|
GLint fgSceneryCompile();
|
||||||
static void fgSceneryDraw();
|
static void fgSceneryDraw();
|
||||||
/* pointer to terrain mesh structure */
|
/* pointer to terrain mesh structure */
|
||||||
static GLint mesh;
|
static GLint terrain, runway;
|
||||||
|
|
||||||
/* Another hack */
|
/* Another hack */
|
||||||
double fogDensity = 2000.0;
|
double fogDensity = 2000.0;
|
||||||
|
@ -90,7 +90,6 @@ int use_signals = 0;
|
||||||
|
|
||||||
static void fgInitVisuals() {
|
static void fgInitVisuals() {
|
||||||
/* if the 4th field is 0.0, this specifies a direction ... */
|
/* if the 4th field is 0.0, this specifies a direction ... */
|
||||||
static GLfloat color[4] = { 0.3, 0.7, 0.2, 1.0 };
|
|
||||||
static GLfloat fogColor[4] = {0.65, 0.65, 0.85, 1.0};
|
static GLfloat fogColor[4] = {0.65, 0.65, 0.85, 1.0};
|
||||||
|
|
||||||
glEnable( GL_DEPTH_TEST );
|
glEnable( GL_DEPTH_TEST );
|
||||||
|
@ -105,7 +104,6 @@ static void fgInitVisuals() {
|
||||||
glEnable( GL_LIGHTING );
|
glEnable( GL_LIGHTING );
|
||||||
glEnable( GL_LIGHT0 );
|
glEnable( GL_LIGHT0 );
|
||||||
|
|
||||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color );
|
|
||||||
glShadeModel( GL_FLAT ); /* glShadeModel( GL_SMOOTH ); */
|
glShadeModel( GL_FLAT ); /* glShadeModel( GL_SMOOTH ); */
|
||||||
|
|
||||||
glEnable( GL_FOG );
|
glEnable( GL_FOG );
|
||||||
|
@ -135,7 +133,7 @@ static void fgUpdateViewParams() {
|
||||||
/* Tell GL we are about to modify the projection parameters */
|
/* Tell GL we are about to modify the projection parameters */
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(45.0, 1.0/win_ratio, 1.0, 6000.0);
|
gluPerspective(45.0, 1.0/win_ratio, 0.01, 6000.0);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -145,6 +143,8 @@ static void fgUpdateViewParams() {
|
||||||
pos_y = (FG_Latitude * RAD_TO_DEG) * 3600.0;
|
pos_y = (FG_Latitude * RAD_TO_DEG) * 3600.0;
|
||||||
pos_z = FG_Altitude * 0.01; /* (Convert feet to aproximate arcsecs) */
|
pos_z = FG_Altitude * 0.01; /* (Convert feet to aproximate arcsecs) */
|
||||||
|
|
||||||
|
printf("*** pos_z = %.2f\n", pos_z);
|
||||||
|
|
||||||
/* build current rotation matrix */
|
/* build current rotation matrix */
|
||||||
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
||||||
MAT3rotate(R, vec, FG_Phi);
|
MAT3rotate(R, vec, FG_Phi);
|
||||||
|
@ -272,23 +272,78 @@ void fgInitTimeDepCalcs() {
|
||||||
|
|
||||||
static void fgSceneryInit() {
|
static void fgSceneryInit() {
|
||||||
/* make terrain mesh */
|
/* make terrain mesh */
|
||||||
mesh = fgSceneryCompile();
|
terrain = fgSceneryCompile();
|
||||||
|
runway = fgRunwayHack(0.69, 53.07);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* create the terrain mesh */
|
/* create the terrain mesh */
|
||||||
GLint fgSceneryCompile() {
|
GLint fgSceneryCompile() {
|
||||||
GLint mesh;
|
GLint terrain;
|
||||||
|
|
||||||
mesh = mesh2GL(mesh_ptr);
|
terrain = mesh2GL(mesh_ptr);
|
||||||
|
|
||||||
return(mesh);
|
return(terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* hack in a runway */
|
||||||
|
GLint fgRunwayHack(double width, double length) {
|
||||||
|
static GLfloat concrete[4] = { 0.5, 0.5, 0.5, 1.0 };
|
||||||
|
static GLfloat line[4] = { 0.9, 0.9, 0.9, 1.0 };
|
||||||
|
int i;
|
||||||
|
int num_lines = 8;
|
||||||
|
float line_len, line_width_2, cur_pos;
|
||||||
|
|
||||||
|
runway = glGenLists(1);
|
||||||
|
glNewList(runway, GL_COMPILE);
|
||||||
|
|
||||||
|
/* draw concrete */
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, concrete );
|
||||||
|
glNormal3f(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
glVertex3d( 0.0, -width/2.0, 0.0);
|
||||||
|
glVertex3d( 0.0, width/2.0, 0.0);
|
||||||
|
glVertex3d(length, width/2.0, 0.0);
|
||||||
|
glVertex3d(length, -width/2.0, 0.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* draw center line */
|
||||||
|
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, line );
|
||||||
|
line_len = length / ( 2 * num_lines + 1);
|
||||||
|
printf("line_len = %.3f\n", line_len);
|
||||||
|
line_width_2 = 0.02;
|
||||||
|
cur_pos = line_len;
|
||||||
|
for ( i = 0; i < num_lines; i++ ) {
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glVertex3d( cur_pos, -line_width_2, 0.005);
|
||||||
|
glVertex3d( cur_pos, line_width_2, 0.005);
|
||||||
|
cur_pos += line_len;
|
||||||
|
glVertex3d( cur_pos, line_width_2, 0.005);
|
||||||
|
glVertex3d( cur_pos, -line_width_2, 0.005);
|
||||||
|
cur_pos += line_len;
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
return(runway);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* draw the terrain mesh */
|
/* draw the terrain mesh */
|
||||||
static void fgSceneryDraw() {
|
static void fgSceneryDraw() {
|
||||||
glCallList(mesh);
|
static float z = 32.35;
|
||||||
|
|
||||||
|
glCallList(terrain);
|
||||||
|
|
||||||
|
/* z -= 0.01; */
|
||||||
|
printf("*** Drawing runway at %.2f\n", z);
|
||||||
|
|
||||||
|
glTranslatef( -398391.28, 120070.41, z);
|
||||||
|
glRotatef(170.0, 0.0, 0.0, 1.0);
|
||||||
|
glCallList(runway);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,9 +534,12 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.17 1997/06/17 16:51:58 curt
|
/* Revision 1.18 1997/06/18 02:21:24 curt
|
||||||
/* Timer interval stuff now uses gettimeofday() instead of ftime()
|
/* Hacked in a runway
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.17 1997/06/17 16:51:58 curt
|
||||||
|
* Timer interval stuff now uses gettimeofday() instead of ftime()
|
||||||
|
*
|
||||||
* Revision 1.16 1997/06/17 04:19:16 curt
|
* Revision 1.16 1997/06/17 04:19:16 curt
|
||||||
* More timer related tweaks with respect to view direction changes.
|
* More timer related tweaks with respect to view direction changes.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,8 +38,10 @@
|
||||||
/* walk through mesh and make ogl calls */
|
/* walk through mesh and make ogl calls */
|
||||||
GLint mesh2GL(struct mesh *m) {
|
GLint mesh2GL(struct mesh *m) {
|
||||||
GLint mesh;
|
GLint mesh;
|
||||||
|
static GLfloat color[4] = { 0.3, 0.7, 0.2, 1.0 };
|
||||||
|
|
||||||
float x1, y1, x2, y2, z11, z12, z21, z22;
|
float x1, y1, x2, y2, z11, z12, z21, z22;
|
||||||
|
|
||||||
MAT3vec v1, v2, normal;
|
MAT3vec v1, v2, normal;
|
||||||
int i, j, istep, jstep, iend, jend;
|
int i, j, istep, jstep, iend, jend;
|
||||||
float temp;
|
float temp;
|
||||||
|
@ -49,6 +51,8 @@ GLint mesh2GL(struct mesh *m) {
|
||||||
mesh = glGenLists(1);
|
mesh = glGenLists(1);
|
||||||
glNewList(mesh, GL_COMPILE);
|
glNewList(mesh, GL_COMPILE);
|
||||||
|
|
||||||
|
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color );
|
||||||
|
|
||||||
iend = m->cols - 1;
|
iend = m->cols - 1;
|
||||||
jend = m->rows - 1;
|
jend = m->rows - 1;
|
||||||
|
|
||||||
|
@ -104,9 +108,12 @@ GLint mesh2GL(struct mesh *m) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.18 1997/06/17 04:19:17 curt
|
/* Revision 1.19 1997/06/18 02:21:24 curt
|
||||||
/* More timer related tweaks with respect to view direction changes.
|
/* Hacked in a runway
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.18 1997/06/17 04:19:17 curt
|
||||||
|
* More timer related tweaks with respect to view direction changes.
|
||||||
|
*
|
||||||
* Revision 1.17 1997/06/16 19:32:52 curt
|
* Revision 1.17 1997/06/16 19:32:52 curt
|
||||||
* Starting to add general timer support.
|
* Starting to add general timer support.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue