Moved PI definitions to ../constants.h
Moved random() stuff to ../Utils/ and renamed fg_random()
This commit is contained in:
parent
6ef6f4d986
commit
982a9821d2
5 changed files with 60 additions and 98 deletions
|
@ -24,7 +24,6 @@
|
|||
**************************************************************************/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -35,10 +34,7 @@
|
|||
|
||||
#include "GLUTkey.h"
|
||||
#include "../Aircraft/aircraft.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
#include "../constants.h"
|
||||
|
||||
extern double fogDensity;
|
||||
extern double goal_view_offset;
|
||||
|
@ -51,32 +47,32 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
|
||||
printf("Key hit = %d", k);
|
||||
|
||||
if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
|
||||
if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
|
||||
printf(" SHIFTED\n");
|
||||
switch (k) {
|
||||
case 49: /* numeric keypad 1 */
|
||||
goal_view_offset = M_PI * 0.75;
|
||||
goal_view_offset = FG_PI * 0.75;
|
||||
return;
|
||||
case 50: /* numeric keypad 2 */
|
||||
goal_view_offset = M_PI;
|
||||
goal_view_offset = FG_PI;
|
||||
return;
|
||||
case 51: /* numeric keypad 3 */
|
||||
goal_view_offset = M_PI * 1.25;
|
||||
goal_view_offset = FG_PI * 1.25;
|
||||
return;
|
||||
case 52: /* numeric keypad 4 */
|
||||
goal_view_offset = M_PI * 0.50;
|
||||
goal_view_offset = FG_PI * 0.50;
|
||||
return;
|
||||
case 54: /* numeric keypad 6 */
|
||||
goal_view_offset = M_PI * 1.50;
|
||||
goal_view_offset = FG_PI * 1.50;
|
||||
return;
|
||||
case 55: /* numeric keypad 7 */
|
||||
goal_view_offset = M_PI * 0.25;
|
||||
goal_view_offset = FG_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;
|
||||
goal_view_offset = FG_PI * 1.75;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -147,28 +143,28 @@ void GLUTspecialkey(int k, int x, int y) {
|
|||
printf(" SHIFTED\n");
|
||||
switch (k) {
|
||||
case GLUT_KEY_END: /* numeric keypad 1 */
|
||||
goal_view_offset = M_PI * 0.75;
|
||||
goal_view_offset = FG_PI * 0.75;
|
||||
return;
|
||||
case GLUT_KEY_DOWN: /* numeric keypad 2 */
|
||||
goal_view_offset = M_PI;
|
||||
goal_view_offset = FG_PI;
|
||||
return;
|
||||
case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 */
|
||||
goal_view_offset = M_PI * 1.25;
|
||||
goal_view_offset = FG_PI * 1.25;
|
||||
return;
|
||||
case GLUT_KEY_LEFT: /* numeric keypad 4 */
|
||||
goal_view_offset = M_PI * 0.50;
|
||||
goal_view_offset = FG_PI * 0.50;
|
||||
return;
|
||||
case GLUT_KEY_RIGHT: /* numeric keypad 6 */
|
||||
goal_view_offset = M_PI * 1.50;
|
||||
goal_view_offset = FG_PI * 1.50;
|
||||
return;
|
||||
case GLUT_KEY_HOME: /* numeric keypad 7 */
|
||||
goal_view_offset = M_PI * 0.25;
|
||||
goal_view_offset = FG_PI * 0.25;
|
||||
return;
|
||||
case GLUT_KEY_UP: /* numeric keypad 8 */
|
||||
goal_view_offset = 0.00;
|
||||
return;
|
||||
case GLUT_KEY_PAGE_UP: /* numeric keypad 9 */
|
||||
goal_view_offset = M_PI * 1.75;
|
||||
goal_view_offset = FG_PI * 1.75;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -215,9 +211,13 @@ void GLUTspecialkey(int k, int x, int y) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.16 1997/07/18 23:41:24 curt
|
||||
/* Tweaks for building with Cygnus Win32 compiler.
|
||||
/* Revision 1.17 1997/07/19 22:34:02 curt
|
||||
/* Moved PI definitions to ../constants.h
|
||||
/* Moved random() stuff to ../Utils/ and renamed fg_random()
|
||||
/*
|
||||
* Revision 1.16 1997/07/18 23:41:24 curt
|
||||
* Tweaks for building with Cygnus Win32 compiler.
|
||||
*
|
||||
* Revision 1.15 1997/07/16 20:04:47 curt
|
||||
* Minor tweaks to aid Win32 port.
|
||||
*
|
||||
|
|
|
@ -24,9 +24,7 @@
|
|||
**************************************************************************/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
|
@ -49,21 +47,9 @@
|
|||
#include "../Math/mat3.h"
|
||||
#include "../Math/polar.h"
|
||||
#include "../Timer/fg_timer.h"
|
||||
#include "../Utils/fg_random.h"
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef PI2
|
||||
#define PI2 (M_PI + M_PI)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
/* This is a record containing all the info for the aircraft currently
|
||||
being operated */
|
||||
struct aircraft_params current_aircraft;
|
||||
|
@ -174,8 +160,8 @@ static void fgUpdateViewParams() {
|
|||
|
||||
MAT3_SET_VEC(vec, 0.0, 0.0, -1.0);
|
||||
/* 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);
|
||||
/* MAT3rotate(TMP, vec, FG_PI + FG_PI_2 + FG_Psi + view_offset); */
|
||||
MAT3rotate(TMP, vec, FG_Psi - FG_PI_2);
|
||||
/* printf("Yaw matrix\n");
|
||||
MAT3print(TMP, stdout); */
|
||||
MAT3mult(R, R, TMP);
|
||||
|
@ -255,22 +241,22 @@ void fgUpdateTimeDepCalcs(int multi_loop) {
|
|||
} else {
|
||||
/* move view_offset towards goal_view_offset */
|
||||
if ( goal_view_offset > view_offset ) {
|
||||
if ( goal_view_offset - view_offset < M_PI ) {
|
||||
if ( goal_view_offset - view_offset < FG_PI ) {
|
||||
view_offset += 0.01;
|
||||
} else {
|
||||
view_offset -= 0.01;
|
||||
}
|
||||
} else {
|
||||
if ( view_offset - goal_view_offset < M_PI ) {
|
||||
if ( view_offset - goal_view_offset < FG_PI ) {
|
||||
view_offset -= 0.01;
|
||||
} else {
|
||||
view_offset += 0.01;
|
||||
}
|
||||
}
|
||||
if ( view_offset > PI2 ) {
|
||||
view_offset -= PI2;
|
||||
if ( view_offset > FG_2PI ) {
|
||||
view_offset -= FG_2PI;
|
||||
} else if ( view_offset < 0 ) {
|
||||
view_offset += PI2;
|
||||
view_offset += FG_2PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -417,24 +403,9 @@ static void fgMainLoop( void ) {
|
|||
FG_Altitude * FEET_TO_METER);
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_RAND
|
||||
# ifdef sgi
|
||||
# undef RAND_MAX
|
||||
# define RAND_MAX 2147483647
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_RAND
|
||||
FG_U_gust = rand() * 3.0 / RAND_MAX - 1.0;
|
||||
FG_V_gust = rand() * 3.0 / RAND_MAX - 1.0;
|
||||
FG_W_gust = rand() * 3.0 / RAND_MAX - 1.0;
|
||||
#else
|
||||
FG_U_gust = random() * 3.0 / RAND_MAX - 1.0;
|
||||
FG_V_gust = random() * 3.0 / RAND_MAX - 1.0;
|
||||
FG_W_gust = random() * 3.0 / RAND_MAX - 1.0;
|
||||
#endif
|
||||
|
||||
FG_U_gust = fg_random() * 1.0 - 0.5;
|
||||
FG_V_gust = fg_random() * 1.0 - 0.5;
|
||||
FG_W_gust = fg_random() * 1.0 - 0.5;
|
||||
}
|
||||
|
||||
|
||||
|
@ -468,7 +439,10 @@ int main( int argc, char *argv[] ) {
|
|||
|
||||
f = ¤t_aircraft.flight;
|
||||
|
||||
/* printf("Flight Gear: prototype code to test OpenGL, LaRCsim, and VRML\n\n");*/
|
||||
/* might as well do this first thing ... seed the random number generater */
|
||||
fg_srandom();
|
||||
|
||||
printf("Flight Gear: prototype code to test OpenGL, LaRCsim, and VRML\n\n");
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -645,9 +619,13 @@ int printf (const char *format, ...) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.36 1997/07/18 23:41:25 curt
|
||||
/* Tweaks for building with Cygnus Win32 compiler.
|
||||
/* Revision 1.37 1997/07/19 22:34:02 curt
|
||||
/* Moved PI definitions to ../constants.h
|
||||
/* Moved random() stuff to ../Utils/ and renamed fg_random()
|
||||
/*
|
||||
* Revision 1.36 1997/07/18 23:41:25 curt
|
||||
* Tweaks for building with Cygnus Win32 compiler.
|
||||
*
|
||||
* Revision 1.35 1997/07/18 14:28:34 curt
|
||||
* Hacked in some support for wind/turbulence.
|
||||
*
|
||||
|
|
|
@ -32,7 +32,7 @@ AFILES = ../Aircraft/libAircraft.a ../Controls/libControls.a \
|
|||
../Flight/libFlight.a ../Flight/LaRCsim/libLaRCsim.a \
|
||||
../Flight/Slew/libSlew.a ../Math/libMath.a \
|
||||
../Scenery/libScenery.a \
|
||||
../Timer/libTimer.a
|
||||
../Timer/libTimer.a ../Utils/libUtils.a
|
||||
|
||||
|
||||
include ../make.inc
|
||||
|
@ -76,6 +76,10 @@ mesh2GL.o:
|
|||
|
||||
#---------------------------------------------------------------------------
|
||||
# $Log$
|
||||
# Revision 1.23 1997/07/19 22:34:03 curt
|
||||
# Moved PI definitions to ../constants.h
|
||||
# Moved random() stuff to ../Utils/ and renamed fg_random()
|
||||
#
|
||||
# Revision 1.22 1997/07/18 23:41:25 curt
|
||||
# Tweaks for building with Cygnus Win32 compiler.
|
||||
#
|
||||
|
|
|
@ -10,7 +10,7 @@ GLUTkey.o: GLUTkey.c GLUTkey.h ../Aircraft/aircraft.h \
|
|||
../Aircraft/../Flight/LaRCsim/ls_interface.h \
|
||||
../Aircraft/../Flight/LaRCsim/../flight.h \
|
||||
../Aircraft/../Controls/controls.h \
|
||||
../Aircraft/../Controls/../limits.h
|
||||
../Aircraft/../Controls/../limits.h ../constants.h
|
||||
GLmain.o: GLmain.c ../constants.h ../Aircraft/aircraft.h \
|
||||
../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
|
||||
../Aircraft/../Flight/LaRCsim/ls_interface.h \
|
||||
|
@ -18,7 +18,7 @@ GLmain.o: GLmain.c ../constants.h ../Aircraft/aircraft.h \
|
|||
../Aircraft/../Controls/controls.h \
|
||||
../Aircraft/../Controls/../limits.h ../Scenery/mesh.h \
|
||||
../Scenery/scenery.h ../Math/mat3.h ../Math/polar.h \
|
||||
../Math/../types.h ../Timer/fg_timer.h
|
||||
../Math/../types.h ../Timer/fg_timer.h ../Utils/fg_random.h
|
||||
mesh2GL.o: mesh2GL.c ../constants.h ../Scenery/mesh.h \
|
||||
../Scenery/scenery.h ../Math/mat3.h ../Math/polar.h \
|
||||
../Math/../types.h
|
||||
../Math/../types.h ../Utils/fg_random.h
|
||||
|
|
|
@ -30,22 +30,12 @@
|
|||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include <stdlib.h> /* for random(), srandom() */
|
||||
#include <time.h> /* for time() to seed srandom() */
|
||||
|
||||
#include "../constants.h"
|
||||
#include "../Scenery/mesh.h"
|
||||
#include "../Scenery/scenery.h"
|
||||
#include "../Math/mat3.h"
|
||||
#include "../Math/polar.h"
|
||||
|
||||
|
||||
#ifndef USE_RAND
|
||||
# ifdef sgi
|
||||
# undef RAND_MAX
|
||||
# define RAND_MAX 2147483647
|
||||
# endif
|
||||
#endif
|
||||
#include "../Utils/fg_random.h"
|
||||
|
||||
|
||||
/* The following routine is a real hack used for testing puposes only
|
||||
|
@ -95,7 +85,6 @@ GLint mesh2GL(struct mesh *m) {
|
|||
/* static GLfloat color[4] = { 0.5, 0.4, 0.25, 1.0 }; */ /* dark desert */
|
||||
static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 };
|
||||
double randx, randy;
|
||||
int t;
|
||||
|
||||
float x1, y1, x2, y2, z11, z12, z21, z22;
|
||||
struct fgCartesianPoint p11, p12, p21, p22;
|
||||
|
@ -196,22 +185,9 @@ GLint mesh2GL(struct mesh *m) {
|
|||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
#ifdef USE_RAND
|
||||
srand(time(&t));
|
||||
#else
|
||||
srandom(time(&t));
|
||||
#endif
|
||||
*/
|
||||
|
||||
for ( i = 0; i < 200; i++ ) {
|
||||
#ifdef USE_RAND
|
||||
randx = rand() * 3600.0 / RAND_MAX;
|
||||
randy = rand() * 3600.0 / RAND_MAX;
|
||||
#else
|
||||
randx = random() * 3600.0 / RAND_MAX;
|
||||
randy = random() * 3600.0 / RAND_MAX;
|
||||
#endif
|
||||
randx = fg_random() * 3600.0;
|
||||
randy = fg_random() * 3600.0;
|
||||
|
||||
mesh_make_test_object(m->originx + randx, m->originy + randy);
|
||||
}
|
||||
|
@ -224,9 +200,13 @@ GLint mesh2GL(struct mesh *m) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.36 1997/07/18 23:41:25 curt
|
||||
/* Tweaks for building with Cygnus Win32 compiler.
|
||||
/* Revision 1.37 1997/07/19 22:34:03 curt
|
||||
/* Moved PI definitions to ../constants.h
|
||||
/* Moved random() stuff to ../Utils/ and renamed fg_random()
|
||||
/*
|
||||
* Revision 1.36 1997/07/18 23:41:25 curt
|
||||
* Tweaks for building with Cygnus Win32 compiler.
|
||||
*
|
||||
* Revision 1.35 1997/07/18 14:28:35 curt
|
||||
* Hacked in some support for wind/turbulence.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue