Search in sources :

Example 1 with VRViewManagerOpenVR

use of com.jme3.util.VRViewManagerOpenVR in project jmonkeyengine by jMonkeyEngine.

the class OpenVRInput method getFinalObserverPosition.

@Override
public Vector3f getFinalObserverPosition(int index) {
    if (environment != null) {
        VRViewManagerOpenVR vrvm = (VRViewManagerOpenVR) environment.getVRViewManager();
        if (vrvm != null) {
            if (isInputDeviceTracking(index) == false) {
                return null;
            }
            Object obs = environment.getObserver();
            Vector3f pos = getPosition(index);
            if (obs instanceof Camera) {
                ((Camera) obs).getRotation().mult(pos, pos);
                return pos.addLocal(((Camera) obs).getLocation());
            } else {
                ((Spatial) obs).getWorldRotation().mult(pos, pos);
                return pos.addLocal(((Spatial) obs).getWorldTranslation());
            }
        } else {
            throw new IllegalStateException("VR environment has no valid view manager.");
        }
    } else {
        throw new IllegalStateException("VR input is not attached to a VR environment.");
    }
}
Also used : VRViewManagerOpenVR(com.jme3.util.VRViewManagerOpenVR) Vector3f(com.jme3.math.Vector3f) Camera(com.jme3.renderer.Camera)

Example 2 with VRViewManagerOpenVR

use of com.jme3.util.VRViewManagerOpenVR in project jmonkeyengine by jMonkeyEngine.

the class VREnvironment method atttach.

/**
     * Attach the VR environment to the given app state and application. 
     * This method should be called within the {@link AppState#stateAttached(com.jme3.app.state.AppStateManager) stateAttached(com.jme3.app.state.AppStateManager)} method 
     * from the app state.
     * @param appState the app state to attach.
     * @param application the application to attach.
     */
public void atttach(AppState appState, Application application) {
    this.application = application;
    this.app = appState;
    // Instanciate view manager
    if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_VALUE) {
        viewmanager = new VRViewManagerOpenVR(this);
    } else if (vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE) {
        viewmanager = new VRViewManagerOSVR(this);
    } else {
        logger.severe("Cannot instanciate view manager, unknown VRAPI type: " + vrBinding);
    }
}
Also used : VRViewManagerOSVR(com.jme3.util.VRViewManagerOSVR) VRViewManagerOpenVR(com.jme3.util.VRViewManagerOpenVR)

Example 3 with VRViewManagerOpenVR

use of com.jme3.util.VRViewManagerOpenVR in project jmonkeyengine by jMonkeyEngine.

the class VRApplication method initialize.

@Override
public void initialize() {
    logger.config("Initialize VR application...");
    initialize_internal();
    cam.setFrustumFar(fFar);
    cam.setFrustumNear(fNear);
    dummyCam = cam.clone();
    if (isInVR()) {
        logger.config("VR mode enabled.");
        if (VRhardware != null) {
            VRhardware.initVRCompositor(compositorAllowed());
        } else {
            logger.warning("No VR system found.");
        }
        //FIXME: WARNING !!
        viewmanager = new VRViewManagerOpenVR(null);
        viewmanager.setResolutionMultiplier(resMult);
        inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9));
        setLostFocusBehavior(LostFocusBehavior.Disabled);
    } else {
        logger.config("VR mode disabled.");
        viewPort.attachScene(rootNode);
        guiViewPort.attachScene(guiNode);
    }
    if (viewmanager != null) {
        viewmanager.initialize();
    }
    simpleInitApp();
    // any filters created, move them now
    if (viewmanager != null) {
        viewmanager.moveScreenProcessingToEyes();
        // print out camera information
        if (isInVR()) {
            logger.info("VR Initialization Information");
            if (viewmanager.getLeftCamera() != null) {
                logger.info("camLeft: " + viewmanager.getLeftCamera().toString());
            }
            if (viewmanager.getRightCamera() != null) {
                logger.info("camRight: " + viewmanager.getRightCamera().toString());
            }
        }
    }
}
Also used : VRViewManagerOpenVR(com.jme3.util.VRViewManagerOpenVR) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Aggregations

VRViewManagerOpenVR (com.jme3.util.VRViewManagerOpenVR)3 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 Vector3f (com.jme3.math.Vector3f)1 Camera (com.jme3.renderer.Camera)1 VRViewManagerOSVR (com.jme3.util.VRViewManagerOSVR)1