diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-04 18:36:06 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-04 18:36:06 +0400 |
commit | 4ea816837de646af124ffc82758cae37950a0a51 (patch) | |
tree | 771c7a0e084446080d6f6d12258585a479bf2887 /source/gameengine/Rasterizer/RAS_FramingManager.cpp | |
parent | 82dc05391cdda573f1523325bfd4c6a2a5233323 (diff) |
Configurable sensor size:
- Added support of variable size sensor width and height.
- Added presets for most common cameras, also new presets can be defined by user.
- Added option to control which dimension (vertical or horizontal) of sensor
size defines FOV. Old behavior of automatic FOV calculation is also kept.
- Renderer, viewport, game engine and collada importer/exporter should
deal fine with this changes. Other exporters would be updated soon.
Diffstat (limited to 'source/gameengine/Rasterizer/RAS_FramingManager.cpp')
-rw-r--r-- | source/gameengine/Rasterizer/RAS_FramingManager.cpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index da6c230ffc1..8a5c10b3a3b 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -39,25 +39,35 @@ ComputeDefaultFrustum( const float camnear, const float camfar, const float lens, + const float sensor_x, const float sensor_y, + const short sensor_fit, const float design_aspect_ratio, RAS_FrameFrustum & frustum -){ - - /* - * Magic Blender calculation. - * Blender does not give a Field of View as lens but a size - * at 16 units away from the lens. - */ - float halfSize = 16.f * camnear / lens; +){ + float halfSize; float sizeX; float sizeY; - if (design_aspect_ratio > 1.f) { - // halfsize defines the width + if(sensor_fit==RAS_SENSORFIT_AUTO) { + halfSize = (sensor_x / 2.f) * camnear / lens; + + if (design_aspect_ratio > 1.f) { + // halfsize defines the width + sizeX = halfSize; + sizeY = halfSize/design_aspect_ratio; + } else { + // halfsize defines the height + sizeX = halfSize * design_aspect_ratio; + sizeY = halfSize; + } + } + else if(sensor_fit==RAS_SENSORFIT_HOR) { + halfSize = (sensor_x / 2.f) * camnear / lens; sizeX = halfSize; sizeY = halfSize/design_aspect_ratio; - } else { - // halfsize defines the height + } + else { + halfSize = (sensor_y / 2.f) * camnear / lens; sizeX = halfSize * design_aspect_ratio; sizeY = halfSize; } @@ -77,6 +87,7 @@ ComputeDefaultOrtho( const float camfar, const float scale, const float design_aspect_ratio, + const short sensor_fit, RAS_FrameFrustum & frustum ) { @@ -84,12 +95,22 @@ ComputeDefaultOrtho( float sizeX; float sizeY; - if (design_aspect_ratio > 1.f) { - // halfsize defines the width + if(sensor_fit==RAS_SENSORFIT_AUTO) { + if (design_aspect_ratio > 1.f) { + // halfsize defines the width + sizeX = halfSize; + sizeY = halfSize/design_aspect_ratio; + } else { + // halfsize defines the height + sizeX = halfSize * design_aspect_ratio; + sizeY = halfSize; + } + } + else if(sensor_fit==RAS_SENSORFIT_HOR) { sizeX = halfSize; sizeY = halfSize/design_aspect_ratio; - } else { - // halfsize defines the height + } + else { sizeX = halfSize * design_aspect_ratio; sizeY = halfSize; } @@ -199,6 +220,7 @@ ComputeFrustum( const RAS_Rect &availableViewport, const RAS_Rect &viewport, const float lens, + const float sensor_x, const float sensor_y, const short sensor_fit, const float camnear, const float camfar, RAS_FrameFrustum &frustum @@ -224,6 +246,9 @@ ComputeFrustum( camnear, camfar, lens, + sensor_x, + sensor_y, + sensor_fit, design_aspect_ratio, frustum ); @@ -269,6 +294,7 @@ RAS_FramingManager:: const float scale, const float camnear, const float camfar, + const short sensor_fit, RAS_FrameFrustum &frustum ) { @@ -293,6 +319,7 @@ RAS_FramingManager:: camfar, scale, design_aspect_ratio, + sensor_fit, frustum ); |