Skip to main content
Up and Coming
May 11, 2014

SharpOVR 0.4.2 NuGet Update

I've released a NuGet package called SharpOVR, it's a .NET API for the Oculus Rift. It is based on SDK 0.4.x and wraps most of the functionality provided by the SDK. It only supports SDK Rendering at the moment (no Client Distortion Rendering). It has a dependency on SharpDX for the Matrix, ViewportF, Vector and Point classes.
https://www.nuget.org/packages/SharpOVR/

Here's how to use it:

OVR.Initialize();
using (HMD hmd = OVR.HmdCreate(0))
{
// Configure rendering, configure tracking, BeginFrame, EndFrame, etc
}
OVR.Shutdown();

It targets the "Any CPU" platform as the assembly embeds both Win32/x64 unmanaged dlls and loads the appropriate one at runtime. In other words, just add the NuGet package to your project and you're good to go.

I've created a sample SharpDX game project (shown below) that can help you get started.
SharpOVR Sample



Let me know if you have any questions/suggestions.

Guy

    51 replies

    guygodinAuthor
    Up and Coming
    August 5, 2014
    I would recommend creating a different wrapper entirely for OpenGL since SharpOVR is based on SharpDX and uses a lot of the basic types provided (Vector3, Matrix, Quaternion, etc.). I'm not a fan of defines, especially in .NET since libraries are distributed as DLLs.
    Virtual Desktop Developer
    New Participant
    August 8, 2014
    Hi,
    This looks great!
    My c# dx engine (if you can call it that) uses SlimDX rather than SharpDX.
    Do you think it would be fairly trivial for me to convert it to use SlimDX?

    Cheers.
    New Participant
    August 11, 2014
    Works really well with DK2!

    This may be a trivial question, but does anyone know how to get rotations about the X, Y, and Z axis' with SharpOVR?
    guygodinAuthor
    Up and Coming
    August 11, 2014
    I've put an extension method for the Quaternion in SharpOVR called GetEulerAngles(). You can get the rotation with something like

    float yaw, pitch, roll;
    hmd.GetEyePose(0).Orientation.GetEulerAngles(out yaw, out pitch, out roll);
    Virtual Desktop Developer
    New Participant
    August 11, 2014
    Thank you for the quick reply Guy.

    Perhaps you could help me a little further? I'm just trying to get up and running, but I am unable to get a reading with the following:
    static void Main()
    {
    OVR.Initialize();
    using (HMD hmd = OVR.HmdCreate(0))
    {
    while(!Console.KeyAvailable)
    {
    Console.Clear();
    float yaw, pitch, roll;
    hmd.GetEyePose(0).Orientation.GetEulerAngles(out yaw, out pitch, out roll);
    Console.WriteLine("Yaw: {0} Pitch: {1} Roll: {2}", yaw, pitch, roll);
    Thread.Sleep(33);
    }
    }

    OVR.Shutdown();

    }


    It's always 0. I've noticed that blue led does not come on when I run. The SharpOVR RiftGame works fine.
    guygodinAuthor
    Up and Coming
    August 12, 2014
    You need to call ConfigureTracking() to start the sensors. Add the following line before your while loop:

    hmd.ConfigureTracking(TrackingCapabilities.Orientation | TrackingCapabilities.Position | TrackingCapabilities.MagYawCorrection, TrackingCapabilities.None);
    Virtual Desktop Developer
    New Participant
    August 12, 2014
    Guy, you're awesome. Thank you!
    guygodinAuthor
    Up and Coming
    August 12, 2014
    SharpOVR has been updated to 0.4.1. Not many changes to the API itself, only a new InitializeRenderingShim() method if you use DirectToRift mode.

    I've corrected the weird issues where some axis / positions had to be inverted. There are new extension methods to properly mimic the various matrix and vector transformations done in the SDK. Have a look at the updated SharpOVR Sample.
    Virtual Desktop Developer
    New Participant
    August 17, 2014
    Hey,
    thanks for the work, it's amazing.
    I tried to load my own fbx model into your sample but it gets completely messed up. I just see some random flickering 'triangle star thing'. I think it's a sharpDX issue but can you give me a small hint on what could be wrong? I've never used sharpDX, just some XNA. :)

    Solved: (but still strange)
    https://github.com/sharpdx/SharpDX/issues/88
    New Participant
    August 27, 2014
    First off: Thanks for making and contributing SharpOVR it is really awesome.
    I am currently playing with SharpDX rendering and I have a few questions about your library.

    1. The only license I can find is the Oculus LibOVR license, how do you plan to license SharpOVR and are you planning on releasing the source?

    2. The current nuget release is bound to the signed 2.6 desktop/d3d11.2 sharpdx dlls. Is there some reason for this tight binding? Are you planning on releasing alternate versions for each version/build variation of sharpdx?

    3. The MatrixOrthoSubProjection method produces non-aligning results across the eyes when rendering sprites. I am not sure which one is right as the sprites are visible in both eyes, but in very different positions. Am I missing something (like a specific value for an eye-specific parameter) with the usage of this method? Or do I have to have to perform additional steps beyond applying the projection to get correct ortho rendering?

    Thanks again for your work on this.