// Copyright (C) 2008 Tim Moore
+// Copyright (C) 2011 Mathias Froehlich
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
double left, right, bottom, top, parentNear, parentFar;
projectionMatrix.getFrustum(left, right, bottom, top,
parentNear, parentFar);
+ if ((info->flags & FIXED_NEAR_FAR) == 0) {
+ parentNear = _zNear;
+ parentFar = _zFar;
+ }
if (parentFar < _nearField || _nearField == 0.0f) {
camera->setProjectionMatrix(projectionMatrix);
camera->setCullMask(camera->getCullMask()
double aspectRatio = projectionNode->getDoubleValue("aspect-ratio",
1.0);
double zNear = projectionNode->getDoubleValue("near", 0.0);
- double zFar = projectionNode->getDoubleValue("far", 0.0);
+ double zFar = projectionNode->getDoubleValue("far", zNear + 20000);
double offsetX = projectionNode->getDoubleValue("offset-x", 0.0);
double offsetY = projectionNode->getDoubleValue("offset-y", 0.0);
double tan_fovy = tan(DegreesToRadians(fovy*0.5));
double bottom = -tan_fovy * zNear + offsetY;
pOff.makeFrustum(left, right, bottom, top, zNear, zFar);
cameraFlags |= PROJECTION_ABSOLUTE;
+ if (projectionNode->getBoolValue("fixed-near-far", true))
+ cameraFlags |= FIXED_NEAR_FAR;
} else if ((projectionNode = cameraNode->getNode("frustum")) != 0
|| (projectionNode = cameraNode->getNode("ortho")) != 0) {
double top = projectionNode->getDoubleValue("top", 0.0);
double left = projectionNode->getDoubleValue("left", 0.0);
double right = projectionNode->getDoubleValue("right", 0.0);
double zNear = projectionNode->getDoubleValue("near", 0.0);
- double zFar = projectionNode->getDoubleValue("far", 0.0);
+ double zFar = projectionNode->getDoubleValue("far", zNear + 20000);
if (cameraNode->getNode("frustum")) {
pOff.makeFrustum(left, right, bottom, top, zNear, zFar);
cameraFlags |= PROJECTION_ABSOLUTE;
pOff.makeOrtho(left, right, bottom, top, zNear, zFar);
cameraFlags |= (PROJECTION_ABSOLUTE | ORTHO);
}
+ if (projectionNode->getBoolValue("fixed-near-far", true))
+ cameraFlags |= FIXED_NEAR_FAR;
} else {
// old style shear parameters
double shearx = cameraNode->getDoubleValue("shear-x", 0);
PROJECTION_ABSOLUTE = 0x2, /**< The projection is absolute. */
ORTHO = 0x4, /**< The projection is orthographic */
GUI = 0x8, /**< Camera draws the GUI. */
- DO_INTERSECTION_TEST = 0x10 /**< scene intersection tests this
+ DO_INTERSECTION_TEST = 0x10,/**< scene intersection tests this
camera. */
+ FIXED_NEAR_FAR = 0x20 /**< take the near far values in the
+ projection for real. */
};
/** Create a camera group associated with an osgViewer::Viewer.
* @param viewer the viewer