X-Git-Url: http://git.tdb.fi/?p=libs%2Fvr.git;a=blobdiff_plain;f=source%2Fstereocombiner.cpp;h=75c788997e770fa0f1a7340d03b578e969062d51;hp=a276c3bc3c677ad2ba24f49df1b435e572842156;hb=c7e4d2226f16c8dfd9136eaa298fb0e6937ef125;hpb=268da92f49360feaf9445ed2b8264d9310d3cebe diff --git a/source/stereocombiner.cpp b/source/stereocombiner.cpp index a276c3b..75c7889 100644 --- a/source/stereocombiner.cpp +++ b/source/stereocombiner.cpp @@ -1,15 +1,44 @@ +#include #include "stereocombiner.h" +using namespace std; + namespace Msp { namespace VR { StereoCombiner::StereoCombiner(): - width_div(1), - height_div(1), - keep_aspect(false), - oversize(1.0f), + target_width(0), + target_height(0), + render_aspect(1.0f), frustum_skew(0.0f) { } +void StereoCombiner::configure_eye_frustums(const Frustum &left_frustum, const Frustum &right_frustum) +{ + float vertical = max(max(left_frustum.top, -left_frustum.bottom), max(right_frustum.top, -right_frustum.bottom)); + fov = Geometry::atan(vertical)*2.0f; + + float inner = max(left_frustum.right, -right_frustum.left); + float outer = max(-left_frustum.left, right_frustum.right); + frustum_skew = (inner-outer)/(inner+outer); + + render_aspect = (inner+outer)/(vertical*2); +} + + +StereoCombiner::Frustum::Frustum(): + left(-1), + right(1), + bottom(-1), + top(1) +{ } + +StereoCombiner::Frustum::Frustum(float l, float r, float b, float t): + left(l), + right(r), + bottom(b), + top(t) +{ } + } // namespace VR } // namespace Msp