Java API — Oculus
New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

Java API

rupyrupy Posts: 517
Brain Burst
edited May 2013 in Support
I realize that this might never work because of latency issues, but I know Notch is working on it, so Notch how is it going?
aeon.svg
"It's like Homeworld in first person."
Disable Aero and vSync for a completely simulator sickness free experience with 2xHz FPS.
Keep the config utility open for tracking to work.

Comments

  • If he won't share a JNI Implementation I'll be making one... which probably means it will suck... might not even work, but I'll do it!
  • mike997mike997 Posts: 21
    Well, displaying the game won't be the problem, the issue will be the input device. I'll have a look at it as well in a month or so when I get my dev kit :)

    Mike
    Game in pre-alpha with support for Oculus Rift DK2 coming in the next patch, State of Fortune
  • rupyrupy Posts: 517
    Brain Burst
    Ok, good to hear I'm not the only one who is going to use Java!

    Out of curiosity what are your projects about? Edit: loading SoF now...
    aeon.svg
    "It's like Homeworld in first person."
    Disable Aero and vSync for a completely simulator sickness free experience with 2xHz FPS.
    Keep the config utility open for tracking to work.
  • rmcclellandrmcclelland Posts: 146
    Art3mis
    FYI, notch posted on another thread about LWJGL integration:

    viewtopic.php?f=20&t=10
  • JustinJustin Posts: 11
    FYI, notch posted on another thread about LWJGL integration:

    viewtopic.php?f=20&t=10

    Notch recently posted on his twitter that he couldn't get it to work and that he would "take another swing at it" when he got back from the US.
  • brantlewbrantlew Posts: 540 Oculus Staff
    I can't see any reason why a JNI implementation could not be created. The SDK is not C-style so it's a little more effort than just creating pass through functions, but I can't think of anything that would prohibit a wrapper.
  • MrGeddingsMrGeddings Posts: 604
    Art3mis
    i HOPE it can be worked out id love to see Minecraft with the Rift......

    ugh why did they have to make the game in java lol oh well ;-).
  • rupy wrote:
    Ok, good to hear I'm not the only one who is going to use Java!
    Out of curiosity what are your projects about? Edit: loading SoF now...
    I'm not strictly sure what kind of projects I'll be doing, but I can say it will be more casual gameplay and/or applications. My first test / project will be a chess game. Nothing extraordinary.
  • nephneph Posts: 40
    Hi, i'm working on Oculus Rift support for jMonkeyEngine, and a step in that process has been making a JNI (my first, in fact).

    I've posted the source here: http://www.softwarepioneering.com/

    More info on the jme integration here: http://jmonkeyengine.org/forum/topic/oculus-rift-support/
    "The television screen has become the retina of the minds eye."
  • jhericojherico Posts: 1,419
    Nexus 6
    Wrapping the Oculus SDK in JNI seems like a lot of effort for minimal return. Instead, it's easier to use the Java HID API https://code.google.com/p/javahidapi/ library to talk to the tracker hardware directly.

    I've actually got a full Java implementation of reading and parsing the head tracking packets, and passing them into a port of the sensor fusion logic.

    The core of the rift interaction is a tight loop running in it's own thread. The 'device' is an HIDDevice instance provided by the above linked library.
        @Override
        public void run() {
            long nextKeepAlive = 0;
            int bytesRead = 0;
            try {
                device.enableBlocking();
                while (!shutdown) {
                    if (System.currentTimeMillis() > nextKeepAlive) {
                        setKeepAliveMilliSeconds(KEEP_ALIVE_TIME);
                        nextKeepAlive = System.currentTimeMillis() + (3 * 1000);
                    }
    
                    int timeout = (int) Math.max(System.currentTimeMillis() - nextKeepAlive, 100);
                    bytesRead = device.readTimeout(buffer.array(), timeout);
                    if (0 == bytesRead) {
                        continue;
                    }
                    buffer.position(0);
                    callback.apply(new TrackerMessage(buffer));
                }
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    
    Brad Davis - Developer for High Fidelity
    Co-author of Oculus Rift in Action

  • rupyrupy Posts: 517
    Brain Burst
    Ok would be interesting to know how many millisec you shave off the @38leinaD/@neph JNI implementation with java HID _without_ passing the data to the fusion sensor?

    It's obvious to me that if you can bypass the fusion sensor you should write your own sensor logic.

    Can you test @neph or this https://developer.oculusvr.com/forums/viewtopic.php?f=20&t=255 quickly?
    aeon.svg
    "It's like Homeworld in first person."
    Disable Aero and vSync for a completely simulator sickness free experience with 2xHz FPS.
    Keep the config utility open for tracking to work.
  • bhodgmanbhodgman Posts: 7
    NerveGear
    The "minecrift" minecraft mod, which adds rift support, uses the JRift library. Looks like someone's already made a JNI wrapper :D
    [edit] I should've clicked the link right above my post before writing this :oops:
Sign In or Register to comment.