/** * Rendering callback of the app state. This method is called by the {@link #update(float) update()} method and should not be called manually. * @param renderManager the {@link RenderManager render manager}. */ public void simpleRender(RenderManager renderManager) { PreNormalCaching.resetCache(environment.isInVR()); }
@Override public void triggerHapticPulse(int controllerIndex, float seconds) { if (environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false) { return; } // apparently only axis ID of 0 works VRSystem.VRSystem_TriggerHapticPulse(LWJGLOpenVRInput.controllerIndex[controllerIndex], 0, (short) Math.round(3f * seconds / 1e-3f)); }
@Override public void triggerHapticPulse(int controllerIndex, float seconds) { if( environment.isInVR() == false || isInputDeviceTracking(controllerIndex) == false ){ return; } // apparently only axis ID of 0 works ((VR_IVRSystem_FnTable)environment.getVRHardware().getVRSystem()).TriggerHapticPulse.apply(OpenVRInput.controllerIndex[controllerIndex], 0, (short)Math.round(3f * seconds / 1e-3f)); }
@Override public Vector2f getCursorPosition() { if (environment != null){ if (environment.getApplication() != null){ if( environment.isInVR() ) { return cursorPos; } return environment.getApplication().getInputManager().getCursorPosition(); } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
/** * 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(); }
app.getCamera().setFrustumNear(fNear); if( environment.isInVR() ) {
@Override public void centerMouse() { if (environment != null){ if (environment.getApplication() != null){ // set mouse in center of the screen if newly added Vector2f size = environment.getVRGUIManager().getCanvasSize(); MouseInput mi = environment.getApplication().getContext().getMouseInput(); AppSettings as = environment.getApplication().getContext().getSettings(); if( mi instanceof GlfwMouseInputVR ) ((GlfwMouseInputVR)mi).setCursorPosition((int)(as.getWidth() / 2f), (int)(as.getHeight() / 2f)); if( environment.isInVR() ) { cursorPos.x = size.x / 2f; cursorPos.y = size.y / 2f; recentCenterCount = 2; } } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
/** * Get the GUI canvas size. This method return the size in pixels of the GUI available area within the VR view. * @return the GUI canvas size. This method return the size in pixels of the GUI available area within the VR view. */ public Vector2f getCanvasSize() { if (environment != null){ if (environment.getApplication() != null){ if( screenSize == null ) { if( environment.isInVR() && environment.getVRHardware() != null ) { screenSize = new Vector2f(); environment.getVRHardware().getRenderSize(screenSize); screenSize.multLocal(environment.getVRViewManager().getResolutionMuliplier()); } else { AppSettings as = environment.getApplication().getContext().getSettings(); screenSize = new Vector2f(as.getWidth(), as.getHeight()); } } return screenSize; } else { throw new IllegalStateException("VR GUI manager underlying environment is not attached to any application."); } } else { throw new IllegalStateException("VR GUI manager is not attached to any environment."); } }
if( environment.isInVR() ) { VRAPI api = environment.getVRHardware(); if( api.getCompositor() != null ) {
if( environment.isInVR() ) { VRAPI api = environment.getVRHardware(); if( api.getCompositor() != null ) {
if (environment.isInVR()) { VRAPI api = environment.getVRHardware();
if (getVREnvironment().getApplication() != null){ if( getVREnvironment().isInVR() == false || getVREnvironment().getVRinput() == null || getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){
if (getVREnvironment().getApplication() != null){ if( getVREnvironment().isInVR() == false || getVREnvironment().getVRinput() == null || getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){
if (getVREnvironment().getApplication() != null){ if( getVREnvironment().isInVR() == false || getVREnvironment().getVRinput() == null || getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){
if (getVREnvironment().getApplication() != null){ if( getVREnvironment().isInVR() == false || getVREnvironment().getVRinput() == null || getVREnvironment().getVRinput().isInputDeviceTracking(inputIndex) == false ){
@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); }
if( environment.isInVR() == false ){ Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true);
if( environment.isInVR() == false ){ return;