OpenVR Available, Convert?

Sorry, VR is low in my TODO list. But @jherico seems to continue to work on it.

Big news, @rickard & @jherico!

I ran OpenVR through JNAerator, targeting BridJ (which supposedly is faster & has better C++ support), creating a Java API:

https://github.com/phr00t/jmonkeyengine-virtual-reality/tree/master/src/openvr_api

I went a bit farther than jherico ā€“ I made sure to embed all of the OpenVR libraries, so this should already start working for all operating systems:

https://github.com/phr00t/jmonkeyengine-virtual-reality/tree/master/src/lib

I added a new VRHMD object for OpenVR to the jMonkeyEngine Virtual Reality library:

I already tested the VR_Initialize() function, which currently returns 110. 110 means the OpenVR runtime isnā€™t installed (which it isnā€™t on my machine, yet). Good news is ā€“ that is an expected result! Looks like we will get to integrating this sooner than expected. Next step will be to install the OpenVR runtime & start figuring out how to integrate rendering. I forsee the traditional Oculus Rift VRHMD object become obsolete and deprecated.

6 Likes

After installing SteamVR (start the Steam client, go to Library ā†’ Tools, right click SteamVR & go to Install) & running the library, I now get this error:

HmdError_Init_HmdNotFound (108) - Either no HMD was attached to the system or the HMD could not be initialized.

ā€¦ which is also expected, since I donā€™t have one plugged in! My Rift ironically isnā€™t hooked up to my primary development machine, so Iā€™m hoping there is a way we can test/implement much of the functionality without an actual HMD connected (like we were able to do with the Rift).

1 Like

Small update to display any errors in English during initialization:

https://github.com/phr00t/jmonkeyengine-virtual-reality/commit/2db6467c269d3151f021ddc8e49b595ca57aa0d4

@rickard, do you want to look this library over & perhaps start contributing rendering integration? It looks like this is what we need to call to get pose information:

Dealing with Pointers in Java with BridJ is a little funky, but it seems to be working. It might get a bit more complicated with more complex object types, though.

Iā€™ll try to, this weekend.
Most likely Iā€™ll use your classes and try to build a minimum viable test based on the official example to confirm that my expectations on how it works are correct. Then we can see how to get it into the current architecture.
From skimming through the example, it seems itā€™s much more direct than the oculus implementation, more akin to how cardboard works (supplying the matrix transforms for each eye directly).

1 Like

OK, sounds good. Iā€™d much prefer you handle this, since you have more experience in this area. Hopefully most of the code can go inside the OpenVR.java implemented interface. However, Iā€™m sure there are places among the library where changes will be needed too (like where you see ā€œVRhardware instanceof OculusRiftā€ will probably need corresponding ā€œVRhardware instanceof OpenVRā€ sections). Ultimately, we are probably going to remove the Oculus Rift stuff (since it is already obsolete, and going to be even more obsolete when the big v0.6 SDK changes come).

Status update, which will be important for you @rickard:

I cleaned up the BridJ interface so it is easier to read & understand. The ā€œPointerā€ interface is much easier to use if you donā€™t specify what kind of pointer it is (e.g. just leave ā€œPointerā€ instead of ā€œPointer{IVRSystem}ā€).

I also noticed there might be some instances where BridJ thought an argument was a Pointer, but isnā€™t. vRGetStringForHmdError, for example, wants just the long value ā€“ not a pointer to a long. I updated the Openvr_apiLibrary.java as seen in this commit (near the bottom):

https://github.com/phr00t/jmonkeyengine-virtual-reality/commit/ba0877400ccd695805a49b11d7285be63cc58263

I have a strong feeling functions like GetFloatTrackedDevicePropertyā€™s hmdDeviceIndex argument will work the same, which if so, still needs to be fixed.

EDIT: another quick edit, since hmdDeviceIndex seems to be an int, not a long. Still need to determine if its looking for a pointer to an int, or just the int value. It appears it wants just the int, but BridJ auto-generated a setup for a pointer to an intā€¦ have to test.

@phr00t
Progress is pretty slow as Iā€™m getting to grips with the example application and the library.
Iā€™m currently working on mapping the UpdateHMDMatrixPose() method from the example. Just so we donā€™t do any duplicate work. Iā€™ll continue from there.

Iā€™ve checked in my progress from this weekend.
Basically there are methods for getting various pose transforms from the HMD, but not put into any context yet. Itā€™s 100% not tested.
Btw, itā€™s easier to intialize the Pointers, but thereā€™s a whole lot of casting once you want to use them for something.

