Search in sources :

Example 46 with Pointer

use of com.jme3.scene.plugins.blender.file.Pointer in project jmonkeyengine by jMonkeyEngine.

the class OSVRInput method init.

@Override
public boolean init() {
    logger.config("Initialize OSVR input.");
    buttonHandler = new Callback() {

        @SuppressWarnings("unused")
        public void invoke(Pointer userdata, Pointer timeval, OSVR_ButtonReport report) {
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < BUTTON_COUNT; j++) {
                    if (buttons[i][j] == null)
                        continue;
                    if (userdata.toString().equals(buttons[i][j].getPointer().toString())) {
                        buttonState[i][j] = report.state;
                        return;
                    }
                }
            }
        }
    };
    analogHandler = new Callback() {

        @SuppressWarnings("unused")
        public void invoke(Pointer userdata, Pointer timeval, OSVR_AnalogReport report) {
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < ANALOG_COUNT; j++) {
                    for (int k = 0; k < CHANNEL_COUNT; k++) {
                        if (analogs[i][j][k] == null)
                            continue;
                        if (userdata.toString().equals(analogs[i][j][k].getPointer().toString())) {
                            analogState[i][j][k] = (float) report.state;
                            return;
                        }
                    }
                }
            }
        }
    };
    buttons = new OSVR_ClientInterface[2][BUTTON_COUNT];
    analogs = new OSVR_ClientInterface[2][ANALOG_COUNT][CHANNEL_COUNT];
    buttonState = new float[2][BUTTON_COUNT];
    analogState = new float[2][ANALOG_COUNT][CHANNEL_COUNT];
    hands = new OSVR_ClientInterface[2];
    hands[0] = getInterface(leftHand);
    hands[1] = getInterface(rightHand);
    handState = new OSVR_Pose3[2];
    handState[0] = new OSVR_Pose3();
    handState[1] = new OSVR_Pose3();
    for (int h = 0; h < 2; h++) {
        for (int i = 0; i < BUTTON_COUNT - 2; i++) {
            buttons[h][i] = getInterface(getButtonString(h == 0, (byte) Integer.toString(i).toCharArray()[0]));
            OsvrClientKitLibrary.osvrRegisterButtonCallback(buttons[h][i], buttonHandler, buttons[h][i].getPointer());
        }
    }
    buttons[0][BUTTON_COUNT - 2] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', 'b', 'u', 'm', 'p', 'e', 'r', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterButtonCallback(buttons[0][BUTTON_COUNT - 2], buttonHandler, buttons[0][BUTTON_COUNT - 2].getPointer());
    buttons[1][BUTTON_COUNT - 2] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', 'b', 'u', 'm', 'p', 'e', 'r', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterButtonCallback(buttons[1][BUTTON_COUNT - 2], buttonHandler, buttons[1][BUTTON_COUNT - 2].getPointer());
    buttons[0][BUTTON_COUNT - 1] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', 'j', 'o', 'y', 's', 't', 'i', 'c', 'k', '/', 'b', 'u', 't', 't', 'o', 'n', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterButtonCallback(buttons[0][BUTTON_COUNT - 1], buttonHandler, buttons[0][BUTTON_COUNT - 1].getPointer());
    buttons[1][BUTTON_COUNT - 1] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', 'j', 'o', 'y', 's', 't', 'i', 'c', 'k', '/', 'b', 'u', 't', 't', 'o', 'n', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterButtonCallback(buttons[1][BUTTON_COUNT - 1], buttonHandler, buttons[1][BUTTON_COUNT - 1].getPointer());
    analogs[0][0][0] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', 't', 'r', 'i', 'g', 'g', 'e', 'r', (byte) 0 });
    analogs[1][0][0] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', 't', 'r', 'i', 'g', 'g', 'e', 'r', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterAnalogCallback(analogs[0][0][0], analogHandler, analogs[0][0][0].getPointer());
    OsvrClientKitLibrary.osvrRegisterAnalogCallback(analogs[1][0][0], analogHandler, analogs[1][0][0].getPointer());
    analogs[0][1][0] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', 'j', 'o', 'y', 's', 't', 'i', 'c', 'k', '/', 'x', (byte) 0 });
    analogs[0][1][1] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'l', 'e', 'f', 't', '/', 'j', 'o', 'y', 's', 't', 'i', 'c', 'k', '/', 'y', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterAnalogCallback(analogs[0][1][0], analogHandler, analogs[0][1][0].getPointer());
    OsvrClientKitLibrary.osvrRegisterAnalogCallback(analogs[0][1][1], analogHandler, analogs[0][1][1].getPointer());
    analogs[1][1][0] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', 'j', 'o', 'y', 's', 't', 'i', 'c', 'k', '/', 'x', (byte) 0 });
    analogs[1][1][1] = getInterface(new byte[] { '/', 'c', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', '/', 'r', 'i', 'g', 'h', 't', '/', 'j', 'o', 'y', 's', 't', 'i', 'c', 'k', '/', 'y', (byte) 0 });
    OsvrClientKitLibrary.osvrRegisterAnalogCallback(analogs[1][1][0], analogHandler, analogs[1][1][0].getPointer());
    OsvrClientKitLibrary.osvrRegisterAnalogCallback(analogs[1][1][1], analogHandler, analogs[1][1][1].getPointer());
    return true;
}
Also used : Callback(com.sun.jna.Callback) OSVR_ButtonReport(com.jme3.system.osvr.osvrclientreporttypes.OSVR_ButtonReport) OSVR_Pose3(com.jme3.system.osvr.osvrclientreporttypes.OSVR_Pose3) Pointer(com.sun.jna.Pointer) OSVR_AnalogReport(com.jme3.system.osvr.osvrclientreporttypes.OSVR_AnalogReport)

Aggregations

Pointer (com.jme3.scene.plugins.blender.file.Pointer)30 Structure (com.jme3.scene.plugins.blender.file.Structure)27 ArrayList (java.util.ArrayList)12 APIBuffer (com.jme3.lwjgl3.utils.APIBuffer)6 DynamicArray (com.jme3.scene.plugins.blender.file.DynamicArray)6 List (java.util.List)6 FileBlockHeader (com.jme3.scene.plugins.blender.file.FileBlockHeader)5 Vector2f (com.jme3.math.Vector2f)4 Vector3f (com.jme3.math.Vector3f)4 Map (java.util.Map)4 Spline (com.jme3.math.Spline)3 Spatial (com.jme3.scene.Spatial)3 ConstIpo (com.jme3.scene.plugins.blender.animations.Ipo.ConstIpo)3 BlenderFileException (com.jme3.scene.plugins.blender.file.BlenderFileException)3 BlenderInputStream (com.jme3.scene.plugins.blender.file.BlenderInputStream)3 TouchEvent (com.jme3.input.event.TouchEvent)2 Transform (com.jme3.math.Transform)2 CameraNode (com.jme3.scene.CameraNode)2 LightNode (com.jme3.scene.LightNode)2 Node (com.jme3.scene.Node)2