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.
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).
Small update to display any errors in English during initialization:
@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).
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):
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.
Great, thank you for the help. I havenāt had a chance to really look it over yet ā been working on a Spermination update 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:
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:
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:
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:
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!
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.