1 Like

Great, thank you for the help. I havenā€™t had a chance to really look it over yet ā€“ been working on a Spermination update :stuck_out_tongue: The SteamVR team has some instructions on testing with a Null Driver here:

http://steamcommunity.com/app/250820/discussions/0/613956964603712981/#c613956964604147408

I havenā€™t gotten those instructions to work yet, but I admit I need to spend a little more time trying. We need to figure out how much needs to be filled out before we get something worth testing against a Rift (printing out pose information would be a great step). Iā€™ll be able to look more at this in the next few days.

I think the basic stuff is there for reading out poses. That should be enough for testing against with a StereoCameraControl. It seems the preferred way of rendering is to use the supplied viewports and projection matrices. This can be added once the basics are confirmed. I can look into that over the coming weeks, but this weekend is packed.

OK, checked in some more progress:

https://github.com/phr00t/jmonkeyengine-virtual-reality/commit/edb2898c7cf32dd295543cff36ffe71a72c0634d

Flagged Oculus Rift SDK-specific stuff deprecated. There might be spots where Rift structures are used, like OvrSizei, that need to be replaced. I changed one to Vector2f.

Is it possible to dump HMDInfo? It seems like the only variable used is pupillary distance. Perhaps a few more variables will be needed for the shader filter, though? Iā€™d like to remove code & structure excess where possible.

The TestVRApplication project now runs up to the updatePose() function. Unfortunately, it crashes because Iā€™m still getting ā€œNo HMD present (108)ā€ when trying to initialize. I have no HMD hooked up, so this error is mostly expected, although Iā€™m trying to use the ā€œNull Driverā€ method I posted about above. Asking for help on that here:

Perhaps hooking it up to a Rift DK1 or DK2 would get us some results.

Another quick update ā€“ getting the projection matrix & texture render size:

https://github.com/phr00t/jmonkeyengine-virtual-reality/commit/45b1c18a2420db8ee911ba0396ddebc2307aaff7

I left a TODO when initializing the composer. I couldnā€™t find how to get hold of the version number there. Without it being initialized, itā€™s not going to work.

This should do it:

https://github.com/phr00t/jmonkeyengine-virtual-reality/commit/858ab4c291b82e40220f90d4a866092fd71e9b61

Another quick update ā€“ I donā€™t think you need to allocate a long for the compositor. The VRGetGenericInterface probably initializes the memory needed for whatever interface is being returned. I made the change here:

https://github.com/phr00t/jmonkeyengine-virtual-reality/commit/dce02efa5ff65b6147b05918083381cbcb6376f7

From Valve:

ā€œThe compositor still needs some work before it will be fully operational on both linux and osx, but you can use the sdk interfaces to do your own distortion correction, etc. in the meantime.ā€

Still trying to get the debug environment working to get past the ā€œHmd not found (108)ā€ error without an HMD plugged in:

Made a little progress, but it looks like some arguments might be broken on the vrserver tool. Awaiting Valveā€™s responseā€¦ anyone with a Rift & Windows is free to try the library sooner, before I get to it though!

1 Like

By the way, thereā€™s OSVR SDK coming out in July 2015:
http://www.osvr.com/

This one is actually open source (Apache 2.0 license), unlike OpenVR which is a proprietary SDK and not open at all.
This means we can actually integrate OSVR with jMonkeyEngine without concerns over license.

They still havenā€™t provided the source code yet though, will be waiting patientlyā€¦

Thank you for the heads-up. Weā€™ll see how the project develops.

My gut is to stick with OpenVR, though. Valve is obviously a huge player, already incorporating OpenVR into the largest digital distribution platform as SteamVR. The Vive is currently the most promising piece of hardware, which OpenVR (and SteamVR) is the primary driver for. People already have Oculus Rifts, which is being used against OpenVR already.

OSVR looks promising, but OpenVR is larger & has a head start at accomplishing unification of VR hardware. The open-source angle is nice, but doesnā€™t trump other factors (in my humble opinion).

What worries me about the OSVR is that it doesnā€™t seem to have any (positional) head-tracking, which simply is a must for any decent VR experience (itā€™s extendable, I know).
I also ā€œregistered my interestā€ many months ago, but I have yet to receive any newsletter from them.

That said, provided there is some way of getting positional tracking Iā€™ll get one. Iā€™ll probably sit around waiting for someone to make a java port, though.