1
0
Fork 0

Working on views (side, front, back, transitions, etc.)

This commit is contained in:
curt 1997-06-02 03:01:38 +00:00
parent 607546e8f4
commit 2abbce4d79
4 changed files with 149 additions and 73 deletions

View file

@ -43,15 +43,18 @@ void aircraft_debug(int type) {
FG_RAD_2_DEG(FG_Longitude) * 3600.0,
FG_RAD_2_DEG(FG_Latitude) * 3600.0,
FG_Altitude, FG_Phi, FG_Theta, FG_Psi);
printf("Mach = %.2f Elev = %.2f, Aileron = %.2f, Rudder = %.2f Power = %.2f\n",
FG_Mach_number, FG_Elevator, FG_Aileron, FG_Rudder, FG_Throttle[0]);
printf("Kts = %.0f Elev = %.2f, Aileron = %.2f, Rudder = %.2f Power = %.2f\n",
FG_V_equiv_kts, FG_Elevator, FG_Aileron, FG_Rudder, FG_Throttle[0]);
}
/* $Log$
/* Revision 1.6 1997/05/31 19:16:26 curt
/* Elevator trim added.
/* Revision 1.7 1997/06/02 03:01:39 curt
/* Working on views (side, front, back, transitions, etc.)
/*
* Revision 1.6 1997/05/31 19:16:26 curt
* Elevator trim added.
*
* Revision 1.5 1997/05/30 19:30:14 curt
* The LaRCsim flight model is starting to look like it is working.
*

View file

@ -24,6 +24,7 @@
**************************************************************************/
#include <math.h>
#include <stdio.h>
#include <GL/glut.h>
@ -32,6 +33,7 @@
#include "../aircraft/aircraft.h"
extern double fogDensity;
extern double goal_view_offset;
/* Handle keyboard events */
void GLUTkey(unsigned char k, int x, int y) {
@ -41,54 +43,83 @@ void GLUTkey(unsigned char k, int x, int y) {
printf("Key hit = %d\n", k);
switch (k) {
case 50: /* numeric keypad 2 */
fgElevMove(-0.01);
return;
case 56: /* numeric keypad 8 */
fgElevMove(0.01);
return;
case 49: /* numeric keypad 1 */
fgElevTrimMove(-0.001);
return;
case 55: /* numeric keypad 7 */
fgElevTrimMove(0.001);
return;
case 52: /* numeric keypad 4 */
fgAileronMove(-0.01);
return;
case 54: /* numeric keypad 6 */
fgAileronMove(0.01);
return;
case 48: /* numeric keypad Ins */
fgRudderMove(-0.01);
return;
case 13: /* numeric keypad Enter */
fgRudderMove(0.01);
return;
case 53: /* numeric keypad 5 */
fgAileronSet(0.0);
fgElevSet(0.0);
fgRudderSet(0.0);
return;
case 57: /* numeric keypad 9 (Pg Up) */
fgThrottleMove(0, 0.01);
return;
case 51: /* numeric keypad 3 (Pg Dn) */
fgThrottleMove(0, -0.01);
return;
case 122:
fogDensity *= 1.10;
glFogf(GL_FOG_END, fogDensity);
printf("Fog density = %.4f\n", fogDensity);
return;
case 90:
fogDensity /= 1.10;
glFogf(GL_FOG_END, fogDensity);
printf("Fog density = %.4f\n", fogDensity);
return;
case 27: /* ESC */
exit(0);
if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
switch (k) {
case 49: /* numeric keypad 1 */
goal_view_offset = M_PI * 0.75;
return;
case 50: /* numeric keypad 2 */
goal_view_offset = M_PI;
return;
case 51: /* numeric keypad 3 */
goal_view_offset = M_PI * 1.25;
return;
case 52: /* numeric keypad 4 */
goal_view_offset = M_PI * 0.50;
return;
case 54: /* numeric keypad 6 */
goal_view_offset = M_PI * 1.50;
return;
case 55: /* numeric keypad 7 */
goal_view_offset = M_PI * 0.25;
return;
case 56: /* numeric keypad 8 */
goal_view_offset = 0.00;
return;
case 57: /* numeric keypad 9 */
goal_view_offset = M_PI * 1.75;
return;
}
} else {
switch (k) {
case 50: /* numeric keypad 2 */
fgElevMove(-0.01);
return;
case 56: /* numeric keypad 8 */
fgElevMove(0.01);
return;
case 49: /* numeric keypad 1 */
fgElevTrimMove(-0.001);
return;
case 55: /* numeric keypad 7 */
fgElevTrimMove(0.001);
return;
case 52: /* numeric keypad 4 */
fgAileronMove(-0.01);
return;
case 54: /* numeric keypad 6 */
fgAileronMove(0.01);
return;
case 48: /* numeric keypad Ins */
fgRudderMove(-0.01);
return;
case 13: /* numeric keypad Enter */
fgRudderMove(0.01);
return;
case 53: /* numeric keypad 5 */
fgAileronSet(0.0);
fgElevSet(0.0);
fgRudderSet(0.0);
return;
case 57: /* numeric keypad 9 (Pg Up) */
fgThrottleMove(0, 0.01);
return;
case 51: /* numeric keypad 3 (Pg Dn) */
fgThrottleMove(0, -0.01);
return;
case 122:
fogDensity *= 1.10;
glFogf(GL_FOG_END, fogDensity);
printf("Fog density = %.4f\n", fogDensity);
return;
case 90:
fogDensity /= 1.10;
glFogf(GL_FOG_END, fogDensity);
printf("Fog density = %.4f\n", fogDensity);
return;
case 27: /* ESC */
exit(0);
}
}
}
@ -121,9 +152,12 @@ void GLUTspecialkey(unsigned char k, int x, int y) {
/* $Log$
/* Revision 1.7 1997/05/31 19:16:25 curt
/* Elevator trim added.
/* Revision 1.8 1997/06/02 03:01:38 curt
/* Working on views (side, front, back, transitions, etc.)
/*
* Revision 1.7 1997/05/31 19:16:25 curt
* Elevator trim added.
*
* Revision 1.6 1997/05/31 04:13:52 curt
* WE CAN NOW FLY!!!
*

View file

@ -72,6 +72,8 @@ static GLint mesh;
/* Another hack */
double fogDensity = 2000.0;
double view_offset = 0.0;
double goal_view_offset = 0.0;
/* Another hack */
#define DEFAULT_MODEL_HZ 20
@ -122,8 +124,8 @@ static void fgInitVisuals() {
static void fgUpdateViewParams() {
double pos_x, pos_y, pos_z;
struct flight_params *f;
MAT3mat R, tmp;
MAT3vec vec, forward, up;
MAT3mat R, TMP;
MAT3vec vec, up, forward, fwrd_view;
f = &current_aircraft.flight;
@ -146,30 +148,61 @@ static void fgUpdateViewParams() {
/* printf("Roll matrix\n"); */
/* MAT3print(R, stdout); */
MAT3_SET_VEC(vec, 0.0, -1.0, 0.0);
MAT3rotate(tmp, vec, FG_Theta);
MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
/* MAT3mult_vec(vec, vec, R); */
MAT3rotate(TMP, vec, -FG_Theta);
/* printf("Pitch matrix\n"); */
/* MAT3print(tmp, stdout); */
MAT3mult(R, R, tmp);
/* MAT3print(TMP, stdout); */
MAT3mult(R, R, TMP);
MAT3_SET_VEC(vec, 0.0, 0.0, -1.0);
MAT3rotate(tmp, vec, M_PI + M_PI_2 + FG_Psi );
/* MAT3mult_vec(vec, vec, R); */
/* MAT3rotate(TMP, vec, M_PI + M_PI_2 + FG_Psi + view_offset); */
MAT3rotate(TMP, vec, FG_Psi - M_PI_2);
/* printf("Yaw matrix\n");
MAT3print(tmp, stdout); */
MAT3mult(R, R, tmp);
MAT3print(TMP, stdout); */
MAT3mult(R, R, TMP);
/* MAT3print(R, stdout); */
/* generate the current forward and up vectors */
/* generate the current up, forward, and fwrd-view vectors */
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
MAT3mult_vec(up, vec, R);
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
MAT3mult_vec(forward, vec, R);
printf("Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1],
forward[2]);
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
MAT3mult_vec(up, vec, R);
if ( fabs(goal_view_offset - view_offset) < 0.09 ) {
view_offset = goal_view_offset;
} else {
/* move view_offset towards goal_view_offset */
if ( goal_view_offset > view_offset ) {
if ( goal_view_offset - view_offset < M_PI ) {
view_offset += 0.05;
} else {
view_offset -= 0.05;
}
} else {
if ( view_offset - goal_view_offset < M_PI ) {
view_offset -= 0.05;
} else {
view_offset += 0.05;
}
}
if ( view_offset > PI2 ) {
view_offset -= PI2;
} else if ( view_offset < 0 ) {
view_offset += PI2;
}
}
MAT3rotate(TMP, up, view_offset);
MAT3mult_vec(fwrd_view, forward, TMP);
gluLookAt(pos_x, pos_y, pos_z,
pos_x + forward[0], pos_y + forward[1], pos_z + forward[2],
pos_x + fwrd_view[0], pos_y + fwrd_view[1], pos_z + fwrd_view[2],
up[0], up[1], up[2]);
glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
@ -375,7 +408,7 @@ int main( int argc, char *argv[] ) {
/* Initial Orientation */
FG_Phi = -2.658474E-06;
FG_Theta = 7.401790E-03;
FG_Psi = 102.0 * DEG_TO_RAD;
FG_Psi = 282.0 * DEG_TO_RAD;
/* Initial Angular B rates */
FG_P_body = 7.206685E-05;
@ -450,9 +483,12 @@ int main( int argc, char *argv[] ) {
/* $Log$
/* Revision 1.11 1997/05/31 19:16:25 curt
/* Elevator trim added.
/* Revision 1.12 1997/06/02 03:01:38 curt
/* Working on views (side, front, back, transitions, etc.)
/*
* Revision 1.11 1997/05/31 19:16:25 curt
* Elevator trim added.
*
* Revision 1.10 1997/05/31 04:13:52 curt
* WE CAN NOW FLY!!!
*

View file

@ -44,7 +44,7 @@ GLint mesh2GL(struct mesh *m) {
int i, j, istep, jstep, iend, jend;
float temp;
istep = jstep = 50; /* Detail level 1 -- 1200 ... */
istep = jstep = 30; /* Detail level 1 -- 1200 ... */
mesh = glGenLists(1);
glNewList(mesh, GL_COMPILE);
@ -104,9 +104,12 @@ GLint mesh2GL(struct mesh *m) {
/* $Log$
/* Revision 1.14 1997/05/31 19:16:26 curt
/* Elevator trim added.
/* Revision 1.15 1997/06/02 03:01:38 curt
/* Working on views (side, front, back, transitions, etc.)
/*
* Revision 1.14 1997/05/31 19:16:26 curt
* Elevator trim added.
*
* Revision 1.13 1997/05/31 04:13:53 curt
* WE CAN NOW FLY!!!
*