aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Kernel/OVR_Math.cpp
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-04-14 21:25:09 -0700
committerBrad Davis <[email protected]>2014-04-14 21:25:09 -0700
commit07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (patch)
tree1854d0c690eff32e77b137567c88a52d56d8b660 /LibOVR/Src/Kernel/OVR_Math.cpp
parentf28388ff2af14b56ef2d973b2f4f9da021716d4c (diff)
Adding windows 0.3.1 SDK
Diffstat (limited to 'LibOVR/Src/Kernel/OVR_Math.cpp')
-rw-r--r--LibOVR/Src/Kernel/OVR_Math.cpp99
1 files changed, 18 insertions, 81 deletions
diff --git a/LibOVR/Src/Kernel/OVR_Math.cpp b/LibOVR/Src/Kernel/OVR_Math.cpp
index e5a1f0e..396d3ff 100644
--- a/LibOVR/Src/Kernel/OVR_Math.cpp
+++ b/LibOVR/Src/Kernel/OVR_Math.cpp
@@ -5,16 +5,16 @@ Content : Implementation of 3D primitives such as vectors, matrices.
Created : September 4, 2012
Authors : Andrew Reisse, Michael Antonov, Anna Yershova
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-Licensed under the Oculus VR SDK License Version 2.0 (the "License");
-you may not use the Oculus VR SDK except in compliance with the License,
+Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-2.0
+http://www.oculusvr.com/licenses/LICENSE-3.1
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -72,83 +72,20 @@ const double Math<double>::SingularityRadius = 0.000000000001; // Use for Gimbal
//-------------------------------------------------------------------------------------
-// ***** Matrix4f
-
-
-Matrix4f Matrix4f::LookAtRH(const Vector3f& eye, const Vector3f& at, const Vector3f& up)
-{
- Vector3f z = (eye - at).Normalized(); // Forward
- Vector3f x = up.Cross(z).Normalized(); // Right
- Vector3f y = z.Cross(x);
-
- Matrix4f m(x.x, x.y, x.z, -(x.Dot(eye)),
- y.x, y.y, y.z, -(y.Dot(eye)),
- z.x, z.y, z.z, -(z.Dot(eye)),
- 0, 0, 0, 1 );
- return m;
-}
-
-Matrix4f Matrix4f::LookAtLH(const Vector3f& eye, const Vector3f& at, const Vector3f& up)
-{
- Vector3f z = (at - eye).Normalized(); // Forward
- Vector3f x = up.Cross(z).Normalized(); // Right
- Vector3f y = z.Cross(x);
-
- Matrix4f m(x.x, x.y, x.z, -(x.Dot(eye)),
- y.x, y.y, y.z, -(y.Dot(eye)),
- z.x, z.y, z.z, -(z.Dot(eye)),
- 0, 0, 0, 1 );
- return m;
-}
-
-
-Matrix4f Matrix4f::PerspectiveLH(float yfov, float aspect, float znear, float zfar)
-{
- Matrix4f m;
- float tanHalfFov = tan(yfov * 0.5f);
-
- m.M[0][0] = 1.0f / (aspect * tanHalfFov);
- m.M[1][1] = 1.0f / tanHalfFov;
- m.M[2][2] = zfar / (zfar - znear);
- m.M[3][2] = 1.0f;
- m.M[2][3] = (zfar * znear) / (znear - zfar);
- m.M[3][3] = 0.0f;
-
- // Note: Post-projection matrix result assumes Left-Handed coordinate system,
- // with Y up, X right and Z forward. This supports positive z-buffer values.
- return m;
-}
-
-
-Matrix4f Matrix4f::PerspectiveRH(float yfov, float aspect, float znear, float zfar)
-{
- Matrix4f m;
- float tanHalfFov = tan(yfov * 0.5f);
-
- m.M[0][0] = 1.0f / (aspect * tanHalfFov);
- m.M[1][1] = 1.0f / tanHalfFov;
- m.M[2][2] = zfar / (znear - zfar);
- // m.M[2][2] = zfar / (zfar - znear);
- m.M[3][2] = -1.0f;
- m.M[2][3] = (zfar * znear) / (znear - zfar);
- m.M[3][3] = 0.0f;
-
- // Note: Post-projection matrix result assumes Left-Handed coordinate system,
- // with Y up, X right and Z forward. This supports positive z-buffer values.
- // This is the case even for RHS cooridnate input.
- return m;
-}
-
-Matrix4f Matrix4f::Ortho2D(float w, float h)
-{
- Matrix4f m;
- m.M[0][0] = 2.0f/w;
- m.M[1][1] = -2.0f/h;
- m.M[0][3] = -1.0;
- m.M[1][3] = 1.0;
- m.M[2][2] = 0;
- return m;
-}
+// ***** Matrix4
+
+template<>
+const Matrix4<float> Matrix4<float>::IdentityValue = Matrix4<float>(1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f);
+
+template<>
+const Matrix4<double> Matrix4<double>::IdentityValue = Matrix4<double>(1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+
} // Namespace OVR