From 1d058b0bac42aa38b19762fcfaca64ff8c7608fd Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 22 Oct 2003 18:48:31 +0000 Subject: [PATCH] Jim Wilson: This makes it possible to setup multiple cockpit views and have the correct clipping plane set for rendering the model. --- src/Main/viewer.cxx | 10 +++++++++- src/Main/viewer.hxx | 8 +++++++- src/Main/viewmgr.cxx | 12 ++++++++++-- src/Model/acmodel.cxx | 8 +++++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index 282d6a9d0..ef142a1a0 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -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) { diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 30f17a0d0..26e581387 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -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) diff --git a/src/Main/viewmgr.cxx b/src/Main/viewmgr.cxx index 90fd4c3a7..39e7ac95b 100644 --- a/src/Main/viewmgr.cxx +++ b/src/Main/viewmgr.cxx @@ -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(); diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx index e14c6bd26..e209416c9 100644 --- a/src/Model/acmodel.cxx +++ b/src/Model/acmodel.cxx @@ -21,6 +21,7 @@ #include
#include
#include
+#include
#include #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);