Skip to main content
Up and Coming
June 8, 2013

Minimal C# wrapper

Hi,
To start, there is a very complete and beautifully written C# wrapper available at https://github.com/SiS-Shadowman/RiftDotNet written by SiSShadowman.

Since I just needed the HMD orientation and didn't want the dependency towards SharpDx, I created a minimal C++ dll and C# assembly. It just fetches the HMD orientation.

You can get the code (or contribute :)) at:
https://github.com/davyloots/riftsharp

I didn't include the actual LibOVR code project from the Oculus SDK because I'm not sure about the licensing, so you'll need to import that lib project before compiling.

If you just want to use it, here's a compiled version:
http://rcdeskpilot.com/system/files/RiftSharp.zip

The RiftSharpDll.dll is the C++ dll, RiftSharp.dll is the wrapper assembly. Just add a reference to that last one and copy the C++ dll to your binary folder.
Code use is as folows:


using RiftSharp;

//.....
YawPitchRoll ypr = Hmd.Instance.YawPitchRoll;
float yaw=ypr.Yaw;


This is just a quick implementation, not even error handling is present. I'm not a very competent coder and my C++ is very rusty, so use at your own risk ;) .

    8 replies

    Participant
    July 29, 2013
    Thanks for this great start point...

    I added a few methods...like GetHmdInfo, integrated a bit of mag calibration and added ovr util to get eye render params and distortion scale....

    oh and compiled it as 64bit....

    hope it helps someone else out there starting the rift process ;-)

    attached rar contains h cpp and compiled 64bit dll


    Rudi
    dalootsAuthor
    Up and Coming
    August 3, 2013
    Thanks Rudi!

    If you could push your modifications to Github that would be awesome.
    True 3D video for VR: http://q3d.quaternionsoftware.com
    New Participant
    October 4, 2013
    aahh, what a relief, i had the same problem with that directx bindings ;)
    this way i can continue my little test :D
    haha, happy codin'!
    Up and Coming
    October 15, 2013
    Hi,

    Thanks for the effort, sounds like I give this one a try!

    Is it possible to add the methods to transform a given image for display in the Rift? Or is it already in there somewhere?

    Cheers!
    dalootsAuthor
    Up and Coming
    October 16, 2013
    Hi psychophysics,

    The image distortion function is not included because I didn't want to insert a dependency on any (graphics) library. The way to do the distortion differs slightly whether you use DirectX, OpenGL, XNA, WPF, ...
    If you're seeking help with that I suggest posing the question but include what graphics library you're using.

    Cheers.
    True 3D video for VR: http://q3d.quaternionsoftware.com
    Participant
    November 12, 2013
    Is it possible to write your app completely in c# as the samples are in C++

    I wanted to post a topic about what programming language to use but as a new person I cant

    Trying to decide as an iOS dev what to write my game in.
    dalootsAuthor
    Up and Coming
    November 12, 2013
    Hi Burf2000,
    Yes, it's possible to write your app completely in C#. You can use this wrapper for the tracker orientation and e.g. XNA or managed DirectX for the visuals. Or the RiftDotNet wrapper with SharpDX for visuals.
    But if it's a game you're writing I would consider looking at Unity3D. You can code in C# in Unity, and compile for a bunch of platforms. It will also save you the pain of writing your own game engine.
    Cheers.
    True 3D video for VR: http://q3d.quaternionsoftware.com
    Participant
    November 12, 2013
    I know the sensible approach would be unity, and I must give it a look.

    I cant see me ever releasing this except as sample code.

    I am tempted to do it in Objective C and OpenGL but that does not really excite me. I have already written my own 3D test environments for Android and iOS in OpenGL.

    If I want to play with C# it looks like SharpDx or Sunburn framework seem to be the way to go for something new.

    To use SharpDx do I need your wrapper and the RiftDotNet one? Has anyone got a template / example for SharpDX and the rift?