Class LegacyApplication
- All Implemented Interfaces:
Application,SystemListener
- Direct Known Subclasses:
SimpleApplication
LegacyApplication class represents an instance of a
real-time 3D rendering jME application.
An LegacyApplication provides all the tools that are commonly used in jME3
applications.
jME3 applications *SHOULD NOT EXTEND* this class but extend SimpleApplication instead.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AssetManagerprotected AudioRendererprotected Cameraprotected JmeContextprotected ViewPortprotected booleanprotected InputManagerprotected JoyInputprotected KeyInputprotected Listenerprotected LostFocusBehaviorprotected MouseInputprotected booleanprotected AppProfilerprotected Rendererprotected RenderManagerprotected AppSettingsprotected floatprotected AppStateManagerprotected Timerprotected TouchInputprotected ViewPort -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance ofLegacyApplication.LegacyApplication(AppState... initialStates) Create a new instance ofLegacyApplication, preinitialized with the specified set of app states. -
Method Summary
Modifier and TypeMethodDescriptionvoidInitializes the application's canvas for use.voiddestroy()Do not call manually.protected voidvoidEnqueues a runnable object to execute in the jME3 rendering thread.<V> Future<V>Enqueues a task/callable object to execute in the jME3 rendering thread.voidInternal use only.Returns the current AppProfiler hook, or null if none is set.Determine the application's behavior when unfocused.getTimer()voidhandleError(String errMsg, Throwable t) Internal use only.voidDo not call manually.booleanReturns true if pause on lost focus is enabled, false otherwise.voidInternal use only.voidrequestClose(boolean esc) Internal use only.voidrescale(float x, float y) Called to notify the application that the scale has changed.voidreshape(int w, int h) Internal use only.voidrestart()Restarts the context, applying any changed settings.protected voidRuns tasks enqueued viaenqueue(Callable)voidsetAppProfiler(AppProfiler prof) Sets an AppProfiler hook that will be called back for specific steps within a single update frame.voidsetAssetManager(AssetManager assetManager) Deprecated.voidsetLostFocusBehavior(LostFocusBehavior lostFocusBehavior) Changes the application's behavior when unfocused.voidsetPauseOnLostFocus(boolean pauseOnLostFocus) Enable or disable pause on lost focus.voidsetSettings(AppSettings settings) Set the display settings to define the display created.voidSets the Timer implementation that will be used for calculating frame times.voidstart()Starts the application indisplaymode.voidstart(boolean waitFor) Starts the application indisplaymode.voidstart(JmeContext.Type contextType) Starts the application.voidstart(JmeContext.Type contextType, boolean waitFor) Starts the application.voidStarts the rendering thread after createCanvas() has been called.voidstartCanvas(boolean waitFor) Starts the rendering thread after createCanvas() has been called.voidstop()Requests the context to close, shutting down the main loop and making necessary cleanup operations.voidstop(boolean waitFor) Requests the context to close, shutting down the main loop and making necessary cleanup operations.voidupdate()Do not call manually.
-
Field Details
-
assetManager
-
audioRenderer
-
renderer
-
renderManager
-
viewPort
-
guiViewPort
-
context
-
settings
-
timer
-
cam
-
listener
-
inputEnabled
protected boolean inputEnabled -
lostFocusBehavior
-
speed
protected float speed -
paused
protected boolean paused -
mouseInput
-
keyInput
-
joyInput
-
touchInput
-
inputManager
-
stateManager
-
prof
-
-
Constructor Details
-
LegacyApplication
public LegacyApplication()Create a new instance ofLegacyApplication. -
LegacyApplication
Create a new instance ofLegacyApplication, preinitialized with the specified set of app states.- Parameters:
initialStates- app states to pre-attach, or null for none
-
-
Method Details
-
getLostFocusBehavior
Determine the application's behavior when unfocused.- Specified by:
getLostFocusBehaviorin interfaceApplication- Returns:
- The lost focus behavior of the application.
-
setLostFocusBehavior
Changes the application's behavior when unfocused. By default, the application willthrottle the update loopso as not to use 100% of the CPU when out of focus, e.g. alt-tabbed, minimized, or hidden by another window.- Specified by:
setLostFocusBehaviorin interfaceApplication- Parameters:
lostFocusBehavior- The new lost focus behavior to use.- See Also:
-
isPauseOnLostFocus
public boolean isPauseOnLostFocus()Returns true if pause on lost focus is enabled, false otherwise.- Specified by:
isPauseOnLostFocusin interfaceApplication- Returns:
- true if pause on lost focus is enabled
- See Also:
-
setPauseOnLostFocus
public void setPauseOnLostFocus(boolean pauseOnLostFocus) Enable or disable pause on lost focus.By default, pause on lost focus is enabled. If enabled, the application will stop updating when it loses focus or becomes inactive (e.g. alt-tab). For online or real-time applications, this might be undesirable, so this feature should be disabled. For other applications, it is best to keep it enabled so the CPU is not used unnecessarily.
- Specified by:
setPauseOnLostFocusin interfaceApplication- Parameters:
pauseOnLostFocus- True to enable pause on lost focus, false otherwise.- See Also:
-
setAssetManager
Deprecated. -
setSettings
Set the display settings to define the display created.Examples of display parameters include display pixel width and height, color bit depth, z-buffer bits, anti-aliasing samples, and update frequency. If this method is called while the application is already running, then
restart()must be called to apply the settings to the display.- Specified by:
setSettingsin interfaceApplication- Parameters:
settings- The settings to set.
-
setTimer
Sets the Timer implementation that will be used for calculating frame times. By default, Application will use the Timer as returned by the current JmeContext implementation.- Specified by:
setTimerin interfaceApplication- Parameters:
timer- the desired timer (alias created)
-
getTimer
- Specified by:
getTimerin interfaceApplication
-
getAssetManager
- Specified by:
getAssetManagerin interfaceApplication- Returns:
- The
asset managerfor this application.
-
getInputManager
- Specified by:
getInputManagerin interfaceApplication- Returns:
- the
input manager.
-
getStateManager
- Specified by:
getStateManagerin interfaceApplication- Returns:
- the
app state manager
-
getRenderManager
- Specified by:
getRenderManagerin interfaceApplication- Returns:
- the
render manager
-
getRenderer
- Specified by:
getRendererin interfaceApplication- Returns:
- The
rendererfor the application
-
getAudioRenderer
- Specified by:
getAudioRendererin interfaceApplication- Returns:
- The
audio rendererfor the application
-
getListener
- Specified by:
getListenerin interfaceApplication- Returns:
- The
listenerobject for audio
-
getContext
- Specified by:
getContextin interfaceApplication- Returns:
- The
display contextfor the application
-
getCamera
- Specified by:
getCamerain interfaceApplication- Returns:
- The
camerafor the application
-
start
public void start()Starts the application indisplaymode.- Specified by:
startin interfaceApplication- See Also:
-
start
public void start(boolean waitFor) Starts the application indisplaymode.- Specified by:
startin interfaceApplication- Parameters:
waitFor- true→wait for the context to be initialized, false→don't wait- See Also:
-
start
Starts the application. Creating a rendering context and executing the main loop in a separate thread.- Parameters:
contextType- the type of context to create
-
start
Starts the application. Creating a rendering context and executing the main loop in a separate thread.- Parameters:
contextType- the type of context to createwaitFor- true→wait for the context to be initialized, false→don't wait
-
setAppProfiler
Sets an AppProfiler hook that will be called back for specific steps within a single update frame. Value defaults to null.- Specified by:
setAppProfilerin interfaceApplication- Parameters:
prof- the profiler to use (alias created) or null for none
-
getAppProfiler
Returns the current AppProfiler hook, or null if none is set.- Specified by:
getAppProfilerin interfaceApplication- Returns:
- the pre-existing instance, or null if none
-
createCanvas
public void createCanvas()Initializes the application's canvas for use.After calling this method, cast the
getContext()context to JmeCanvasContext, then acquire the canvas with JmeCanvasContext.getCanvas() and attach it to an AWT/Swing Frame. The rendering thread will start when the canvas becomes visible on screen, however if you wish to start the context immediately you may callstartCanvas()to force the rendering thread to start.- See Also:
-
startCanvas
public void startCanvas()Starts the rendering thread after createCanvas() has been called.Same as calling startCanvas(false)
- See Also:
-
startCanvas
public void startCanvas(boolean waitFor) Starts the rendering thread after createCanvas() has been called.Calling this method is optional, the canvas will start automatically when it becomes visible.
- Parameters:
waitFor- If true, the current thread will block until the rendering thread is running
-
reshape
public void reshape(int w, int h) Internal use only.- Specified by:
reshapein interfaceSystemListener- Parameters:
w- the new width of the display (in pixels, ≥0)h- the new height of the display (in pixels, ≥0)
-
rescale
public void rescale(float x, float y) Description copied from interface:SystemListenerCalled to notify the application that the scale has changed.- Specified by:
rescalein interfaceSystemListener- Parameters:
x- the new horizontal scale of the displayy- the new vertical scale of the display
-
restart
public void restart()Restarts the context, applying any changed settings.Changes to the
AppSettingsof this Application are not applied immediately; calling this method forces the context to restart, applying the new settings.- Specified by:
restartin interfaceApplication
-
stop
public void stop()Requests the context to close, shutting down the main loop and making necessary cleanup operations. Same as calling stop(false)- Specified by:
stopin interfaceApplication- See Also:
-
stop
public void stop(boolean waitFor) Requests the context to close, shutting down the main loop and making necessary cleanup operations. After the application has stopped, it cannot be used anymore.- Specified by:
stopin interfaceApplication- Parameters:
waitFor- true→wait for the context to be fully destroyed, true→don't wait
-
initialize
public void initialize()Do not call manually. Callback from ContextListener.Initializes the
Application, by creating a display and default camera. If display settings are not specified, a default 640x480 display is created. Default values are used for the camera; perspective projection with 45° field of view, with near and far values 1 and 1000 units respectively.- Specified by:
initializein interfaceSystemListener
-
handleError
Internal use only.- Specified by:
handleErrorin interfaceSystemListener- Parameters:
errMsg- The error message, if any, or null.t- Throwable object, or null.
-
gainFocus
public void gainFocus()Internal use only.- Specified by:
gainFocusin interfaceSystemListener
-
loseFocus
public void loseFocus()Internal use only.- Specified by:
loseFocusin interfaceSystemListener
-
requestClose
public void requestClose(boolean esc) Internal use only.- Specified by:
requestClosein interfaceSystemListener- Parameters:
esc- If true, the user pressed ESC to close the application.
-
enqueue
Enqueues a task/callable object to execute in the jME3 rendering thread.Callables are executed right at the beginning of the main loop. They are executed even if the application is currently paused or out of focus.
- Specified by:
enqueuein interfaceApplication- Type Parameters:
V- type of result returned by the Callable- Parameters:
callable- The callable to run in the main jME3 thread- Returns:
- a new instance
-
enqueue
Enqueues a runnable object to execute in the jME3 rendering thread.Runnables are executed right at the beginning of the main loop. They are executed even if the application is currently paused or out of focus.
- Specified by:
enqueuein interfaceApplication- Parameters:
runnable- The runnable to run in the main jME3 thread
-
runQueuedTasks
protected void runQueuedTasks()Runs tasks enqueued viaenqueue(Callable) -
update
public void update()Do not call manually. Callback from ContextListener.- Specified by:
updatein interfaceSystemListener
-
destroyInput
protected void destroyInput() -
destroy
public void destroy()Do not call manually. Callback from ContextListener.- Specified by:
destroyin interfaceSystemListener
-
getGuiViewPort
- Specified by:
getGuiViewPortin interfaceApplication- Returns:
- The GUI viewport. Which is used for the on screen statistics and FPS.
-
getViewPort
- Specified by:
getViewPortin interfaceApplication
-