]> git.mxchange.org Git - flightgear.git/commitdiff
Jim Wilson:
authorcurt <curt>
Wed, 22 Oct 2003 18:48:31 +0000 (18:48 +0000)
committercurt <curt>
Wed, 22 Oct 2003 18:48:31 +0000 (18:48 +0000)
This makes it possible to setup multiple cockpit views and have the correct
clipping plane set for rendering the model.

src/Main/viewer.cxx
src/Main/viewer.hxx
src/Main/viewmgr.cxx
src/Model/acmodel.cxx

index 282d6a9d0cc722af3619349819adb9d253ca97e4..ef142a1a0e09f2caf2bdf27b49c38941ecf20f28 100644 (file)
@@ -138,7 +138,7 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
                     double heading_offset_deg, double pitch_offset_deg,
                     double roll_offset_deg, double fov_deg,
                     double target_x_offset_m, double target_y_offset_m,
-                    double target_z_offset_m, double near_m ):
+                    double target_z_offset_m, double near_m, bool internal ):
     _dirty(true),
     _lon_deg(0),
     _lat_deg(0),
@@ -162,6 +162,8 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
     _at_model = at_model;
     _at_model_index = at_model_index;
 
+    _internal = internal;
+
     if (damp_roll > 0.0)
       _damp_roll = 1.0 / pow(10, fabs(damp_roll));
     if (damp_pitch > 0.0)
@@ -230,6 +232,12 @@ FGViewer::setType ( int type )
     _type = FG_LOOKAT;
 }
 
+void
+FGViewer::setInternal ( bool internal )
+{
+  _internal = internal;
+}
+
 void
 FGViewer::setLongitude_deg (double lon_deg)
 {
index 30f17a0d0acdf0ffee4bf132ea55ac7eed83f502..26e581387282d053dad9094aa1cd4cfc70d4959b 100644 (file)
@@ -67,7 +67,7 @@ public:
               double heading_offset_deg, double pitch_offset_deg,
               double roll_offset_deg, double fov_deg,
               double target_x_offset_m, double target_y_offset_m,
-              double target_z_offset_m, double near_m );
+              double target_z_offset_m, double near_m, bool internal );
 
     // Destructor
     virtual ~FGViewer( void );
@@ -89,6 +89,9 @@ public:
     virtual fgViewType getType() const { return _type; }
     virtual void setType( int type );
 
+    virtual bool getInternal() const { return _internal; }
+    virtual void setInternal( bool internal );
+
     // Reference geodetic position of view from position...
     //   These are the actual aircraft position (pilot in
     //   pilot view, model in model view).
@@ -323,6 +326,9 @@ private:
     fgViewType _type;
     fgScalingType _scaling_type;
 
+    // internal view (e.g. cockpit) flag
+    bool _internal;
+
     // view is looking from a model
     bool _from_model;
     int _from_model_index;  // number of model (for multi model)
index 90fd4c3a73c68e5c794e9f8a66d512f4388cecac..39e7ac95bd5a893e0498c02efa2ec4722c5f22c4 100644 (file)
@@ -56,6 +56,7 @@ FGViewMgr::init ()
   double heading_offset_deg, pitch_offset_deg, roll_offset_deg;
   double target_x_offset_m, target_y_offset_m, target_z_offset_m;
   double near_m;
+  bool internal;
 
   for (int i = 0; i < fgGetInt("/sim/number-views"); i++) {
     viewpath = "/sim/view";
@@ -67,6 +68,12 @@ FGViewMgr::init ()
     nodepath += "/type";
     strdata = fgGetString(nodepath.c_str());
 
+    // find out if this is an internal view (e.g. in cockpit, low near plane)
+    internal = false; // default
+    nodepath = viewpath;
+    nodepath += "/internal";
+    internal = fgGetBool(nodepath.c_str());
+
     // FIXME:
     // this is assumed to be an aircraft model...we will need to read
     // model-from-type as well.
@@ -155,13 +162,14 @@ FGViewMgr::init ()
                               heading_offset_deg, pitch_offset_deg,
                               roll_offset_deg, fov_deg,
                               target_x_offset_m, target_y_offset_m,
-                              target_z_offset_m, near_m ));
+                              target_z_offset_m, near_m, internal ));
     else
       add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
                               false, 0, 0.0, 0.0, 0.0,
                               x_offset_m, y_offset_m, z_offset_m,
                               heading_offset_deg, pitch_offset_deg,
-                              roll_offset_deg, fov_deg, 0, 0, 0, near_m ));
+                              roll_offset_deg, fov_deg, 0, 0, 0, near_m,
+                              internal ));
   }
 
   copyToCurrent();
index e14c6bd263246e050bae6f1acbe9ef3d0df6e63a..e209416c90940f80080746ebd43ec1d9d81545e3 100644 (file)
@@ -21,6 +21,7 @@
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/viewmgr.hxx>
+#include <Main/viewer.hxx>
 #include <Scenery/scenery.hxx>
 
 #include "model_panel.hxx"
@@ -91,8 +92,9 @@ void
 FGAircraftModel::update (double dt)
 {
   int view_number = globals->get_viewmgr()->get_current();
+  int is_internal = globals->get_current_view()->getInternal();
 
-  if (view_number == 0 && !fgGetBool("/sim/view/internal")) {
+  if (view_number == 0 && !is_internal) {
     _aircraft->setVisible(false);
   } else {
     _aircraft->setVisible(true);
@@ -114,8 +116,8 @@ FGAircraftModel::draw ()
                                // OK, now adjust the clip planes and draw
                                // FIXME: view number shouldn't be 
                                // hard-coded.
-  int view_number = globals->get_viewmgr()->get_current();
-  if (_aircraft->getVisible() && view_number == 0) {
+  bool is_internal = globals->get_current_view()->getInternal();
+  if (_aircraft->getVisible() && is_internal) {
     glClearDepth(1);
     glClear(GL_DEPTH_BUFFER_BIT);
     ssgSetNearFar(_nearplane, _farplane);