]> git.tdb.fi Git - libs/vr.git/blobdiff - source/stereocombiner.cpp
Require mspcore since symbols from it are used
[libs/vr.git] / source / stereocombiner.cpp
index 27cbb8f7edd4edad0fc8dc14a7be666eeb44c78c..75c788997e770fa0f1a7340d03b578e969062d51 100644 (file)
@@ -1,14 +1,44 @@
+#include <algorithm>
 #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<float>(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