1
0
Fork 0

Jim Wilson:

This makes it possible to setup multiple cockpit views and have the correct
clipping plane set for rendering the model.
This commit is contained in:
curt 2003-10-22 18:48:31 +00:00
parent 8e904eb882
commit 1d058b0bac
4 changed files with 31 additions and 7 deletions

View 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)
{

View 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)

View 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();

View 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);