Functions from OVR_Math.h

Feb 2, 2015 at 7:22 PM
Edited Feb 2, 2015 at 7:27 PM
Hey so in working on this OpenGL example, there's a bunch of Quarternion, Matrix4 and Vector3 maths that would be highly convenient to bring over to OculusWrap.

In particular I'm looking at Federico Mammano's OpenGL conversion of OculusRoomTiny for reference.

The particular block I'm looking at is within the eye render passes.
Matrix4f rollPitchYaw       = Matrix4f::RotationY(Yaw);
Matrix4f finalRollPitchYaw  = rollPitchYaw * Matrix4f(useEyePose->Orientation);
Vector3f finalUp            = finalRollPitchYaw.Transform(Vector3f(0, 1, 0));
Vector3f finalForward       = finalRollPitchYaw.Transform(Vector3f(0, 0, -1));
Vector3f shiftedEyePos      = Pos + rollPitchYaw.Transform(useEyePose->Position);

Matrix4f view = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + finalForward, finalUp);
Matrix4f proj = ovrMatrix4f_Projection(EyeRenderDesc[eye].Fov, 0.2f, 1000.0f, true); 
Did you have any thoughts about how these methods can be added to the wrapper? I'm no C# expert, so I'm not at all sure how C++ templates make their way across. Perhaps a maths utility class to embody this? I'm not sure if you can mix structs and classes easily to make the operator overloading as pleasant on the C# side.
Feb 2, 2015 at 8:41 PM
Edited Feb 2, 2015 at 8:52 PM
The other thing that crossed my mind was to have a thin integration layer to something like glmnet

or this part of XnaGeometry:
Feb 3, 2015 at 3:54 PM
Building wrapper code for math primitives isn't a good idea, because the overhead of calling native code, from managed code, is too big to provide a decent performance.

SharpDX provides a set of math primitives for vector, matrix and quaternion operations, for DirectX code in .NET. I'm sure that whatever OpenGL library exists for .NET will also have math primitives built in, but unfortunately I don't have any experience writing OpenGL code for .NET, so I can't provide any advice on how to do that.

A quick Google search led me to The Open Toolkit Library, which is an OpenGL implementation for .NET. This library also seems to provide the math primitives you would need to interact with OpenGL. It should be a small task to convert from the vector, quaternion and matrix primitives, provided by OculusWrap, into the similar primitives for OpenTK.
Marked as answer by MortInfinite on 3/21/2015 at 11:52 PM