1
0
Fork 0

Added some early support for a cheezy external view of TuX.

'v' toggles internal vs. external view modes.
Add the distance of the bouding radius into the tile's range selector.
This commit is contained in:
curt 1999-06-30 14:35:01 +00:00
parent 39b3602dce
commit 9f9f487e2a
5 changed files with 78 additions and 15 deletions

View file

@ -277,7 +277,10 @@ void GLUTkey(unsigned char k, int x, int y) {
t->adjust_warp_delta (+30);
local_update_sky_and_lighting_params();
return;
case 120: // X key
case 118: // v key
v->cycle_view_mode();
return;
case 120: // x key
fov = current_options.get_fov();
fov /= 1.05;
if ( fov < FG_FOV_MIN ) {

View file

@ -402,17 +402,15 @@ static void fgRenderFrame( void ) {
sgMat4 sgTRANS;
sgMakeTransMat4( sgTRANS,
current_view.view_pos.x()
+ current_view.view_forward[0] * 20,
current_view.view_pos.y()
+ current_view.view_forward[1] * 20,
current_view.view_pos.z()
+ current_view.view_forward[2] * 20 );
current_view.view_pos.x(),
current_view.view_pos.y(),
current_view.view_pos.z() );
sgMat4 sgTMP;
// sgMat4 sgTMP;
sgMat4 sgTUX;
sgMultMat4( sgTMP, current_view.sgUP, sgTRANS );
sgMultMat4( sgTUX, current_view.sgLARC_TO_SSG, sgTMP );
// sgMultMat4( sgTMP, current_view.sgUP, sgTRANS );
// sgMultMat4( sgTUX, current_view.sgLARC_TO_SSG, sgTMP );
sgMultMat4( sgTUX, current_view.sgVIEW_ROT, sgTRANS );
sgCoord tuxpos;
sgSetCoord( &tuxpos, sgTUX );
@ -423,7 +421,17 @@ static void fgRenderFrame( void ) {
current_view.view_pos.y(),
current_view.view_pos.z() );
sgMat4 sgVIEW;
sgMultMat4( sgVIEW, current_view.sgVIEW, sgTRANS );
if ( current_view.view_mode == FGView::FG_VIEW_FIRST_PERSON ) {
sgCopyMat4( sgVIEW, current_view.sgVIEW );
} else if ( current_view.view_mode == FGView::FG_VIEW_FOLLOW ) {
FGMat4Wrapper tmp = current_view.follow.front();
sgCopyMat4( sgVIEW, tmp.m );
}
if ( current_view.follow.size() > 15 ) {
current_view.follow.pop_front();
}
ssgSetCamera( sgVIEW );
global_tile_mgr.prep_ssg_nodes();

View file

@ -76,6 +76,7 @@ FGView::FGView( void ) {
void FGView::Init( void ) {
FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
view_mode = FG_VIEW_FIRST_PERSON;
view_offset = 0.0;
goal_view_offset = 0.0;
@ -131,6 +132,16 @@ void FGView::UpdateFOV( const fgOPTIONS& o ) {
}
// Cycle view mode
void FGView::cycle_view_mode() {
if ( view_mode == FG_VIEW_FIRST_PERSON ) {
view_mode = FG_VIEW_FOLLOW;
} else if ( view_mode == FG_VIEW_FOLLOW ) {
view_mode = FG_VIEW_FIRST_PERSON;
}
}
// Basically, this is a modified version of the Mesa gluLookAt()
// function that's been modified slightly so we can capture the
// result before sending it off to OpenGL land.
@ -742,7 +753,15 @@ void FGView::UpdateViewMath( FGInterface *f ) {
sgMat4 sgTMP;
sgMultMat4( sgTMP, sgLOCAL, sgUP );
sgMultMat4( sgVIEW, sgLARC_TO_SSG, sgTMP );
sgMultMat4( sgVIEW_ROT, sgLARC_TO_SSG, sgTMP );
sgMakeTransMat4( sgTRANS, view_pos.x(), view_pos.y(), view_pos.z() );
sgMultMat4( sgVIEW, sgVIEW_ROT, sgTRANS );
FGMat4Wrapper tmp;
sgCopyMat4( tmp.m, sgVIEW );
follow.push_back( tmp );
/*
cout << "FG derived VIEW matrix using sg routines" << endl;

View file

@ -29,6 +29,10 @@
# error This library requires C++
#endif
#include <Include/compiler.h>
#include <list>
#include <sg.h> // plib include
#include <FDM/flight.hxx>
@ -39,6 +43,18 @@
#include "options.hxx"
FG_USING_STD(list);
class FGMat4Wrapper {
public:
sgMat4 m;
};
typedef list < FGMat4Wrapper > sgMat4_list;
typedef sgMat4_list::iterator sgMat4_list_iterator;
typedef sgMat4_list::const_iterator const_sgMat4_list_iterator;
// used in views.cxx and tilemgr.cxx
#define USE_FAST_FOV_CLIP
@ -49,6 +65,12 @@ class FGView {
public:
enum fgViewMode
{
FG_VIEW_FIRST_PERSON = 0,
FG_VIEW_FOLLOW = 1
};
// the current offset from forward for viewing
double view_offset;
@ -153,7 +175,14 @@ public:
// Current model view matrix;
GLfloat MODEL_VIEW[16];
sgMat4 sgLOCAL, sgUP, sgVIEW, sgLARC_TO_SSG;
// view mode
fgViewMode view_mode;
// sg versions of our friendly matrices
sgMat4 sgLOCAL, sgUP, sgVIEW_ROT, sgTRANS, sgVIEW, sgLARC_TO_SSG;
// queue of view matrices so we can have a follow view
sgMat4_list follow;
public:
@ -190,6 +219,9 @@ public:
// Update the field of view coefficients
void UpdateFOV( const fgOPTIONS& o );
// Cycle view mode
void cycle_view_mode();
// accessor functions
inline double get_view_offset() const { return view_offset; }
inline void set_view_offset( double a ) { view_offset = a; }

View file

@ -744,7 +744,6 @@ void FGTileMgr::prep_ssg_nodes( void ) {
float ranges[2];
ranges[0] = 0.0f;
ranges[1] = current_weather.get_visibility();
// traverse the potentially viewable tile list and update range
// selector and transform
@ -753,7 +752,9 @@ void FGTileMgr::prep_ssg_nodes( void ) {
t = global_tile_cache.get_tile(index);
if ( t->is_loaded() ) {
// set range selector (LOD trick)
// set range selector (LOD trick) to be distance to center
// of tile + bounding radius
ranges[1] = current_weather.get_visibility() + t->bounding_radius;
t->range_ptr->setRanges( ranges, 2 );
// calculate tile offset