New ajustAspectRatio (ADJUST_NODE) mode added to osg::Camera to fix issue

with integration with vrjuggler, submitted by Allen Bierbaum.
This commit is contained in:
Robert Osfield 2002-01-15 11:05:00 +00:00
parent 686b1abc83
commit 87763acc03
2 changed files with 15 additions and 12 deletions

View File

@ -80,7 +80,8 @@ class SG_EXPORT Camera: public osg::Referenced
enum AdjustAspectRatioMode
{
ADJUST_VERTICAL,
ADJUST_HORIZONTAL
ADJUST_HORIZONTAL,
ADJUST_NONE
};
/** Set the way that the vertical or horizontal dimensions of the window

View File

@ -163,7 +163,6 @@ void Camera::setFrustum(const double left, const double right,
_top = top/zNear;
_zNear = zNear;
_zFar = zFar;
_dirty = true;
}
@ -240,17 +239,20 @@ void Camera::adjustAspectRatio(const double newAspectRatio, const AdjustAspectRa
return;
}
double previousAspectRatio = (_right-_left)/(_top-_bottom);
double deltaRatio = newAspectRatio/previousAspectRatio;
if (aa == ADJUST_HORIZONTAL)
if(aa != ADJUST_NONE) // If adjustment todo
{
_left *= deltaRatio;
_right *= deltaRatio;
}
else // aa == ADJUST_VERTICAL
{
_bottom /= deltaRatio;
_top /= deltaRatio;
double previousAspectRatio = (_right-_left)/(_top-_bottom);
double deltaRatio = newAspectRatio/previousAspectRatio;
if (aa == ADJUST_HORIZONTAL)
{
_left *= deltaRatio;
_right *= deltaRatio;
}
else // aa == ADJUST_VERTICAL
{
_bottom /= deltaRatio;
_top /= deltaRatio;
}
}
_dirty = true;