+// These are wrapper functions around ssgSetNearFar() and ssgSetFOV()
+// which will post process and rewrite the resulting frustum if we
+// want to do asymmetric view frustums.
+
+static void fgHackFrustum() {
+
+ /* experiment in assymetric view frustums */
+ 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;
+}
+
+
+// we need some static storage space for these values. However, we
+// can't store it in a renderer class object because the functions
+// that manipulate these are static. They are static so they can
+// interface to the display callback system. There's probably a
+// better way, there has to be a better way, but I'm not seeing it
+// right now.
+static float width, height, near, far;
+
+
+/** FlightGear code should use this routine to set the FOV rather than
+ * calling the ssg routine directly
+ */
+void FGRenderer::setFOV( float w, float h ) {
+ width = w;
+ height = h;
+
+ // fully specify the view frustum before hacking it (so we don't
+ // accumulate hacked effects
+ ssgSetFOV( w, h );
+ ssgSetNearFar( near, far );
+
+ fgHackFrustum();
+}
+
+
+/** FlightGear code should use this routine to set the Near/Far clip
+ * planes rather than calling the ssg routine directly
+ */
+void FGRenderer::setNearFar( float n, float f ) {
+ near = n;
+ far = f;
+
+ // fully specify the view frustum before hacking it (so we don't
+ // accumulate hacked effects
+ ssgSetNearFar( n, f );
+ ssgSetFOV( width, height );
+
+ fgHackFrustum();
+}
+