C++ - ified views.[ch]xx
Shuffled some additional view parameters into the fgVIEW class. Changed tile-radius to tile-diameter because it is a much better name. Added a WORLD_TO_EYE transformation to views.cxx. This allows us to transform world space to eye space for view frustum culling.
This commit is contained in:
parent
fb69df5880
commit
65cc9a9e66
8 changed files with 415 additions and 204 deletions
|
@ -72,10 +72,6 @@
|
||||||
// This is a record containing global housekeeping information
|
// This is a record containing global housekeeping information
|
||||||
fgGENERAL general;
|
fgGENERAL general;
|
||||||
|
|
||||||
// view parameters
|
|
||||||
static GLfloat win_ratio = 1.0;
|
|
||||||
static GLint winWidth, winHeight;
|
|
||||||
|
|
||||||
// Another hack
|
// Another hack
|
||||||
int use_signals = 0;
|
int use_signals = 0;
|
||||||
|
|
||||||
|
@ -233,21 +229,22 @@ static void fgUpdateViewParams( void ) {
|
||||||
o = ¤t_options;
|
o = ¤t_options;
|
||||||
v = ¤t_view;
|
v = ¤t_view;
|
||||||
|
|
||||||
fgViewUpdate(f, v, l);
|
v->Update(f);
|
||||||
|
v->UpdateWorldToEye(f);
|
||||||
|
|
||||||
if (displayInstruments) {
|
if (displayInstruments) {
|
||||||
xglViewport( 0, (GLint)(winHeight / 2 ) ,
|
xglViewport( 0, (GLint)((v->winHeight) / 2 ) ,
|
||||||
(GLint)winWidth, (GLint)winHeight / 2 );
|
(GLint)(v->winWidth), (GLint)(v->winHeight) / 2 );
|
||||||
// Tell GL we are about to modify the projection parameters
|
// Tell GL we are about to modify the projection parameters
|
||||||
xglMatrixMode(GL_PROJECTION);
|
xglMatrixMode(GL_PROJECTION);
|
||||||
xglLoadIdentity();
|
xglLoadIdentity();
|
||||||
gluPerspective(o->fov, 2.0/win_ratio, 1.0, 100000.0);
|
gluPerspective(o->fov, v->win_ratio / 2.0, 1.0, 100000.0);
|
||||||
} else {
|
} else {
|
||||||
xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight);
|
xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
|
||||||
// Tell GL we are about to modify the projection parameters
|
// Tell GL we are about to modify the projection parameters
|
||||||
xglMatrixMode(GL_PROJECTION);
|
xglMatrixMode(GL_PROJECTION);
|
||||||
xglLoadIdentity();
|
xglLoadIdentity();
|
||||||
gluPerspective(o->fov, 1.0/win_ratio, 10.0, 100000.0);
|
gluPerspective(o->fov, v->win_ratio, 10.0, 100000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
xglMatrixMode(GL_MODELVIEW);
|
xglMatrixMode(GL_MODELVIEW);
|
||||||
|
@ -288,7 +285,11 @@ static void fgUpdateViewParams( void ) {
|
||||||
|
|
||||||
// Draw a basic instrument panel
|
// Draw a basic instrument panel
|
||||||
static void fgUpdateInstrViewParams( void ) {
|
static void fgUpdateInstrViewParams( void ) {
|
||||||
xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2);
|
fgVIEW *v;
|
||||||
|
|
||||||
|
v = ¤t_view;
|
||||||
|
|
||||||
|
xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) / 2);
|
||||||
|
|
||||||
xglMatrixMode(GL_PROJECTION);
|
xglMatrixMode(GL_PROJECTION);
|
||||||
xglPushMatrix();
|
xglPushMatrix();
|
||||||
|
@ -618,14 +619,18 @@ static void fgMainLoop( void ) {
|
||||||
|
|
||||||
// Handle new window size or exposure
|
// Handle new window size or exposure
|
||||||
static void fgReshape( int width, int height ) {
|
static void fgReshape( int width, int height ) {
|
||||||
|
fgVIEW *v;
|
||||||
|
|
||||||
|
v = ¤t_view;
|
||||||
|
|
||||||
// Do this so we can call fgReshape(0,0) ourselves without having
|
// Do this so we can call fgReshape(0,0) ourselves without having
|
||||||
// to know what the values of width & height are.
|
// to know what the values of width & height are.
|
||||||
if ( (height > 0) && (width > 0) ) {
|
if ( (height > 0) && (width > 0) ) {
|
||||||
win_ratio = (GLfloat) height / (GLfloat) width;
|
v->win_ratio = (GLfloat) width / (GLfloat) height;
|
||||||
}
|
}
|
||||||
|
|
||||||
winWidth = width;
|
v->winWidth = width;
|
||||||
winHeight = height;
|
v->winHeight = height;
|
||||||
|
|
||||||
// Inform gl of our view window size (now handled elsewhere)
|
// Inform gl of our view window size (now handled elsewhere)
|
||||||
// xglViewport(0, 0, (GLint)width, (GLint)height);
|
// xglViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
@ -768,6 +773,14 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.15 1998/05/16 13:08:34 curt
|
||||||
|
// C++ - ified views.[ch]xx
|
||||||
|
// Shuffled some additional view parameters into the fgVIEW class.
|
||||||
|
// Changed tile-radius to tile-diameter because it is a much better
|
||||||
|
// name.
|
||||||
|
// Added a WORLD_TO_EYE transformation to views.cxx. This allows us
|
||||||
|
// to transform world space to eye space for view frustum culling.
|
||||||
|
//
|
||||||
// Revision 1.14 1998/05/13 18:29:57 curt
|
// Revision 1.14 1998/05/13 18:29:57 curt
|
||||||
// Added a keyboard binding to dynamically adjust field of view.
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
// Added a command line option to specify fov.
|
// Added a command line option to specify fov.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
EXTRA_DIST = runfg.in runfg.bat.in
|
EXTRA_DIST = runfg.in runfg.bat.in
|
||||||
|
|
||||||
bin_PROGRAMS = fg
|
bin_PROGRAMS = fg ttest
|
||||||
|
|
||||||
bin_SCRIPTS = runfg runfg.bat
|
bin_SCRIPTS = runfg runfg.bat
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ fg_LDADD = \
|
||||||
$(top_builddir)/Lib/Debug/libDebug.la \
|
$(top_builddir)/Lib/Debug/libDebug.la \
|
||||||
$(top_builddir)/Lib/zlib/libz.la
|
$(top_builddir)/Lib/zlib/libz.la
|
||||||
|
|
||||||
|
ttest_SOURCES = ttest.cxx
|
||||||
|
|
||||||
|
ttest_LDADD = $(top_builddir)/Lib/Math/libMath.la \
|
||||||
|
|
||||||
INCLUDES += \
|
INCLUDES += \
|
||||||
-DGLUT \
|
-DGLUT \
|
||||||
-I$(top_builddir) \
|
-I$(top_builddir) \
|
||||||
|
|
|
@ -73,7 +73,7 @@ VERSION = @VERSION@
|
||||||
|
|
||||||
EXTRA_DIST = runfg.in runfg.bat.in
|
EXTRA_DIST = runfg.in runfg.bat.in
|
||||||
|
|
||||||
bin_PROGRAMS = fg
|
bin_PROGRAMS = fg ttest
|
||||||
|
|
||||||
bin_SCRIPTS = runfg runfg.bat
|
bin_SCRIPTS = runfg runfg.bat
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ fg_LDADD = \
|
||||||
$(top_builddir)/Lib/Bucket/libBucket.la \
|
$(top_builddir)/Lib/Bucket/libBucket.la \
|
||||||
$(top_builddir)/Lib/Debug/libDebug.la \
|
$(top_builddir)/Lib/Debug/libDebug.la \
|
||||||
$(top_builddir)/Lib/zlib/libz.la
|
$(top_builddir)/Lib/zlib/libz.la
|
||||||
|
|
||||||
|
ttest_SOURCES = ttest.cxx
|
||||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||||
CONFIG_HEADER = ../../Include/config.h
|
CONFIG_HEADER = ../../Include/config.h
|
||||||
CONFIG_CLEAN_FILES = runfg runfg.bat
|
CONFIG_CLEAN_FILES = runfg runfg.bat
|
||||||
|
@ -135,6 +137,10 @@ $(top_builddir)/Lib/Math/libMath.la \
|
||||||
$(top_builddir)/Lib/Bucket/libBucket.la \
|
$(top_builddir)/Lib/Bucket/libBucket.la \
|
||||||
$(top_builddir)/Lib/Debug/libDebug.la $(top_builddir)/Lib/zlib/libz.la
|
$(top_builddir)/Lib/Debug/libDebug.la $(top_builddir)/Lib/zlib/libz.la
|
||||||
fg_LDFLAGS =
|
fg_LDFLAGS =
|
||||||
|
ttest_OBJECTS = ttest.o
|
||||||
|
ttest_LDADD = $(LDADD)
|
||||||
|
ttest_DEPENDENCIES =
|
||||||
|
ttest_LDFLAGS =
|
||||||
SCRIPTS = $(bin_SCRIPTS)
|
SCRIPTS = $(bin_SCRIPTS)
|
||||||
|
|
||||||
CXXFLAGS = @CXXFLAGS@
|
CXXFLAGS = @CXXFLAGS@
|
||||||
|
@ -149,10 +155,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
TAR = tar
|
TAR = tar
|
||||||
GZIP = --best
|
GZIP = --best
|
||||||
DEP_FILES = .deps/GLUTkey.P .deps/GLUTmain.P .deps/airports.P \
|
DEP_FILES = .deps/GLUTkey.P .deps/GLUTmain.P .deps/airports.P \
|
||||||
.deps/fg_init.P .deps/options.P .deps/views.P
|
.deps/fg_init.P .deps/options.P .deps/ttest.P .deps/views.P
|
||||||
CXXMKDEP = $(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)
|
CXXMKDEP = $(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)
|
||||||
SOURCES = $(fg_SOURCES)
|
SOURCES = $(fg_SOURCES) $(ttest_SOURCES)
|
||||||
OBJECTS = $(fg_OBJECTS)
|
OBJECTS = $(fg_OBJECTS) $(ttest_OBJECTS)
|
||||||
|
|
||||||
all: Makefile $(PROGRAMS) $(SCRIPTS)
|
all: Makefile $(PROGRAMS) $(SCRIPTS)
|
||||||
|
|
||||||
|
@ -231,6 +237,10 @@ fg: $(fg_OBJECTS) $(fg_DEPENDENCIES)
|
||||||
@rm -f fg
|
@rm -f fg
|
||||||
$(CXXLINK) $(fg_LDFLAGS) $(fg_OBJECTS) $(fg_LDADD) $(LIBS)
|
$(CXXLINK) $(fg_LDFLAGS) $(fg_OBJECTS) $(fg_LDADD) $(LIBS)
|
||||||
|
|
||||||
|
ttest: $(ttest_OBJECTS) $(ttest_DEPENDENCIES)
|
||||||
|
@rm -f ttest
|
||||||
|
$(CXXLINK) $(ttest_LDFLAGS) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS)
|
||||||
|
|
||||||
install-binSCRIPTS: $(bin_SCRIPTS)
|
install-binSCRIPTS: $(bin_SCRIPTS)
|
||||||
@$(NORMAL_INSTALL)
|
@$(NORMAL_INSTALL)
|
||||||
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||||
|
|
|
@ -133,8 +133,8 @@ int fgInitPosition( void ) {
|
||||||
// Test Position
|
// Test Position
|
||||||
// FG_Longitude = ( 8.5 ) * DEG_TO_RAD;
|
// FG_Longitude = ( 8.5 ) * DEG_TO_RAD;
|
||||||
// FG_Latitude = ( 47.5 ) * DEG_TO_RAD;
|
// FG_Latitude = ( 47.5 ) * DEG_TO_RAD;
|
||||||
// FG_Runway_altitude = ( 6000 );
|
FG_Runway_altitude = ( 6000 );
|
||||||
// FG_Altitude = FG_Runway_altitude + 3.758099;
|
FG_Altitude = FG_Runway_altitude + 3.758099;
|
||||||
|
|
||||||
if ( strlen(o->airport_id) ) {
|
if ( strlen(o->airport_id) ) {
|
||||||
fgAIRPORTS airports;
|
fgAIRPORTS airports;
|
||||||
|
@ -271,9 +271,9 @@ int fgInitSubsystems( void ) {
|
||||||
fgTimeUpdate(f, t);
|
fgTimeUpdate(f, t);
|
||||||
|
|
||||||
// Initialize view parameters
|
// Initialize view parameters
|
||||||
// ---->
|
v->Init();
|
||||||
fgViewInit(v);
|
v->Update(f);
|
||||||
fgViewUpdate(f, v, l);
|
v->UpdateWorldToEye(f);
|
||||||
|
|
||||||
// Initialize the orbital elements of sun, moon and mayor planets
|
// Initialize the orbital elements of sun, moon and mayor planets
|
||||||
fgSolarSystemInit(*t);
|
fgSolarSystemInit(*t);
|
||||||
|
@ -297,11 +297,9 @@ int fgInitSubsystems( void ) {
|
||||||
// fgUpdateSunPos() needs a few position and view parameters set
|
// fgUpdateSunPos() needs a few position and view parameters set
|
||||||
// so it can calculate local relative sun angle and a few other
|
// so it can calculate local relative sun angle and a few other
|
||||||
// things for correctly orienting the sky.
|
// things for correctly orienting the sky.
|
||||||
// ---->
|
|
||||||
fgUpdateSunPos();
|
fgUpdateSunPos();
|
||||||
|
|
||||||
// Initialize Lighting interpolation tables
|
// Initialize Lighting interpolation tables
|
||||||
// ---->
|
|
||||||
fgLightInit();
|
fgLightInit();
|
||||||
|
|
||||||
// update the lighting parameters (based on sun angle)
|
// update the lighting parameters (based on sun angle)
|
||||||
|
@ -323,7 +321,6 @@ int fgInitSubsystems( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the "sky"
|
// Initialize the "sky"
|
||||||
// ---->
|
|
||||||
fgSkyInit();
|
fgSkyInit();
|
||||||
|
|
||||||
// Initialize the Scenery Management subsystem
|
// Initialize the Scenery Management subsystem
|
||||||
|
@ -384,6 +381,14 @@ int fgInitSubsystems( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.13 1998/05/16 13:08:35 curt
|
||||||
|
// C++ - ified views.[ch]xx
|
||||||
|
// Shuffled some additional view parameters into the fgVIEW class.
|
||||||
|
// Changed tile-radius to tile-diameter because it is a much better
|
||||||
|
// name.
|
||||||
|
// Added a WORLD_TO_EYE transformation to views.cxx. This allows us
|
||||||
|
// to transform world space to eye space for view frustum culling.
|
||||||
|
//
|
||||||
// Revision 1.12 1998/05/13 18:29:58 curt
|
// Revision 1.12 1998/05/13 18:29:58 curt
|
||||||
// Added a keyboard binding to dynamically adjust field of view.
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
// Added a command line option to specify fov.
|
// Added a command line option to specify fov.
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Debug/fg_debug.h>
|
#include <Debug/fg_debug.h>
|
||||||
|
#include <Include/fg_constants.h>
|
||||||
#include <Include/fg_zlib.h>
|
#include <Include/fg_zlib.h>
|
||||||
|
|
||||||
#include "options.hxx"
|
#include "options.hxx"
|
||||||
|
@ -79,7 +80,7 @@ fgOPTIONS::fgOPTIONS( void ) {
|
||||||
wireframe = 0;
|
wireframe = 0;
|
||||||
|
|
||||||
// Scenery options
|
// Scenery options
|
||||||
tile_radius = 7;
|
tile_diameter = 7;
|
||||||
|
|
||||||
// Time options
|
// Time options
|
||||||
time_offset = 0;
|
time_offset = 0;
|
||||||
|
@ -229,22 +230,16 @@ static int parse_time_offset(char *time_str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Parse --tile-radius=n type option
|
// Parse --tile-diameter=n type option
|
||||||
|
|
||||||
#define FG_RADIUS_MIN 3
|
#define FG_RADIUS_MIN 1
|
||||||
#define FG_RADIUS_MAX 9
|
#define FG_RADIUS_MAX 4
|
||||||
|
|
||||||
static int parse_tile_radius(char *arg) {
|
static int parse_tile_radius(char *arg) {
|
||||||
int radius, tmp;
|
int radius, tmp;
|
||||||
|
|
||||||
radius = parse_int(arg);
|
radius = parse_int(arg);
|
||||||
|
|
||||||
// radius must be odd
|
|
||||||
tmp = radius / 2;
|
|
||||||
if ( radius == ( tmp * 2 ) ) {
|
|
||||||
radius -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
|
if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; }
|
||||||
if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
|
if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; }
|
||||||
|
|
||||||
|
@ -255,10 +250,6 @@ static int parse_tile_radius(char *arg) {
|
||||||
|
|
||||||
|
|
||||||
// Parse --fov=x.xx type option
|
// Parse --fov=x.xx type option
|
||||||
|
|
||||||
#define FG_FOV_MIN 0.1
|
|
||||||
#define FG_FOV_MAX 179.9
|
|
||||||
|
|
||||||
static double parse_fov(char *arg) {
|
static double parse_fov(char *arg) {
|
||||||
double fov;
|
double fov;
|
||||||
|
|
||||||
|
@ -318,6 +309,7 @@ int fgOPTIONS::parse_option( char *arg ) {
|
||||||
wireframe = 1;
|
wireframe = 1;
|
||||||
} else if ( strncmp(arg, "--tile-radius=", 14) == 0 ) {
|
} else if ( strncmp(arg, "--tile-radius=", 14) == 0 ) {
|
||||||
tile_radius = parse_tile_radius(arg);
|
tile_radius = parse_tile_radius(arg);
|
||||||
|
tile_diameter = tile_radius * 2 + 1;
|
||||||
} else if ( strncmp(arg, "--time-offset=", 14) == 0 ) {
|
} else if ( strncmp(arg, "--time-offset=", 14) == 0 ) {
|
||||||
time_offset = parse_time_offset(arg);
|
time_offset = parse_time_offset(arg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -424,7 +416,7 @@ void fgOPTIONS::usage ( void ) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("Scenery Options:\n");
|
printf("Scenery Options:\n");
|
||||||
printf("\t--tile-radius=n: specify tile radius, must be odd 3, 5, or 7\n");
|
printf("\t--tile-radius=n: specify tile radius, must be 1 - 4\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("Time Options:\n");
|
printf("Time Options:\n");
|
||||||
|
@ -438,6 +430,14 @@ fgOPTIONS::~fgOPTIONS( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.10 1998/05/16 13:08:36 curt
|
||||||
|
// C++ - ified views.[ch]xx
|
||||||
|
// Shuffled some additional view parameters into the fgVIEW class.
|
||||||
|
// Changed tile-radius to tile-diameter because it is a much better
|
||||||
|
// name.
|
||||||
|
// Added a WORLD_TO_EYE transformation to views.cxx. This allows us
|
||||||
|
// to transform world space to eye space for view frustum culling.
|
||||||
|
//
|
||||||
// Revision 1.9 1998/05/13 18:29:59 curt
|
// Revision 1.9 1998/05/13 18:29:59 curt
|
||||||
// Added a keyboard binding to dynamically adjust field of view.
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
// Added a command line option to specify fov.
|
// Added a command line option to specify fov.
|
||||||
|
|
|
@ -59,8 +59,10 @@ public:
|
||||||
int wireframe; // Wireframe mode enabled/disabled
|
int wireframe; // Wireframe mode enabled/disabled
|
||||||
|
|
||||||
// Scenery options
|
// Scenery options
|
||||||
int tile_radius; // Square radius of rendered tiles. for instance
|
int tile_radius; // Square radius of rendered tiles (around center
|
||||||
// if tile_radius = 3 then a 3 x 3 grid of tiles will
|
// square.)
|
||||||
|
int tile_diameter; // Diameter of rendered tiles. for instance
|
||||||
|
// if tile_diameter = 3 then a 3 x 3 grid of tiles will
|
||||||
// be drawn. Increase this to see terrain that is
|
// be drawn. Increase this to see terrain that is
|
||||||
// further away.
|
// further away.
|
||||||
|
|
||||||
|
@ -95,6 +97,14 @@ extern fgOPTIONS current_options;
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.8 1998/05/16 13:08:36 curt
|
||||||
|
// C++ - ified views.[ch]xx
|
||||||
|
// Shuffled some additional view parameters into the fgVIEW class.
|
||||||
|
// Changed tile-radius to tile-diameter because it is a much better
|
||||||
|
// name.
|
||||||
|
// Added a WORLD_TO_EYE transformation to views.cxx. This allows us
|
||||||
|
// to transform world space to eye space for view frustum culling.
|
||||||
|
//
|
||||||
// Revision 1.7 1998/05/13 18:29:59 curt
|
// Revision 1.7 1998/05/13 18:29:59 curt
|
||||||
// Added a keyboard binding to dynamically adjust field of view.
|
// Added a keyboard binding to dynamically adjust field of view.
|
||||||
// Added a command line option to specify fov.
|
// Added a command line option to specify fov.
|
||||||
|
|
182
Main/views.cxx
182
Main/views.cxx
|
@ -1,5 +1,5 @@
|
||||||
//
|
// views.cxx -- data structures and routines for managing and view
|
||||||
// views.cxx -- data structures and routines for managing and view parameters.
|
// parameters.
|
||||||
//
|
//
|
||||||
// Written by Curtis Olson, started August 1997.
|
// Written by Curtis Olson, started August 1997.
|
||||||
//
|
//
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
// (Log is kept at end of this file)
|
// (Log is kept at end of this file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,6 +36,7 @@
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
#include <Time/fg_time.hxx>
|
#include <Time/fg_time.hxx>
|
||||||
|
|
||||||
|
#include "options.hxx"
|
||||||
#include "views.hxx"
|
#include "views.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,51 +44,77 @@
|
||||||
fgVIEW current_view;
|
fgVIEW current_view;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
fgVIEW::fgVIEW( void ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initialize a view structure
|
// Initialize a view structure
|
||||||
void fgViewInit(fgVIEW *v) {
|
void fgVIEW::Init( void ) {
|
||||||
fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n");
|
fgPrintf( FG_VIEW, FG_INFO, "Initializing View parameters\n");
|
||||||
|
|
||||||
v->view_offset = 0.0;
|
view_offset = 0.0;
|
||||||
v->goal_view_offset = 0.0;
|
goal_view_offset = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update the view parameters
|
// Update the view parameters
|
||||||
void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l) {
|
void fgVIEW::Update( fgFLIGHT *f ) {
|
||||||
|
fgOPTIONS *o;
|
||||||
fgPolarPoint3d p;
|
fgPolarPoint3d p;
|
||||||
MAT3vec vec, forward, v0, minus_z;
|
MAT3vec vec, forward, v0, minus_z;
|
||||||
MAT3mat R, TMP, UP, LOCAL, VIEW;
|
MAT3mat R, TMP, UP, LOCAL, VIEW;
|
||||||
double ntmp;
|
double theta_x, theta_y, ntmp;
|
||||||
|
|
||||||
|
o = ¤t_options;
|
||||||
|
|
||||||
scenery.center.x = scenery.next_center.x;
|
scenery.center.x = scenery.next_center.x;
|
||||||
scenery.center.y = scenery.next_center.y;
|
scenery.center.y = scenery.next_center.y;
|
||||||
scenery.center.z = scenery.next_center.z;
|
scenery.center.z = scenery.next_center.z;
|
||||||
|
|
||||||
|
printf("win_ratio = %.2f\n", win_ratio);
|
||||||
|
|
||||||
|
// calculate sin() and cos() of fov / 2 in X direction;
|
||||||
|
theta_x = FG_PI_2 - (o->fov * win_ratio * DEG_TO_RAD) / 2.0;
|
||||||
|
printf("theta_x = %.2f\n", theta_x);
|
||||||
|
sin_fov_x = sin(theta_x);
|
||||||
|
cos_fov_x = cos(theta_x);
|
||||||
|
slope_x = sin_fov_x / cos_fov_x;
|
||||||
|
printf("slope_x = %.2f\n", slope_x);
|
||||||
|
|
||||||
|
// calculate sin() and cos() of fov / 2 in Y direction;
|
||||||
|
theta_y = FG_PI_2 - (o->fov * DEG_TO_RAD) / 2.0;
|
||||||
|
printf("theta_y = %.2f\n", theta_y);
|
||||||
|
sin_fov_y = sin(theta_y);
|
||||||
|
cos_fov_y = cos(theta_y);
|
||||||
|
slope_y = sin_fov_y / cos_fov_y;
|
||||||
|
printf("slope_y = %.2f\n", slope_y);
|
||||||
|
|
||||||
// calculate the cartesion coords of the current lat/lon/0 elev
|
// calculate the cartesion coords of the current lat/lon/0 elev
|
||||||
p.lon = FG_Longitude;
|
p.lon = FG_Longitude;
|
||||||
p.lat = FG_Lat_geocentric;
|
p.lat = FG_Lat_geocentric;
|
||||||
p.radius = FG_Sea_level_radius * FEET_TO_METER;
|
p.radius = FG_Sea_level_radius * FEET_TO_METER;
|
||||||
|
|
||||||
v->cur_zero_elev = fgPolarToCart3d(p);
|
cur_zero_elev = fgPolarToCart3d(p);
|
||||||
|
|
||||||
v->cur_zero_elev.x -= scenery.center.x;
|
cur_zero_elev.x -= scenery.center.x;
|
||||||
v->cur_zero_elev.y -= scenery.center.y;
|
cur_zero_elev.y -= scenery.center.y;
|
||||||
v->cur_zero_elev.z -= scenery.center.z;
|
cur_zero_elev.z -= scenery.center.z;
|
||||||
|
|
||||||
// calculate view position in current FG view coordinate system
|
// calculate view position in current FG view coordinate system
|
||||||
// p.lon & p.lat are already defined earlier
|
// p.lon & p.lat are already defined earlier
|
||||||
p.radius = FG_Radius_to_vehicle * FEET_TO_METER + 1.0;
|
p.radius = FG_Radius_to_vehicle * FEET_TO_METER + 1.0;
|
||||||
|
|
||||||
v->abs_view_pos = fgPolarToCart3d(p);
|
abs_view_pos = fgPolarToCart3d(p);
|
||||||
|
|
||||||
v->view_pos.x = v->abs_view_pos.x - scenery.center.x;
|
view_pos.x = abs_view_pos.x - scenery.center.x;
|
||||||
v->view_pos.y = v->abs_view_pos.y - scenery.center.y;
|
view_pos.y = abs_view_pos.y - scenery.center.y;
|
||||||
v->view_pos.z = v->abs_view_pos.z - scenery.center.z;
|
view_pos.z = abs_view_pos.z - scenery.center.z;
|
||||||
|
|
||||||
fgPrintf( FG_VIEW, FG_DEBUG, "Absolute view pos = %.4f, %.4f, %.4f\n",
|
fgPrintf( FG_VIEW, FG_DEBUG, "Absolute view pos = %.4f, %.4f, %.4f\n",
|
||||||
v->abs_view_pos.x, v->abs_view_pos.y, v->abs_view_pos.z);
|
abs_view_pos.x, abs_view_pos.y, abs_view_pos.z);
|
||||||
fgPrintf( FG_VIEW, FG_DEBUG, "Relative view pos = %.4f, %.4f, %.4f\n",
|
fgPrintf( FG_VIEW, FG_DEBUG, "Relative view pos = %.4f, %.4f, %.4f\n",
|
||||||
v->view_pos.x, v->view_pos.y, v->view_pos.z);
|
view_pos.x, view_pos.y, view_pos.z);
|
||||||
|
|
||||||
// Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
|
// Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
|
||||||
// from FG_T_local_to_body[3][3]
|
// from FG_T_local_to_body[3][3]
|
||||||
|
@ -156,11 +182,11 @@ void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l) {
|
||||||
// printf("Local up matrix\n");
|
// printf("Local up matrix\n");
|
||||||
// MAT3print(UP, stdout);
|
// MAT3print(UP, stdout);
|
||||||
|
|
||||||
MAT3_SET_VEC(v->local_up, 1.0, 0.0, 0.0);
|
MAT3_SET_VEC(local_up, 1.0, 0.0, 0.0);
|
||||||
MAT3mult_vec(v->local_up, v->local_up, UP);
|
MAT3mult_vec(local_up, local_up, UP);
|
||||||
|
|
||||||
// printf( "Local Up = (%.4f, %.4f, %.4f)\n",
|
// printf( "Local Up = (%.4f, %.4f, %.4f)\n",
|
||||||
// v->local_up[0], v->local_up[1], v->local_up[2]);
|
// local_up[0], local_up[1], local_up[2]);
|
||||||
|
|
||||||
// Alternative method to Derive local up vector based on
|
// Alternative method to Derive local up vector based on
|
||||||
// *geodetic* coordinates
|
// *geodetic* coordinates
|
||||||
|
@ -175,39 +201,131 @@ void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l) {
|
||||||
|
|
||||||
// generate the current up, forward, and fwrd-view vectors
|
// generate the current up, forward, and fwrd-view vectors
|
||||||
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
||||||
MAT3mult_vec(v->view_up, vec, VIEW);
|
MAT3mult_vec(view_up, vec, VIEW);
|
||||||
|
|
||||||
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
||||||
MAT3mult_vec(forward, vec, VIEW);
|
MAT3mult_vec(forward, vec, VIEW);
|
||||||
// printf( "Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1],
|
// printf( "Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1],
|
||||||
// forward[2]);
|
// forward[2]);
|
||||||
|
|
||||||
MAT3rotate(TMP, v->view_up, v->view_offset);
|
MAT3rotate(TMP, view_up, view_offset);
|
||||||
MAT3mult_vec(v->view_forward, forward, TMP);
|
MAT3mult_vec(view_forward, forward, TMP);
|
||||||
|
|
||||||
// make a vector to the current view position
|
// make a vector to the current view position
|
||||||
MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
|
MAT3_SET_VEC(v0, view_pos.x, view_pos.y, view_pos.z);
|
||||||
|
|
||||||
// Given a vector pointing straight down (-Z), map into onto the
|
// Given a vector pointing straight down (-Z), map into onto the
|
||||||
// local plane representing "horizontal". This should give us the
|
// local plane representing "horizontal". This should give us the
|
||||||
// local direction for moving "south".
|
// local direction for moving "south".
|
||||||
MAT3_SET_VEC(minus_z, 0.0, 0.0, -1.0);
|
MAT3_SET_VEC(minus_z, 0.0, 0.0, -1.0);
|
||||||
map_vec_onto_cur_surface_plane(v->local_up, v0, minus_z, v->surface_south);
|
map_vec_onto_cur_surface_plane(local_up, v0, minus_z, surface_south);
|
||||||
MAT3_NORMALIZE_VEC(v->surface_south, ntmp);
|
MAT3_NORMALIZE_VEC(surface_south, ntmp);
|
||||||
// printf( "Surface direction directly south %.2f %.2f %.2f\n",
|
// printf( "Surface direction directly south %.2f %.2f %.2f\n",
|
||||||
// v->surface_south[0], v->surface_south[1], v->surface_south[2]);
|
// surface_south[0], surface_south[1], surface_south[2]);
|
||||||
|
|
||||||
// now calculate the surface east vector
|
// now calculate the surface east vector
|
||||||
MAT3rotate(TMP, v->view_up, FG_PI_2);
|
MAT3rotate(TMP, view_up, FG_PI_2);
|
||||||
MAT3mult_vec(v->surface_east, v->surface_south, TMP);
|
MAT3mult_vec(surface_east, surface_south, TMP);
|
||||||
// printf( "Surface direction directly east %.2f %.2f %.2f\n",
|
// printf( "Surface direction directly east %.2f %.2f %.2f\n",
|
||||||
// v->surface_east[0], v->surface_east[1], v->surface_east[2]);
|
// surface_east[0], surface_east[1], surface_east[2]);
|
||||||
// printf( "Should be close to zero = %.2f\n",
|
// printf( "Should be close to zero = %.2f\n",
|
||||||
// MAT3_DOT_PRODUCT(v->surface_south, v->surface_east));
|
// MAT3_DOT_PRODUCT(surface_south, surface_east));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Update the "World to Eye" transformation matrix
|
||||||
|
// This is most useful for view frustum culling
|
||||||
|
void fgVIEW::UpdateWorldToEye( fgFLIGHT *f ) {
|
||||||
|
MAT3mat R_Phi, R_Theta, R_Psi, R_Lat, R_Lon, T_view;
|
||||||
|
MAT3mat TMP;
|
||||||
|
MAT3hvec vec;
|
||||||
|
|
||||||
|
// Roll Matrix
|
||||||
|
MAT3_SET_HVEC(vec, 0.0, 0.0, -1.0, 1.0);
|
||||||
|
MAT3rotate(R_Phi, vec, FG_Phi);
|
||||||
|
// printf("Roll matrix (Phi)\n");
|
||||||
|
// MAT3print(R_Phi, stdout);
|
||||||
|
|
||||||
|
// Pitch Matrix
|
||||||
|
MAT3_SET_HVEC(vec, 1.0, 0.0, 0.0, 1.0);
|
||||||
|
MAT3rotate(R_Theta, vec, FG_Theta);
|
||||||
|
// printf("\nPitch matrix (Theta)\n");
|
||||||
|
// MAT3print(R_Theta, stdout);
|
||||||
|
|
||||||
|
// Yaw Matrix
|
||||||
|
MAT3_SET_HVEC(vec, 0.0, -1.0, 0.0, 1.0);
|
||||||
|
MAT3rotate(R_Psi, vec, FG_Psi + FG_PI - view_offset );
|
||||||
|
// printf("\nYaw matrix (Psi)\n");
|
||||||
|
// MAT3print(R_Psi, stdout);
|
||||||
|
|
||||||
|
// Latitude
|
||||||
|
MAT3_SET_HVEC(vec, 1.0, 0.0, 0.0, 1.0);
|
||||||
|
// R_Lat = rotate about X axis
|
||||||
|
MAT3rotate(R_Lat, vec, FG_Latitude);
|
||||||
|
// printf("\nLatitude matrix\n");
|
||||||
|
// MAT3print(R_Lat, stdout);
|
||||||
|
|
||||||
|
// Longitude
|
||||||
|
MAT3_SET_HVEC(vec, 0.0, 0.0, 1.0, 1.0);
|
||||||
|
// R_Lon = rotate about Z axis
|
||||||
|
MAT3rotate(R_Lon, vec, FG_Longitude - FG_PI_2 );
|
||||||
|
// printf("\nLongitude matrix\n");
|
||||||
|
// MAT3print(R_Lon, stdout);
|
||||||
|
|
||||||
|
// View position in scenery centered coordinates
|
||||||
|
MAT3_SET_HVEC(vec, view_pos.x, view_pos.y, view_pos.z, 1.0);
|
||||||
|
MAT3translate(T_view, vec);
|
||||||
|
// printf("\nTranslation matrix\n");
|
||||||
|
// MAT3print(T_view, stdout);
|
||||||
|
|
||||||
|
// aircraft roll/pitch/yaw
|
||||||
|
MAT3mult(TMP, R_Phi, R_Theta);
|
||||||
|
MAT3mult(AIRCRAFT, TMP, R_Psi);
|
||||||
|
// printf("\naircraft roll pitch yaw\n");
|
||||||
|
// MAT3print(AIRCRAFT, stdout);
|
||||||
|
|
||||||
|
// lon/lat
|
||||||
|
MAT3mult(WORLD, R_Lat, R_Lon);
|
||||||
|
// printf("\nworld\n");
|
||||||
|
// MAT3print(WORLD, stdout);
|
||||||
|
|
||||||
|
MAT3mult(EYE_TO_WORLD, AIRCRAFT, WORLD);
|
||||||
|
MAT3mult(EYE_TO_WORLD, EYE_TO_WORLD, T_view);
|
||||||
|
// printf("\nEye to world\n");
|
||||||
|
// MAT3print(EYE_TO_WORLD, stdout);
|
||||||
|
|
||||||
|
MAT3invert(WORLD_TO_EYE, EYE_TO_WORLD);
|
||||||
|
// printf("\nWorld to eye\n");
|
||||||
|
// MAT3print(WORLD_TO_EYE, stdout);
|
||||||
|
|
||||||
|
// printf( "\nview_pos = %.2f %.2f %.2f\n",
|
||||||
|
// view_pos.x, view_pos.y, view_pos.z );
|
||||||
|
|
||||||
|
// MAT3_SET_HVEC(eye, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
// MAT3mult_vec(vec, eye, EYE_TO_WORLD);
|
||||||
|
// printf("\neye -> world = %.2f %.2f %.2f\n", vec[0], vec[1], vec[2]);
|
||||||
|
|
||||||
|
// MAT3_SET_HVEC(vec1, view_pos.x, view_pos.y, view_pos.z, 1.0);
|
||||||
|
// MAT3mult_vec(vec, vec1, WORLD_TO_EYE);
|
||||||
|
// printf( "\nabs_view_pos -> eye = %.2f %.2f %.2f\n",
|
||||||
|
// vec[0], vec[1], vec[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
fgVIEW::~fgVIEW( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.9 1998/05/16 13:08:37 curt
|
||||||
|
// C++ - ified views.[ch]xx
|
||||||
|
// Shuffled some additional view parameters into the fgVIEW class.
|
||||||
|
// Changed tile-radius to tile-diameter because it is a much better
|
||||||
|
// name.
|
||||||
|
// Added a WORLD_TO_EYE transformation to views.cxx. This allows us
|
||||||
|
// to transform world space to eye space for view frustum culling.
|
||||||
|
//
|
||||||
// Revision 1.8 1998/05/02 01:51:01 curt
|
// Revision 1.8 1998/05/02 01:51:01 curt
|
||||||
// Updated polartocart conversion routine.
|
// Updated polartocart conversion routine.
|
||||||
//
|
//
|
||||||
|
|
307
Main/views.hxx
307
Main/views.hxx
|
@ -1,27 +1,26 @@
|
||||||
/**************************************************************************
|
//
|
||||||
* views.hxx -- data structures and routines for managing and view parameters.
|
// views.hxx -- data structures and routines for managing and view parameters.
|
||||||
*
|
//
|
||||||
* Written by Curtis Olson, started August 1997.
|
// Written by Curtis Olson, started August 1997.
|
||||||
*
|
//
|
||||||
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||||
*
|
//
|
||||||
* This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
* License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
*
|
//
|
||||||
* This program is distributed in the hope that it will be useful, but
|
// This program is distributed in the hope that it will be useful, but
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* General Public License for more details.
|
// General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
//
|
||||||
* $Id$
|
// $Id$
|
||||||
* (Log is kept at end of this file)
|
// (Log is kept at end of this file)
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _VIEWS_HXX
|
#ifndef _VIEWS_HXX
|
||||||
|
@ -40,119 +39,171 @@
|
||||||
#include <Time/light.hxx>
|
#include <Time/light.hxx>
|
||||||
|
|
||||||
|
|
||||||
/* Define a structure containing view information */
|
// Define a structure containing view information
|
||||||
typedef struct {
|
class fgVIEW {
|
||||||
/* absolute view position */
|
|
||||||
fgCartesianPoint3d abs_view_pos;
|
|
||||||
|
|
||||||
/* view position translated to scenery.center */
|
public:
|
||||||
fgCartesianPoint3d view_pos;
|
|
||||||
|
|
||||||
/* cartesion coordinates of current lon/lat if at sea level
|
// the current offset from forward for viewing
|
||||||
* translated to scenery.center*/
|
|
||||||
fgCartesianPoint3d cur_zero_elev;
|
|
||||||
|
|
||||||
/* vector in cartesian coordinates from current position to the
|
|
||||||
* postion on the earth's surface the sun is directly over */
|
|
||||||
MAT3vec to_sun;
|
|
||||||
|
|
||||||
/* surface direction to go to head towards sun */
|
|
||||||
MAT3vec surface_to_sun;
|
|
||||||
|
|
||||||
/* surface vector heading south */
|
|
||||||
MAT3vec surface_south;
|
|
||||||
|
|
||||||
/* surface vector heading east (used to unambiguously align sky with sun) */
|
|
||||||
MAT3vec surface_east;
|
|
||||||
|
|
||||||
/* local up vector (normal to the plane tangent to the earth's
|
|
||||||
* surface at the spot we are directly above */
|
|
||||||
MAT3vec local_up;
|
|
||||||
|
|
||||||
/* up vector for the view (usually point straight up through the
|
|
||||||
* top of the aircraft */
|
|
||||||
MAT3vec view_up;
|
|
||||||
|
|
||||||
/* the vector pointing straight out the nose of the aircraft */
|
|
||||||
MAT3vec view_forward;
|
|
||||||
|
|
||||||
/* the current offset from forward for viewing */
|
|
||||||
double view_offset;
|
double view_offset;
|
||||||
|
|
||||||
/* the goal view offset for viewing (used for smooth view changes) */
|
// the goal view offset for viewing (used for smooth view changes)
|
||||||
double goal_view_offset;
|
double goal_view_offset;
|
||||||
} fgVIEW;
|
|
||||||
|
// fov of view is specified in the y direction, win_ratio is used to
|
||||||
|
// calculate the fov in the X direction = width/height
|
||||||
|
double win_ratio;
|
||||||
|
|
||||||
|
// width & height of window
|
||||||
|
int winWidth, winHeight;
|
||||||
|
|
||||||
|
// sin and cos of (fov / 2) in Y axis
|
||||||
|
double sin_fov_y, cos_fov_y;
|
||||||
|
|
||||||
|
// slope of view frustum edge in eye space Y axis
|
||||||
|
double slope_y;
|
||||||
|
|
||||||
|
// sin and cos of (fov / 2) in X axis
|
||||||
|
double sin_fov_x, cos_fov_x;
|
||||||
|
|
||||||
|
// slope of view frustum edge in eye space X axis
|
||||||
|
double slope_x;
|
||||||
|
|
||||||
|
// absolute view position
|
||||||
|
fgCartesianPoint3d abs_view_pos;
|
||||||
|
|
||||||
|
// view position translated to scenery.center
|
||||||
|
fgCartesianPoint3d view_pos;
|
||||||
|
|
||||||
|
// cartesion coordinates of current lon/lat if at sea level
|
||||||
|
// translated to scenery.center*/
|
||||||
|
fgCartesianPoint3d cur_zero_elev;
|
||||||
|
|
||||||
|
// vector in cartesian coordinates from current position to the
|
||||||
|
// postion on the earth's surface the sun is directly over
|
||||||
|
MAT3vec to_sun;
|
||||||
|
|
||||||
|
// surface direction to go to head towards sun
|
||||||
|
MAT3vec surface_to_sun;
|
||||||
|
|
||||||
|
// surface vector heading south
|
||||||
|
MAT3vec surface_south;
|
||||||
|
|
||||||
|
// surface vector heading east (used to unambiguously align sky
|
||||||
|
// with sun)
|
||||||
|
MAT3vec surface_east;
|
||||||
|
|
||||||
|
// local up vector (normal to the plane tangent to the earth's
|
||||||
|
// surface at the spot we are directly above
|
||||||
|
MAT3vec local_up;
|
||||||
|
|
||||||
|
// up vector for the view (usually point straight up through the
|
||||||
|
// top of the aircraft
|
||||||
|
MAT3vec view_up;
|
||||||
|
|
||||||
|
// the vector pointing straight out the nose of the aircraft
|
||||||
|
MAT3vec view_forward;
|
||||||
|
|
||||||
|
// Transformation matrix for eye coordinates to aircraft coordinates
|
||||||
|
MAT3mat AIRCRAFT;
|
||||||
|
|
||||||
|
// Transformation matrix for aircraft coordinates to world
|
||||||
|
// coordinates
|
||||||
|
MAT3mat WORLD;
|
||||||
|
|
||||||
|
// Combined transformation from eye coordinates to world coordinates
|
||||||
|
MAT3mat EYE_TO_WORLD;
|
||||||
|
|
||||||
|
// Inverse of EYE_TO_WORLD which is a transformation from world
|
||||||
|
// coordinates to eye coordinates
|
||||||
|
MAT3mat WORLD_TO_EYE;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
fgVIEW( void );
|
||||||
|
|
||||||
|
// Initialize a view class
|
||||||
|
void Init( void );
|
||||||
|
|
||||||
|
// Update the view parameters
|
||||||
|
void Update( fgFLIGHT *f );
|
||||||
|
|
||||||
|
// Update the "World to Eye" transformation matrix
|
||||||
|
void UpdateWorldToEye( fgFLIGHT *f );
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~fgVIEW( void );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
extern fgVIEW current_view;
|
extern fgVIEW current_view;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize a view structure */
|
#endif // _VIEWS_HXX
|
||||||
void fgViewInit(fgVIEW *v);
|
|
||||||
|
|
||||||
/* Update the view parameters */
|
|
||||||
void fgViewUpdate(fgFLIGHT *f, fgVIEW *v, fgLIGHT *l);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _VIEWS_HXX */
|
// $Log$
|
||||||
|
// Revision 1.6 1998/05/16 13:08:37 curt
|
||||||
|
// C++ - ified views.[ch]xx
|
||||||
/* $Log$
|
// Shuffled some additional view parameters into the fgVIEW class.
|
||||||
/* Revision 1.5 1998/05/02 01:51:02 curt
|
// Changed tile-radius to tile-diameter because it is a much better
|
||||||
/* Updated polartocart conversion routine.
|
// name.
|
||||||
/*
|
// Added a WORLD_TO_EYE transformation to views.cxx. This allows us
|
||||||
* Revision 1.4 1998/04/28 01:20:24 curt
|
// to transform world space to eye space for view frustum culling.
|
||||||
* Type-ified fgTIME and fgVIEW.
|
//
|
||||||
* Added a command line option to disable textures.
|
// Revision 1.5 1998/05/02 01:51:02 curt
|
||||||
*
|
// Updated polartocart conversion routine.
|
||||||
* Revision 1.3 1998/04/25 22:06:31 curt
|
//
|
||||||
* Edited cvs log messages in source files ... bad bad bad!
|
// Revision 1.4 1998/04/28 01:20:24 curt
|
||||||
*
|
// Type-ified fgTIME and fgVIEW.
|
||||||
* Revision 1.2 1998/04/24 00:49:22 curt
|
// Added a command line option to disable textures.
|
||||||
* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
|
//
|
||||||
* Trying out some different option parsing code.
|
// Revision 1.3 1998/04/25 22:06:31 curt
|
||||||
* Some code reorganization.
|
// Edited cvs log messages in source files ... bad bad bad!
|
||||||
*
|
//
|
||||||
* Revision 1.1 1998/04/22 13:25:46 curt
|
// Revision 1.2 1998/04/24 00:49:22 curt
|
||||||
* C++ - ifing the code.
|
// Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
|
||||||
* Starting a bit of reorganization of lighting code.
|
// Trying out some different option parsing code.
|
||||||
*
|
// Some code reorganization.
|
||||||
* Revision 1.11 1998/04/21 17:02:42 curt
|
//
|
||||||
* Prepairing for C++ integration.
|
// Revision 1.1 1998/04/22 13:25:46 curt
|
||||||
*
|
// C++ - ifing the code.
|
||||||
* Revision 1.10 1998/02/07 15:29:45 curt
|
// Starting a bit of reorganization of lighting code.
|
||||||
* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
|
//
|
||||||
* <chotchkiss@namg.us.anritsu.com>
|
// Revision 1.11 1998/04/21 17:02:42 curt
|
||||||
*
|
// Prepairing for C++ integration.
|
||||||
* Revision 1.9 1998/01/29 00:50:29 curt
|
//
|
||||||
* Added a view record field for absolute x, y, z position.
|
// Revision 1.10 1998/02/07 15:29:45 curt
|
||||||
*
|
// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
|
||||||
* Revision 1.8 1998/01/27 00:47:58 curt
|
// <chotchkiss@namg.us.anritsu.com>
|
||||||
* Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
//
|
||||||
* system and commandline/config file processing code.
|
// Revision 1.9 1998/01/29 00:50:29 curt
|
||||||
*
|
// Added a view record field for absolute x, y, z position.
|
||||||
* Revision 1.7 1998/01/22 02:59:38 curt
|
//
|
||||||
* Changed #ifdef FILE_H to #ifdef _FILE_H
|
// Revision 1.8 1998/01/27 00:47:58 curt
|
||||||
*
|
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||||
* Revision 1.6 1998/01/19 19:27:10 curt
|
// system and commandline/config file processing code.
|
||||||
* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
//
|
||||||
* This should simplify things tremendously.
|
// Revision 1.7 1998/01/22 02:59:38 curt
|
||||||
*
|
// Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||||
* Revision 1.5 1997/12/22 04:14:32 curt
|
//
|
||||||
* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
// Revision 1.6 1998/01/19 19:27:10 curt
|
||||||
*
|
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||||
* Revision 1.4 1997/12/17 23:13:36 curt
|
// This should simplify things tremendously.
|
||||||
* Began working on rendering a sky.
|
//
|
||||||
*
|
// Revision 1.5 1997/12/22 04:14:32 curt
|
||||||
* Revision 1.3 1997/12/15 23:54:51 curt
|
// Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||||
* Add xgl wrappers for debugging.
|
//
|
||||||
* Generate terrain normals on the fly.
|
// Revision 1.4 1997/12/17 23:13:36 curt
|
||||||
*
|
// Began working on rendering a sky.
|
||||||
* Revision 1.2 1997/12/10 22:37:48 curt
|
//
|
||||||
* Prepended "fg" on the name of all global structures that didn't have it yet.
|
// Revision 1.3 1997/12/15 23:54:51 curt
|
||||||
* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
// Add xgl wrappers for debugging.
|
||||||
*
|
// Generate terrain normals on the fly.
|
||||||
* Revision 1.1 1997/08/27 21:31:18 curt
|
//
|
||||||
* Initial revision.
|
// Revision 1.2 1997/12/10 22:37:48 curt
|
||||||
*
|
// Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||||
*/
|
// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||||
|
//
|
||||||
|
// Revision 1.1 1997/08/27 21:31:18 curt
|
||||||
|
// Initial revision.
|
||||||
|
//
|
||||||
|
|
Loading…
Reference in a new issue