X-Git-Url: http://git.tdb.fi/?p=libs%2Fvr.git;a=blobdiff_plain;f=source%2Fstereocombiner.cpp;h=75c788997e770fa0f1a7340d03b578e969062d51;hp=27cbb8f7edd4edad0fc8dc14a7be666eeb44c78c;hb=c7e4d2226f16c8dfd9136eaa298fb0e6937ef125;hpb=43579020c5709b589b2404414c489b0e6be3227d diff --git a/source/stereocombiner.cpp b/source/stereocombiner.cpp index 27cbb8f..75c7889 100644 --- a/source/stereocombiner.cpp +++ b/source/stereocombiner.cpp @@ -1,14 +1,44 @@ +#include #include "stereocombiner.h" +using namespace std; + namespace Msp { -namespace GL { +namespace VR { StereoCombiner::StereoCombiner(): - width_div(1), - height_div(1), - keep_aspect(false), - fov(0) + 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 GL +} // namespace VR } // namespace Msp