Oculus Rift Support

AFAIK latency is the key factor for nausea.
Also, from reports, it seems that the hardware&driver latency is already near or above the nausea threshold for some people. If that’s true, every millisecond on the JME side counts.

Yeah. For example, i haven’t been able to make a “release” build yet for the .dll, due to the compiler being a different version. I’m thinking once the library is in a working state, i might get some help with the JNI stuff. There are some other weirdness with it as well. Like i have to create it from the static context which i launch the app in. Creating it from within the app (same thread, different thread, callable doesn’t matter), it won’t return the JNI object properly.

Most things seem to be in order for an initial release. It’s all contained in this google code repo:
http://code.google.com/p/jmonkeyengine-oculus-rift/

TestStereoCams.java should show you a couple of white boxes moving back and forth. It’s also possible to remove some comments and load the wildhouse scene.

It uses a StereoCamAppState, which creates cameras with two BarrelDistortionFilters as a post effect.
The filters use a BarrelDistortion material, and the cameras are added to a StereoCameraControl which is based on the CameraControl.
At the moment, you will move in the direction you face.

Some things for the next one:
Skyboxes are not looking very good right now.
Neither does gui.
Post effects (are only on one viewport right now)
Try to make a ‘release’ version of the dll, and create the jni object inside the app.

Quick response. Thanks, I’ll give it a look. Yeah I suspected latency to be a larger issue…

Not sure if this is what you’re referencing, but I’m getting a “UnsatisfiedLinkError: blahblah\OculusLib64.dll: Can’t find dependent libraries” as well as “camera has private access in CameraControl” for StereoCameraControl.java

Ah, sorry.
I had forgotten i had edited CameraControl. This is since i extended it for the StereoCamControl, camera had to be protected instead.

I also forgot to mention you need to add the oculuslib.jar to your project (it’s in the root dir). For the next release i should probably upload the whole project structure as well. I’ll update the documentation meanwhile

I saw your wiki update with the Camera patch. I did add oculuslib.jar to the project via rightclickproject->properties->libraries->addjar->oculuslib.jar and the project doesn’t seem to recognize it.

How do you mean it doesn’t recognize it? Does it complain over the .jar, or doesn’t it extract the dll from it?

It will give off the error “java.lang.UnsatisfiedLinkError: no OculusLib64 in java.library.path” which I suspect is a failure to extract the dll. When I copy the four files from the jar and place it in the same directory as lwjgl64.dll, the aforementioned error disappears and I get “java.lang.UnsatisfiedLinkError: C:\Users\blahblahblah\RiftTest\OculusLib64.dll: Can’t find dependent libraries” instead, the one I was asking you about in my much earlier comment. I’m suspecting I’m missing some dependencies that you have but didn’t upload.

Right. It was due to me creating the oculus object in the static context when creating the app that did it. It must extract the dll’s there as well.
If you do a sync with the repo you should get some stuff that hopefully fixes it.

When I run TestStereoCams OculusLib64.dll successfully materializes into the main directory. However It says “Can’t find dependent libraries” which probably makes sense since I don’t see a lib file in the directory. Running the other files such as TestOculus doesn’t extract the dll.

FYI: You have an unused import in StereoCamAppState (vrgui or something like that). I resolved the private CameraControl camera by just copy-pasting CameraControl’s code and putting it in a copy in the project’s com.jme3.scene.control folder and making the necessary changes.

Weird, since the libs are in the oculuslib.jar, and it works for me. Hmm…

Edit: removed the reference to TestGui and added CameraControl to the repo. Thanks

If you’re still stumped you could always just upload the whole project structure and see if it works for me.

Done. Can you see if it copies oculuslib.jar to the dist/lib folder?

Yes it gets copied into the dist/lib folder.

I’m getting “java.lang.IllegalAccessError: tried to access field com.jme3.scene.control.CameraControl.camera from class com.jme3.scene.control.StereoCameraControl” on the surface which may be indicative of other errors. In my console I see the usual can’t find dependent libraries for OculusLib64.dll error and a nullpointerexception. If I comment out controlUpdate from StereoCameraControl, the program will at least run, although not correctly. Also, I still see the unused TestGui import in StereoCamAppState

I just tried wiping the whole directory and download it, and it worked like before. I also diffed my jme project to see if there were any other relevant changes i had made and found nothing. I’ve really no idea what could be the problem.
Is anyone else testing it and experiencing the same problem?

Ack, I dun goofed. I didn’t include the nbproject folder when I was replacing my project files with the new files. After I found out about my error, I noticed that I don’t have jME3-core and jMonkeyEngine3. I instead have a library called “jme3” which resolves all the reference issues, but maybe there is a slight difference between my libraries and yours which is causing the issues I’m having.

That could cause some problems. Don’t see why it would cause those problems though.

Nevertheless, glad to see the problems resolved :mrgreen:

I’m going to see if i can better the initialization of the JNI object now

Sorry I was being misleading. I’m still getting issues. Is there any way I can have a copy of your jME3-core and jMonkeyEngine3 libraries? I also later found out that my “jme3” library is actually my version of jME3-core. If I’m not mistaken, your project properties files should say what version of java you have… If your libraries don’t work, I’ll just take a look at it myself and see if I can fix it, I don’t want to hassle you any more at this point.

There was a discrepency in the libs. It only occured to me once the method was called, but perhaps different java versions act differently.
I’ve uploaded new libs and some code. The initialization of the native object is now much smoother as well.

Hope this fixes your problems!

Edit: And todays big oculus news. John Carmack joins as CTO! :open_mouth: