From c6c094034c4d9cd54b7ffed5a3862bbf134c1e5d Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 25 Feb 2005 22:27:15 +0000 Subject: [PATCH] Add support for drawing only a portion of the configured view frustum. This is one way to get an asymmetric view frustum without needing to compute the sgFrustum parameters directly. --- src/Main/renderer.cxx | 73 +++++++++++++++++++++++++++++++++---------- src/Main/viewmgr.cxx | 4 ++- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index 7879eee20..da3f05696 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -818,25 +818,64 @@ FGRenderer::resize( int width, int height ) { static void fgHackFrustum() { -#if 0 - /* experiment in assymetric view frustums */ + // specify a percent of the configured view frustum to actually + // display. This is a bit of a hack to achieve asymmetric view + // frustums. For instance, if you want to display two monitors + // side by side, you could specify each with a double fov, a 0.5 + // aspect ratio multiplier, and then the left side monitor would + // have a left_pct = 0.0, a right_pct = 0.5, a bottom_pct = 0.0, + // and a top_pct = 1.0. The right side monitor would have a + // left_pct = 0.5 and a right_pct = 1.0. + + static SGPropertyNode *left_pct + = fgGetNode("/sim/current-view/frustum-left-pct"); + static SGPropertyNode *right_pct + = fgGetNode("/sim/current-view/frustum-right-pct"); + static SGPropertyNode *bottom_pct + = fgGetNode("/sim/current-view/frustum-bottom-pct"); + static SGPropertyNode *top_pct + = fgGetNode("/sim/current-view/frustum-top-pct"); + sgFrustum *f = ssgGetFrustum(); - cout << " l = " << f->getLeft() - << " r = " << f->getRight() - << " b = " << f->getBot() - << " t = " << f->getTop() - << " n = " << f->getNear() - << " f = " << f->getFar() - << endl; - static double incr = 0.0; - double factor = (sin(incr) + 1.0) / 2.0; // map to [0-1] - double w = (f->getRight() - f->getLeft()) / 2.0; - double l = f->getLeft() + w * factor; - double r = l + w; - ssgSetFrustum(l, r, f->getBot(), f->getTop(), f->getNear(), f->getFar()); - incr += 0.001; -#endif + // cout << " l = " << f->getLeft() + // << " r = " << f->getRight() + // << " b = " << f->getBot() + // << " t = " << f->getTop() + // << " n = " << f->getNear() + // << " f = " << f->getFar() + // << endl; + + double width = f->getRight() - f->getLeft(); + double height = f->getTop() - f->getBot(); + + double l, r, t, b; + + if ( left_pct != NULL ) { + l = f->getLeft() + width * left_pct->getDoubleValue(); + } else { + l = f->getLeft(); + } + + if ( right_pct != NULL ) { + r = f->getLeft() + width * right_pct->getDoubleValue(); + } else { + r = f->getRight(); + } + + if ( bottom_pct != NULL ) { + b = f->getBot() + height * bottom_pct->getDoubleValue(); + } else { + b = f->getBot(); + } + + if ( top_pct != NULL ) { + t = f->getBot() + height * top_pct->getDoubleValue(); + } else { + t = f->getTop(); + } + + ssgSetFrustum(l, r, b, t, f->getNear(), f->getFar()); } diff --git a/src/Main/viewmgr.cxx b/src/Main/viewmgr.cxx index ad376d30a..bc1c54521 100644 --- a/src/Main/viewmgr.cxx +++ b/src/Main/viewmgr.cxx @@ -54,12 +54,14 @@ FGViewMgr::init () // double damp_alt; double damp_roll = 0.0, damp_pitch = 0.0, damp_heading = 0.0; double x_offset_m, y_offset_m, z_offset_m, fov_deg; - double aspect_ratio_multiplier = 1.0; 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; + double aspect_ratio_multiplier + = fgGetDouble("/sim/current-view/aspect-ratio-multiplier"); + for (int i = 0; i < fgGetInt("/sim/number-views"); i++) { viewpath = "/sim/view"; sprintf(stridx, "[%d]", i); -- 2.39.5