/** * Set the resolution multiplier. * @param val the resolution multiplier. */ public void setResolutionMultiplier(float val) { resMult = val; if( environment.getVRViewManager() != null ){ environment.getVRViewManager().setResolutionMultiplier(resMult); } }
@Override public void render(RenderManager rm) { super.render(rm); // update compositor if( environment.getVRViewManager() != null ) { environment.getVRViewManager().render(); } }
/** * Get the VR headset right viewport. * @return the VR headset right viewport. * @see #getLeftViewPort() */ public ViewPort getRightViewPort() { if( environment.getVRViewManager() == null ){ return application.getViewPort(); } return environment.getVRViewManager().getRightViewPort(); }
/** * Move filters from the main scene into the eye's. * This removes filters from the main scene. */ public void moveScreenProcessingToVR() { environment.getVRViewManager().moveScreenProcessingToEyes(); }
/** * Get the VR headset left viewport. * @return the VR headset left viewport. * @see #getRightViewPort() */ public ViewPort getLeftViewPort() { if( environment.getVRViewManager() == null ){ return application.getViewPort(); } return environment.getVRViewManager().getLeftViewPort(); }
/** * Get the VR view manager. * @return the VR view manager. */ public VRViewManager getVRViewManager() { return getVREnvironment().getVRViewManager(); }
@Override public void postRender() { super.postRender(); // update compositor if( environment.getVRViewManager() != null ) { environment.getVRViewManager().postRender(); } }
/** * Set the background color for both left and right view ports. * @param clr the background color. */ public void setBackgroundColors(ColorRGBA clr) { if( environment.getVRViewManager() == null ) { application.getViewPort().setBackgroundColor(clr); } else if( environment.getVRViewManager().getLeftViewPort() != null ) { environment.getVRViewManager().getLeftViewPort().setBackgroundColor(clr); if( environment.getVRViewManager().getRightViewPort() != null ){ environment.getVRViewManager().getRightViewPort().setBackgroundColor(clr); } } }
/** * Get the {@link Camera camera} used for rendering. * If the VR mode is {@link #isInVR() active}, this method return a dummy camera, otherwise, * this method return the camera of the attached application. * @return the camera attached used for rendering. */ public Camera getCamera() { if( isInVR() && getVRViewManager() != null && getVRViewManager().getLeftCamera() != null ) { return getDummyCamera(); } return application.getCamera(); }
@Override public Quaternion getFinalObserverRotation(int index) { if (environment != null) { VRViewManager vrvm = environment.getVRViewManager(); if (vrvm != null) { if (isInputDeviceTracking(index) == false) { return null; } Object obs = environment.getObserver(); if (obs instanceof Camera) { tempq.set(((Camera) obs).getRotation()); } else { tempq.set(((Spatial) obs).getWorldRotation()); } return tempq.multLocal(getOrientation(index)); } else { throw new IllegalStateException("VR environment has no valid view manager."); } } else { throw new IllegalStateException("VR input is not attached to a VR environment."); } }
@Override public Quaternion getFinalObserverRotation(int index) { if (environment != null){ OpenVRViewManager vrvm = (OpenVRViewManager)environment.getVRViewManager(); if (vrvm != null){ if(isInputDeviceTracking(index) == false ){ return null; } Object obs = environment.getObserver(); if( obs instanceof Camera ) { tempq.set(((Camera)obs).getRotation()); } else { tempq.set(((Spatial)obs).getWorldRotation()); } return tempq.multLocal(getOrientation(index)); } else { throw new IllegalStateException("VR environment has no valid view manager."); } } else { throw new IllegalStateException("VR input is not attached to a VR environment."); } }
@Override public Quaternion getFinalObserverRotation(int index) { OSVRViewManager vrvm = (OSVRViewManager)environment.getVRViewManager(); if( vrvm == null || isInputDeviceTracking(index) == false ) return null; Object obs = environment.getObserver(); if( obs instanceof Camera ) { tempq.set(((Camera)obs).getRotation()); } else { tempq.set(((Spatial)obs).getWorldRotation()); } return tempq.multLocal(getOrientation(index)); }
@Override public Vector3f getFinalObserverPosition(int index) { if (environment != null){ OpenVRViewManager vrvm = (OpenVRViewManager)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."); } }
@Override public Vector3f getFinalObserverPosition(int index) { if (environment != null) { VRViewManager vrvm = (VRViewManager) 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."); } }
@Override public void update(float tpf) { // update VR pose & cameras if( environment.getVRViewManager() != null ) { environment.getVRViewManager().update(tpf); } else if( environment.getObserver() != null ) { environment.getCamera().setFrame(((Spatial)environment.getObserver()).getWorldTranslation(), ((Spatial)environment.getObserver()).getWorldRotation()); } if( environment.isInVR() == false || environment.getVRGUIManager().getPositioningMode() == VRGUIPositioningMode.MANUAL ) { // only update geometric state here if GUI is in manual mode, or not in VR // it will get updated automatically in the viewmanager update otherwise // TODO isn't this done by SimpleApplication? for (Spatial spatial : application.getGuiViewPort().getScenes()) { //spatial.updateLogicalState(tpf); spatial.updateGeometricState(); } } // use the analog control on the first tracked controller to push around the mouse environment.getVRMouseManager().updateAnalogAsMouse(0, null, null, null, tpf); }
@Override public Quaternion getFinalObserverRotation(int index) { // Copied from OpenVRInput VREnvironment env = hardware.getEnvironment(); OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); Object obs = env.getObserver(); Quaternion tempq = new Quaternion(); // TODO move to class scope? if (obs instanceof Camera) { tempq.set(((Camera) obs).getRotation()); } else { tempq.set(((Spatial) obs).getWorldRotation()); } return tempq.multLocal(getOrientation(index)); }
@Override public Vector3f getFinalObserverPosition(int index) { OSVRViewManager vrvm = (OSVRViewManager) environment.getVRViewManager(); if( vrvm == null || 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()); } }
@Override public Vector3f getFinalObserverPosition(int index) { // Copied from OpenVRInput VREnvironment env = hardware.getEnvironment(); OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); Object obs = env.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()); } }
/** * Get the observer final rotation within the scene. * @return the observer final rotation within the scene. * @see #getFinalObserverPosition() */ public Quaternion getFinalObserverRotation() { if( environment.getVRViewManager() == null ) { if( environment.getObserver() == null ) { return environment.getCamera().getRotation(); } else { return ((Spatial)environment.getObserver()).getWorldRotation(); } } if( environment.getObserver() == null ) { tempq.set(environment.getDummyCamera().getRotation()); } else { tempq.set(((Spatial)environment.getObserver()).getWorldRotation()); } return tempq.multLocal(environment.getVRHardware().getOrientation()); }
/** * Get the observer final position within the scene. * @return the observer position. * @see #getFinalObserverRotation() */ public Vector3f getFinalObserverPosition() { if( environment.getVRViewManager() == null ) { if( environment.getObserver() == null ) { return environment.getCamera().getLocation(); } else{ return ((Spatial)environment.getObserver()).getWorldTranslation(); } } Vector3f pos = environment.getVRHardware().getPosition(); if( environment.getObserver() == null ) { environment.getDummyCamera().getRotation().mult(pos, pos); return pos.addLocal(environment.getDummyCamera().getLocation()); } else { ((Spatial)environment.getObserver()).getWorldRotation().mult(pos, pos); return pos.addLocal(((Spatial)environment.getObserver()).getWorldTranslation()); } }