**************************************************************************/
-#include <math.h>
#include <stdio.h>
#ifdef WIN32
#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;
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 {
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 {
/* $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.
*
**************************************************************************/
-#include <math.h>
#include <stdio.h>
-#include <stdlib.h>
#ifdef WIN32
# include <windows.h>
#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;
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);
} 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;
}
}
}
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;
}
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");
/**********************************************************************
/* $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.
*
../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
#---------------------------------------------------------------------------
# $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.
#
../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 \
../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
#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
/* 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;
}
*/
-/*
-#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);
}
/* $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.
*