Package com.jme3.app

Class VRAppState

All Implemented Interfaces:
AppState

public class VRAppState extends AbstractAppState
A JMonkey app state dedicated to Virtual Reality. An application that want to use VR devices (HTC vive, ...) has to use this app state.
As this app state and the main application have to share application settings, the common way to use this app state is:
Attaching an instance of this app state to an already started application may cause crashes.
  • Field Details

    • ID

      public static final String ID
      See Also:
    • DISABLE_VR

      public boolean DISABLE_VR
      Is the application has not to start within VR mode (default is false).
  • Constructor Details

    • VRAppState

      public VRAppState(VREnvironment environment)
      Create a new default VR app state that relies on the given VR environment.
      Parameters:
      environment - the VR environment that this app state is using.
    • VRAppState

      public VRAppState(AppSettings settings, VREnvironment environment)
      Create a new VR app state with given settings. The app state relies on the given VR environment.
      Parameters:
      settings - the settings to use.
      environment - the VR environment that this app state is using.
  • Method Details

    • simpleUpdate

      public void simpleUpdate(float tpf)
      Simple update of the app state, this method should contain any spatial updates. This method is called by the update() method and should not be called manually.
      Parameters:
      tpf - the application time.
    • simpleRender

      public void simpleRender(RenderManager renderManager)
      Rendering callback of the app state. This method is called by the update() method and should not be called manually.
      Parameters:
      renderManager - the render manager.
    • setFrustrumNearFar

      public void setFrustrumNearFar(float near, float far)
      Set the frustum values for the application.
      Parameters:
      near - the frustum near value.
      far - the frustum far value.
    • setMirrorWindowSize

      public void setMirrorWindowSize(int width, int height)
      Set the mirror window size in pixel.
      Parameters:
      width - the width of the mirror window in pixel.
      height - the height of the mirror window in pixel.
    • setResolutionMultiplier

      public void setResolutionMultiplier(float val)
      Set the resolution multiplier.
      Parameters:
      val - the resolution multiplier.
    • moveScreenProcessingToVR

      public void moveScreenProcessingToVR()
      Move filters from the main scene into the eye's. This removes filters from the main scene.
    • getFinalObserverRotation

      public Quaternion getFinalObserverRotation()
      Get the observer final rotation within the scene.
      Returns:
      the observer final rotation within the scene.
      See Also:
    • getFinalObserverPosition

      public Vector3f getFinalObserverPosition()
      Get the observer final position within the scene.
      Returns:
      the observer position.
      See Also:
    • getLeftViewPort

      public ViewPort getLeftViewPort()
      Get the VR headset left viewport.
      Returns:
      the VR headset left viewport.
      See Also:
    • getRightViewPort

      public ViewPort getRightViewPort()
      Get the VR headset right viewport.
      Returns:
      the VR headset right viewport.
      See Also:
    • setBackgroundColors

      public void setBackgroundColors(ColorRGBA clr)
      Set the background color for both left and right view ports.
      Parameters:
      clr - the background color.
    • getApplication

      public Application getApplication()
      Get the Application to which this app state is attached.
      Returns:
      the Application to which this app state is attached.
      See Also:
    • getStateManager

      public AppStateManager getStateManager()
      Get the state manager to which this app state is attached.
      Returns:
      the state manager to which this app state is attached.
      See Also:
    • getObserver

      public Object getObserver()
      Get the scene observer. If no observer has been set, this method returns the application camera.
      Returns:
      the scene observer.
      See Also:
    • setObserver

      public void setObserver(Spatial observer)
      Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application camera.
      Parameters:
      observer - the scene observer.
    • isInstanceRendering

      public boolean isInstanceRendering()
      Check if the rendering is instanced (see Geometry instancing).
      Returns:
      true if the rendering is instanced and false otherwise.
    • getVREnvironment

      public VREnvironment getVREnvironment()
      Return the VR environment on which this app state relies.
      Returns:
      the VR environment on which this app state relies.
    • getVRHardware

      public VRAPI getVRHardware()
      Get the VR underlying hardware.
      Returns:
      the VR underlying hardware.
    • getVRinput

      public VRInputAPI getVRinput()
      Get the VR dedicated input.
      Returns:
      the VR dedicated input.
    • getVRViewManager

      public VRViewManager getVRViewManager()
      Get the VR view manager.
      Returns:
      the VR view manager.
    • getVRGUIManager

      public VRGuiManager getVRGUIManager()
      Get the GUI manager attached to this app state.
      Returns:
      the GUI manager attached to this app state.
    • getVRMouseManager

      public VRMouseManager getVRMouseManager()
      Get the VR mouse manager attached to this app state.
      Returns:
      the VR mouse manager attached to this application.
    • getSettings

      public AppSettings getSettings()
      Get the settings attached to this app state.
      Returns:
      the settings attached to this app state.
      See Also:
    • setSettings

      public void setSettings(AppSettings settings)
      Set the settings attached to this app state.
      Parameters:
      settings - the settings attached to this app state.
      See Also:
    • update

      public void update(float tpf)
      Description copied from interface: AppState
      Called to update the AppState. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      update in interface AppState
      Overrides:
      update in class AbstractAppState
      Parameters:
      tpf - Time since the last call to update(), in seconds.
    • render

      public void render(RenderManager rm)
      Description copied from interface: AppState
      Render the state. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      render in interface AppState
      Overrides:
      render in class AbstractAppState
      Parameters:
      rm - RenderManager
    • postRender

      public void postRender()
      Description copied from interface: AppState
      Called after all rendering commands are flushed. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      postRender in interface AppState
      Overrides:
      postRender in class AbstractAppState
    • initialize

      public void initialize(AppStateManager stateManager, Application app)
      Description copied from interface: AppState
      Called by AppStateManager when transitioning this AppState from initializing to running.
      This will happen on the next iteration through the update loop after AppStateManager.attach(com.jme3.app.state.AppState) was called.

      AppStateManager will call this only from the update loop inside the rendering thread. This means is it safe to modify the scene graph from this method.

      Specified by:
      initialize in interface AppState
      Overrides:
      initialize in class AbstractAppState
      Parameters:
      stateManager - The state manager
      app - The application
    • stateAttached

      public void stateAttached(AppStateManager stateManager)
      Description copied from interface: AppState
      Called by AppStateManager.attach(com.jme3.app.state.AppState) when transitioning this AppState from detached to initializing.

      There is no assumption about the thread from which this function is called, therefore it is unsafe to modify the scene graph from this method. Please use AppState.initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application) instead.

      Specified by:
      stateAttached in interface AppState
      Overrides:
      stateAttached in class AbstractAppState
      Parameters:
      stateManager - State manager to which the state was attached to.
    • cleanup

      public void cleanup()
      Description copied from interface: AppState
      Called by AppStateManager when transitioning this AppState from terminating to detached. This method is called the following render pass after the AppState has been detached and is always called once and only once for each time initialize() is called. Either when the AppState is detached or when the application terminates (if it terminates normally).
      Specified by:
      cleanup in interface AppState
      Overrides:
      cleanup in class AbstractAppState
    • stateDetached

      public void stateDetached(AppStateManager stateManager)
      Description copied from interface: AppState
      Called by AppStateManager.detach(com.jme3.app.state.AppState) when transitioning this AppState from running to terminating.

      There is no assumption about the thread from which this function is called, therefore it is unsafe to modify the scene graph from this method. Please use AppState.cleanup() instead.

      Specified by:
      stateDetached in interface AppState
      Overrides:
      stateDetached in class AbstractAppState
      Parameters:
      stateManager - The state manager from which the state was detached from.
    • processSettings

      protected void processSettings(AppSettings settings)
      Process the attached settings and apply changes to this app state.
      Parameters:
      settings - the app settings to process.