Search in sources :

Example 1 with StubModel

use of gaiasky.scenegraph.StubModel in project gaiasky by langurmonkey.

the class SGROpenVR method render.

@Override
public void render(SceneGraphRenderer sgr, ICamera camera, double t, int rw, int rh, int tw, int th, FrameBuffer fb, PostProcessBean ppb) {
    if (vrContext != null) {
        rc.ppb = null;
        try {
            vrContext.pollEvents();
        } catch (Exception e) {
        // Should never happen
        }
        // Add controllers
        for (StubModel controller : controllerObjects) {
            Vector3 devicePos = controller.getDevice().getPosition(Space.Tracker);
            // Length from headset to controller
            auxd1.set(devicePos).sub(vrContext.getDeviceByType(VRDeviceType.HeadMountedDisplay).getPosition(Space.Tracker));
            if (controller.instance != null) {
                controller.addToRenderLists(SceneGraphRenderer.RenderGroup.MODEL_PIX);
            }
        }
        /* LEFT EYE */
        // Camera to left
        updateCamera((NaturalCamera) camera.getCurrent(), camera.getCamera(), VR.EVREye_Eye_Left, false, rc);
        sgr.renderGlowPass(camera, sgr.getGlowFb());
        boolean postProcess = postProcessCapture(ppb, fbLeft, rw, rh);
        // Render scene
        sgr.renderScene(camera, t, rc);
        // Camera
        camera.render(rw, rh);
        // GUI
        if (controllerHintGui.mustDraw()) {
            renderGui(controllerHintGui.left());
        } else {
            if (infoGui.mustDraw())
                renderGui(infoGui.left());
            if (selectionGui.mustDraw())
                renderGui(selectionGui.left());
        }
        sendOrientationUpdate(camera.getCamera(), rw, rh);
        postProcessRender(ppb, fbLeft, postProcess, camera, rw, rh);
        /* RIGHT EYE */
        // Camera to right
        updateCamera((NaturalCamera) camera.getCurrent(), camera.getCamera(), VR.EVREye_Eye_Right, false, rc);
        sgr.renderGlowPass(camera, sgr.getGlowFb());
        postProcess = postProcessCapture(ppb, fbRight, rw, rh);
        // Render scene
        sgr.renderScene(camera, t, rc);
        // Camera
        camera.render(rw, rh);
        // GUI
        if (controllerHintGui.mustDraw()) {
            renderGui(controllerHintGui.right());
        } else {
            if (infoGui.mustDraw()) {
                renderGui(infoGui.right());
            }
            if (selectionGui.mustDraw()) {
                renderGui(selectionGui.right());
            }
        }
        sendOrientationUpdate(camera.getCamera(), rw, rh);
        postProcessRender(ppb, fbRight, postProcess, camera, rw, rh);
        /* SUBMIT TO VR COMPOSITOR */
        VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Left, texLeft, null, VR.EVRSubmitFlags_Submit_Default);
        VRCompositor.VRCompositor_Submit(VR.EVREye_Eye_Right, texRight, null, VR.EVRSubmitFlags_Submit_Default);
        /* Render to screen */
        RenderUtils.renderKeepAspect(fbLeft, sbScreen, Gdx.graphics, lastSize);
    }
}
Also used : StubModel(gaiasky.scenegraph.StubModel) Vector3(com.badlogic.gdx.math.Vector3)

Example 2 with StubModel

use of gaiasky.scenegraph.StubModel in project gaiasky by langurmonkey.

the class SGROpenVR method removeVRController.

private void removeVRController(VRDevice device) {
    if (vrDeviceToModel.containsKey(device)) {
        StubModel sm = vrDeviceToModel.get(device);
        controllerObjects.removeValue(sm, true);
        vrDeviceToModel.remove(device);
    }
}
Also used : StubModel(gaiasky.scenegraph.StubModel)

Example 3 with StubModel

use of gaiasky.scenegraph.StubModel in project gaiasky by langurmonkey.

the class SGROpenVR method addVRController.

private void addVRController(VRDevice device) {
    if (!vrDeviceToModel.containsKey(device)) {
        StubModel sm = new StubModel(device, controllersEnv);
        controllerObjects.add(sm);
        vrDeviceToModel.put(device, sm);
    }
}
Also used : StubModel(gaiasky.scenegraph.StubModel)

Example 4 with StubModel

use of gaiasky.scenegraph.StubModel in project gaiasky by langurmonkey.

the class OpenVRListener method axisMoved.

@Override
public void axisMoved(VRDevice device, int axis, float valueX, float valueY) {
    logger.debug("axis moved: [device/axis/x/y]: " + device.toString() + " / " + axis + " / " + valueX + " / " + valueY);
    lazyInit();
    StubModel sm;
    switch(axis) {
        case VRControllerAxes.Axis1:
            // }
            break;
        case VRControllerAxes.Axis2:
            // }
            break;
        case VRControllerAxes.Axis0:
            // Joystick for forward/backward movement
            sm = vrDeviceToModel.get(device);
            if (sm != null) {
                if (cam.getMode().isFocus()) {
                    if (pressedButtons.contains(VRControllerButtons.Axis2)) {
                        cam.addRotateMovement(valueX * 0.1, valueY * 0.1, false, false);
                    } else {
                        cam.setVelocityVR(sm.getBeamP0(), sm.getBeamP1(), valueX, valueY);
                    }
                } else {
                    cam.setVelocityVR(sm.getBeamP0(), sm.getBeamP1(), valueX, valueY);
                }
            }
            lastAxisMovedFrame = GaiaSky.instance.frames;
            break;
    }
}
Also used : StubModel(gaiasky.scenegraph.StubModel)

Example 5 with StubModel

use of gaiasky.scenegraph.StubModel in project gaiasky by langurmonkey.

the class OpenVRListener method select.

/**
 * Selects the object pointed by the given device.
 *
 * @param device
 */
private void select(VRDevice device) {
    // Selection
    StubModel sm = vrDeviceToModel.get(device);
    if (sm != null) {
        p0.set(sm.getBeamP0());
        p1.set(sm.getBeamP1());
        IFocus hit = getBestHit(p0, p1);
        if (hit != null) {
            EventManager.publish(Event.FOCUS_CHANGE_CMD, this, hit);
            EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FOCUS_MODE);
        }
    } else {
        logger.info("Model corresponding to device not found");
    }
}
Also used : StubModel(gaiasky.scenegraph.StubModel) IFocus(gaiasky.scenegraph.IFocus)

Aggregations

StubModel (gaiasky.scenegraph.StubModel)5 Vector3 (com.badlogic.gdx.math.Vector3)1 IFocus (gaiasky.scenegraph.IFocus)1