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
    July 24, 2014
    This is an internal exception that is raised by the managed debugging assistant in Visual Studio. Just turn it off by going to Debug->Exceptions->Managed Debugging Assistants->PInvoke Stack Imbalance (make sure the thrown column is unchecked)

    Thanks for pointing the issue with the RiftGame project, I'll make sure to update it correctly with the next SDK.
    Virtual Desktop Developer
    guygodinAuthor
    Up and Coming
    July 27, 2014
    I've added support for the 0.4.0 SDK which relies on the new Oculus Runtime. I've also eliminated the Stack Imbalance exceptions and added a little more documentation. The sample is also using version 0.4.0 and the solution should properly restore NuGet packages when first downloaded.
    Virtual Desktop Developer
    Participant
    August 1, 2014
    "conniey" wrote:

    Here are the steps:

    • Open RiftGame.csproj in VS.

    • Press Ctrl+S to save RiftGame.sln in the same directory as RiftGame.csproj

    • Right-click on "Solution 'Rift Game' (1 project)" then select "Enable Package Restore..."

    • Right-click on the project, RiftGame.csproj and "Unload Project"

    • Right-click on the unloaded project and select "Edit RiftGame.csproj"

    • Ctrl+H and replace "..\packages" with "packages"

    • Save the file.

    • Right-click on RiftGame.csproj and "Reload Project"

    • Build solution.



    My .csproj file had numerous paths like \..\..\..\packages.

    Doing a single ctrl-h didn't work for me. I had to get rid of all the slashes and dots, making the path just 'packages'.

    Hope this helps someone.
    guygodinAuthor
    Up and Coming
    August 1, 2014
    I updated the sample to have a solution file with proper NuGet references, did you try the latest?
    Virtual Desktop Developer
    Participant
    August 1, 2014
    Hi,

    Yes, I downloaded it yesterday. Here is the url that I downloaded it from: https://onedrive.live.com/?cid=8ae5a4e24a2f8960&id=8AE5A4E24A2F8960%21149320&ithint=file,.zip&authkey=!AFOLyLvcnSgLcqk

    I looked in the csproj file and noticed that there are still some paths such as this:

    <Error Condition="!Exists('..\..\..\packages\SharpDX.2.6.2\build\SharpDX.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\SharpDX.2.6.2\build\SharpDX.targets'))" />

    What I had done is replace "..\..\..\packages" with just "packages". That worked for me. Am I right in understanding that this shouldn't be necessary?

    Also, I'm using VS 2013 (don't know if that matters), and when first opening the solution it complains that it can't find the TFS server (again I don't know if that makes any difference).

    Thanks again! Really nice work, by the way.

    Aaron
    guygodinAuthor
    Up and Coming
    August 2, 2014
    Thanks Aaron, I've just fixed the wrong references and removed the source control (TFS) binding oops!
    Virtual Desktop Developer
    Up and Coming
    August 2, 2014
    Hey there,

    Great work on this, it looks easy to use. Even works in direct mode!

    The only problem I've had is that the head tracking doesn't seem to be working. The orientation works, but translation doesn't. I spit out the left eye position every frame, and it does seem to be reading it correctly from the Rift, but somehow it's getting lost in... er, translation.
    guygodinAuthor
    Up and Coming
    August 2, 2014
    Ah I don't have a DK2 to test the translations unfortunately :cry: I've added modifiers to the translation with the last version, let me know if that fixes it Entroper!
    Virtual Desktop Developer
    Up and Coming
    August 2, 2014
    EDIT: Scratch that, it's working in the new version. The model was just a lot bigger than I realized. When I slowed the rotation down, I could see that my position was actually translating.
    Participant
    August 3, 2014
    I already use it and its pretty nice. Also I really like the demo!

    It's just a shame that it references SharpDX and does not include any of the OpenGL stuff. I kind of had to hack that into there, using reflection to get the private __hmd field.

    My suggestion would be to split this in to a few libraries
    SharpOVR(core)
    SharpOVR.DirectX
    SharpOVR.OpenGL


    So that mac and linux users can also use it without DirectX. Or maybe something can be done with defines.

    I already made most of the code for OpenGL so if you are open to the idea, I'd be happy to make a SharpOVR.OpenGL project.