Package com.jme3.app
Class VRAppState
java.lang.Object
com.jme3.app.state.AbstractAppState
com.jme3.app.VRAppState
- All Implemented Interfaces:
AppState
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
As this app state and the main
application
have to share application settings
,
the common way to use this app state is:- To create
application settings
and set the VR related settings (seeVRConstants
). - To instantiate this app state with the created settings.
- To instantiate the main
application
and to attach it to the created settings (withsetSettings(AppSettings)
). - To start the main
application
.
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Is the application has not to start within VR mode (default isfalse
).static final String
Fields inherited from class com.jme3.app.state.AbstractAppState
initialized
-
Constructor Summary
ConstructorDescriptionVRAppState
(VREnvironment environment) Create a new default VR app state that relies on the givenVR environment
.VRAppState
(AppSettings settings, VREnvironment environment) Create a new VR app state with given settings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Called byAppStateManager
when transitioning thisAppState
from terminating to detached.Get theApplication
to which this app state is attached.Get the observer final position within the scene.Get the observer final rotation within the scene.Get the VR headset left viewport.Get the scene observer.Get the VR headset right viewport.Get thesettings
attached to this app state.Get thestate manager
to which this app state is attached.Return theVR environment
on which this app state relies.Get the GUI manager attached to this app state.Get the VR underlying hardware.Get the VR dedicated input.Get the VR mouse manager attached to this app state.Get the VR view manager.void
initialize
(AppStateManager stateManager, Application app) Called byAppStateManager
when transitioning thisAppState
from initializing to running.
This will happen on the next iteration through the update loop afterAppStateManager.attach(com.jme3.app.state.AppState)
was called.boolean
Check if the rendering is instanced (see Geometry instancing).void
Move filters from the main scene into the eye's.void
Called after all rendering commands are flushed.protected void
processSettings
(AppSettings settings) Process the attached settings and apply changes to this app state.void
render
(RenderManager rm) Render the state.void
Set the background color for both left and right view ports.void
setFrustrumNearFar
(float near, float far) Set the frustum values for the application.void
setMirrorWindowSize
(int width, int height) Set the mirror window size in pixel.void
setObserver
(Spatial observer) Set the scene observer.void
setResolutionMultiplier
(float val) Set the resolution multiplier.void
setSettings
(AppSettings settings) Set thesettings
attached to this app state.void
simpleRender
(RenderManager renderManager) Rendering callback of the app state.void
simpleUpdate
(float tpf) Simple update of the app state, this method should contain any spatial updates.void
stateAttached
(AppStateManager stateManager) Called byAppStateManager.attach(com.jme3.app.state.AppState)
when transitioning thisAppState
from detached to initializing.void
stateDetached
(AppStateManager stateManager) Called byAppStateManager.detach(com.jme3.app.state.AppState)
when transitioning thisAppState
from running to terminating.void
update
(float tpf) Called to update theAppState
.Methods inherited from class com.jme3.app.state.AbstractAppState
getId, isEnabled, isInitialized, setEnabled, setId
-
Field Details
-
ID
- See Also:
-
DISABLE_VR
public boolean DISABLE_VRIs the application has not to start within VR mode (default isfalse
).
-
-
Constructor Details
-
VRAppState
Create a new default VR app state that relies on the givenVR environment
.- Parameters:
environment
- theVR environment
that this app state is using.
-
VRAppState
Create a new VR app state with given settings. The app state relies on the givenVR environment
.- Parameters:
settings
- the settings to use.environment
- theVR 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 theupdate()
method and should not be called manually.- Parameters:
tpf
- the application time.
-
simpleRender
Rendering callback of the app state. This method is called by theupdate()
method and should not be called manually.- Parameters:
renderManager
- therender 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
Get the observer final rotation within the scene.- Returns:
- the observer final rotation within the scene.
- See Also:
-
getFinalObserverPosition
Get the observer final position within the scene.- Returns:
- the observer position.
- See Also:
-
getLeftViewPort
Get the VR headset left viewport.- Returns:
- the VR headset left viewport.
- See Also:
-
getRightViewPort
Get the VR headset right viewport.- Returns:
- the VR headset right viewport.
- See Also:
-
setBackgroundColors
Set the background color for both left and right view ports.- Parameters:
clr
- the background color.
-
getApplication
Get theApplication
to which this app state is attached.- Returns:
- the
Application
to which this app state is attached. - See Also:
-
getStateManager
Get thestate manager
to which this app state is attached.- Returns:
- the
state manager
to which this app state is attached. - See Also:
-
getObserver
Get the scene observer. If no observer has been set, this method returns the application camera.- Returns:
- the scene observer.
- See Also:
-
setObserver
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 andfalse
otherwise.
-
getVREnvironment
Return theVR environment
on which this app state relies.- Returns:
- the
VR environment
on which this app state relies.
-
getVRHardware
Get the VR underlying hardware.- Returns:
- the VR underlying hardware.
-
getVRinput
Get the VR dedicated input.- Returns:
- the VR dedicated input.
-
getVRViewManager
Get the VR view manager.- Returns:
- the VR view manager.
-
getVRGUIManager
Get the GUI manager attached to this app state.- Returns:
- the GUI manager attached to this app state.
-
getVRMouseManager
Get the VR mouse manager attached to this app state.- Returns:
- the VR mouse manager attached to this application.
-
getSettings
Get thesettings
attached to this app state.- Returns:
- the
settings
attached to this app state. - See Also:
-
setSettings
Set thesettings
attached to this app state.- Parameters:
settings
- thesettings
attached to this app state.- See Also:
-
update
public void update(float tpf) Description copied from interface:AppState
Called to update theAppState
. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
update
in interfaceAppState
- Overrides:
update
in classAbstractAppState
- Parameters:
tpf
- Time since the last call to update(), in seconds.
-
render
Description copied from interface:AppState
Render the state. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
render
in interfaceAppState
- Overrides:
render
in classAbstractAppState
- 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 theAppState
is both attached and enabled.- Specified by:
postRender
in interfaceAppState
- Overrides:
postRender
in classAbstractAppState
-
initialize
Description copied from interface:AppState
Called byAppStateManager
when transitioning thisAppState
from initializing to running.
This will happen on the next iteration through the update loop afterAppStateManager.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 interfaceAppState
- Overrides:
initialize
in classAbstractAppState
- Parameters:
stateManager
- The state managerapp
- The application
-
stateAttached
Description copied from interface:AppState
Called byAppStateManager.attach(com.jme3.app.state.AppState)
when transitioning thisAppState
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 interfaceAppState
- Overrides:
stateAttached
in classAbstractAppState
- Parameters:
stateManager
- State manager to which the state was attached to.
-
cleanup
public void cleanup()Description copied from interface:AppState
Called byAppStateManager
when transitioning thisAppState
from terminating to detached. This method is called the following render pass after theAppState
has been detached and is always called once and only once for each timeinitialize()
is called. Either when theAppState
is detached or when the application terminates (if it terminates normally).- Specified by:
cleanup
in interfaceAppState
- Overrides:
cleanup
in classAbstractAppState
-
stateDetached
Description copied from interface:AppState
Called byAppStateManager.detach(com.jme3.app.state.AppState)
when transitioning thisAppState
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 interfaceAppState
- Overrides:
stateDetached
in classAbstractAppState
- Parameters:
stateManager
- The state manager from which the state was detached from.
-
processSettings
Process the attached settings and apply changes to this app state.- Parameters:
settings
- the app settings to process.
-