]> git.mxchange.org Git - flightgear.git/commitdiff
Added some early support for a cheezy external view of TuX.
authorcurt <curt>
Wed, 30 Jun 1999 14:35:01 +0000 (14:35 +0000)
committercurt <curt>
Wed, 30 Jun 1999 14:35:01 +0000 (14:35 +0000)
'v' toggles internal vs. external view modes.
Add the distance of the bouding radius into the tile's range selector.

src/Main/keyboard.cxx
src/Main/main.cxx
src/Main/views.cxx
src/Main/views.hxx
src/Scenery/tilemgr.cxx

index d4e4e8b6c5a21d8ec401cefe6cc5034cdb243272..b5c7d2d5ac228f3049cce1b5c71eb14761022072 100644 (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 ) {
index 19d796e1bf1c82784f9d92e6afe1648f675cb0aa..f141f3bf43f2878ddad496658f7dd907b50736c3 100644 (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 );
-
-       sgMat4 sgTMP;
+                        current_view.view_pos.x(),
+                        current_view.view_pos.y(),
+                        current_view.view_pos.z() );
+
+       // 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();
index c6f6eba4f2b9fa4583098f4f0b57e2c115a61398..23945180bee808eb29e24855dbbd10cb2fd408a5 100644 (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;
index 378bf587617e1695353ce4c4c98fd0aaf57cc8da..b15a47d9f4af2375cf6e8887243b26c05147d6cd 100644 (file)
 # error This library requires C++
 #endif                                   
 
+#include <Include/compiler.h>
+
+#include <list>
+
 #include <sg.h>                        // plib include
 
 #include <FDM/flight.hxx>
 
 #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; }
index f303f82189d833762cafb2c248e1e88fa93ce2bf..e296d0a28b2309bb92239dacd02286dbd36211e9 100644 (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