BGE: Extend Framing Mode + Camera sensor

If the "Framing" mode is set to extend,
the camera frustrum changes when you
resizes the blenderplayer window.

Before this patch, there were no way to
control which part of the framing you want
to extend (vertical, horizontal or arbritary).

Now:
If the camera sensor fit is set to HORIZONTAL,
the horizontal field of view doesn't change.
If set to VERTICAL, the vertical fov doesn't change.

If set to AUTO the old behaviour takes place, arbitrarly
showing more of the horizontal or vertical field of view
depending on the aspect ratio of the window.

Test file:
https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests/gameengine/framing_extend.blend

Bugfix supported by NF-UBC Nereus Program as part of the development
of OceanViz/NereusViz
This commit is contained in:
Dalai Felinto 2013-04-18 23:34:32 +00:00
parent c846e3c750
commit 43998d6a38

@ -257,19 +257,39 @@ ComputeFrustum(
case RAS_FrameSettings::e_frame_extend: case RAS_FrameSettings::e_frame_extend:
{ {
RAS_Rect vt; float x_scale, y_scale;
ComputeBestFitViewRect( switch (sensor_fit) {
availableViewport, case RAS_SENSORFIT_HOR:
design_aspect_ratio, {
vt x_scale = 1.0;
); y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth());
break;
}
case RAS_SENSORFIT_VERT:
{
x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight());
y_scale = 1.0;
break;
}
case RAS_SENSORFIT_AUTO:
default:
{
RAS_Rect vt;
ComputeBestFitViewRect(
availableViewport,
design_aspect_ratio,
vt
);
// now scale the calculated frustum by the difference // now scale the calculated frustum by the difference
// between vt and the viewport in each axis. // between vt and the viewport in each axis.
// These are always > 1 // These are always > 1
float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
break;
}
}
frustum.x1 *= x_scale; frustum.x1 *= x_scale;
frustum.x2 *= x_scale; frustum.x2 *= x_scale;
@ -327,19 +347,39 @@ RAS_FramingManager::
case RAS_FrameSettings::e_frame_extend: case RAS_FrameSettings::e_frame_extend:
{ {
RAS_Rect vt; float x_scale, y_scale;
ComputeBestFitViewRect( switch (sensor_fit) {
availableViewport, case RAS_SENSORFIT_HOR:
design_aspect_ratio, {
vt x_scale = 1.0;
); y_scale = float(viewport.GetHeight()) / float(viewport.GetWidth());
break;
}
case RAS_SENSORFIT_VERT:
{
x_scale = float(viewport.GetWidth()) / float(viewport.GetHeight());
y_scale = 1.0;
break;
}
case RAS_SENSORFIT_AUTO:
default:
{
RAS_Rect vt;
ComputeBestFitViewRect(
availableViewport,
design_aspect_ratio,
vt
);
// now scale the calculated frustum by the difference // now scale the calculated frustum by the difference
// between vt and the viewport in each axis. // between vt and the viewport in each axis.
// These are always > 1 // These are always > 1
float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); x_scale = float(viewport.GetWidth())/float(vt.GetWidth());
float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); y_scale = float(viewport.GetHeight())/float(vt.GetHeight());
break;
}
}
frustum.x1 *= x_scale; frustum.x1 *= x_scale;
frustum.x2 *= x_scale; frustum.x2 *= x_scale;