diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2013-04-19 03:34:32 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2013-04-19 03:34:32 +0400 |
commit | 43998d6a383f6d6a8ae31ed8533235c226deda3f (patch) | |
tree | 47597e75effc961d8955f26dd554babb5d6afbf2 /source/gameengine/Rasterizer | |
parent | c846e3c750576891d3d09ad12e78e699dc91f4fe (diff) |
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
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r-- | source/gameengine/Rasterizer/RAS_FramingManager.cpp | 92 |
1 files changed, 66 insertions, 26 deletions
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index 53d9b64ab0e..d1a801c52f8 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -257,19 +257,39 @@ ComputeFrustum( case RAS_FrameSettings::e_frame_extend: { - RAS_Rect vt; - ComputeBestFitViewRect( - availableViewport, - design_aspect_ratio, - vt - ); - - // now scale the calculated frustum by the difference - // between vt and the viewport in each axis. - // These are always > 1 - - float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); - float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + float x_scale, y_scale; + switch (sensor_fit) { + case RAS_SENSORFIT_HOR: + { + 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 + // between vt and the viewport in each axis. + // These are always > 1 + + x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); + y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + break; + } + } frustum.x1 *= x_scale; frustum.x2 *= x_scale; @@ -327,19 +347,39 @@ RAS_FramingManager:: case RAS_FrameSettings::e_frame_extend: { - RAS_Rect vt; - ComputeBestFitViewRect( - availableViewport, - design_aspect_ratio, - vt - ); - - // now scale the calculated frustum by the difference - // between vt and the viewport in each axis. - // These are always > 1 - - float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); - float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + float x_scale, y_scale; + switch (sensor_fit) { + case RAS_SENSORFIT_HOR: + { + 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 + // between vt and the viewport in each axis. + // These are always > 1 + + x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); + y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); + break; + } + } frustum.x1 *= x_scale; frustum.x2 *= x_scale; |