Class AcorusDemo

java.lang.Object
com.jme3.app.LegacyApplication
com.jme3.app.SimpleApplication
jme3utilities.ui.ActionApplication
jme3utilities.ui.AcorusDemo
All Implemented Interfaces:
com.jme3.app.Application, com.jme3.input.controls.ActionListener, com.jme3.input.controls.InputListener, com.jme3.system.SystemListener

public abstract class AcorusDemo extends ActionApplication
An ActionApplication with additional data and methods for use in demos.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    action string to request JVM garbage collection
    static final String
    action string to activate the display-settings editor
    static final String
    action to toggle the state of the help node
    static final String
    action to toggle animation and physics simulation: paused/running
    static final String
    action to toggle visualization of world axes
    static final Logger
    message logger for this class
    static final float
    animation/physics speed when paused

    Fields inherited from class jme3utilities.ui.ActionApplication

    asScreenShot, asToggleRecorder

    Fields inherited from class com.jme3.app.SimpleApplication

    flyCam, fpsText, guiFont, guiNode, INPUT_MAPPING_CAMERA_POS, INPUT_MAPPING_EXIT, INPUT_MAPPING_HIDE_STATS, INPUT_MAPPING_MEMORY, rootNode, showSettings

    Fields inherited from class com.jme3.app.LegacyApplication

    assetManager, audioRenderer, cam, context, guiViewPort, inputEnabled, inputManager, joyInput, keyInput, listener, lostFocusBehavior, mouseInput, paused, prof, renderer, renderManager, settings, speed, stateManager, timer, touchInput, viewPort
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Instantiate a demo with the appstates favored by SimpleApplication (AudioListenerState, ConstantVerifierState, DebugKeysAppState, FlyCamAppState, and StatsAppState) pre-attached.
    protected
    AcorusDemo(com.jme3.app.state.AppState... initialAppStates)
    Instantiate a demo with the specified appstates pre-attached.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Initialize this application.
    static float
    advanceFloat(float[] valuesArray, float startValue, int amount)
    Advance a float selection by the specified (cyclic) amount.
    static int
    advanceInt(int[] valuesArray, int startValue, int amount)
    Advance an integer selection by the specified (cyclic) amount.
    static String
    advanceString(String[] valuesArray, String startValue, int amount)
    Advance a String selection by the specified (cyclic) amount.
    boolean
    Test whether the world axes are enabled.
    void
    attachWorldAxes(float axisLength)
    Add a visualizer for the axes of the world coordinate system.
    static void
    centerCgm(com.jme3.scene.Spatial cgModel)
    Translate a model's center so that the model rests on the X-Z plane, and its center lies on the Y axis.
    com.jme3.font.Rectangle
    detailedHelpBounds(int viewPortWidth, int viewPortHeight)
    Calculate screen bounds for a detailed help node.
    com.jme3.material.Material
    Find the named Material in the library.
    void
    Initialize the library of named materials.
    Access the HelpBuilder for this application.
    boolean
    Test whether animation is paused.
    void
    onAction(String actionString, boolean ongoing, float tpf)
    Process an action that wasn't handled by the active InputMode.
    void
    onColorSpaceChange(com.jme3.texture.image.ColorSpace newSpace)
    Update colors after the renderer's ColorSpace changes.
    void
    Callback invoked when the active InputMode changes.
    void
    onViewPortResize(int newWidth, int newHeight)
    Update the GUI layout after the ViewPort gets resized.
    void
    registerMaterial(String name, com.jme3.material.Material material)
    Add a Material to the library.
    static void
    setCgmHeight(com.jme3.scene.Spatial cgModel, float height)
    Scale the specified C-G model uniformly so that it has the specified height, assuming Y-up orientation.
    void
    Display the specified version of the help node.
    void
    simpleUpdate(float tpf)
    Callback invoked once per frame.
    void
    Toggle between the detailed help node and the minimal version.
    void
    Toggle the animation and physics simulation: paused/running.
    void
    Toggle visualization of world axes.
    void
    Update the help node to reflect changed bindings.

    Methods inherited from class com.jme3.app.SimpleApplication

    getFlyByCamera, getGuiNode, getRootNode, initialize, isShowSettings, loadGuiFont, setDisplayFps, setDisplayStatView, setShowSettings, simpleRender, start, update

    Methods inherited from class com.jme3.app.LegacyApplication

    createCanvas, destroy, destroyInput, enqueue, enqueue, gainFocus, getAppProfiler, getAssetManager, getAudioRenderer, getCamera, getContext, getGuiViewPort, getInputManager, getListener, getLostFocusBehavior, getRenderer, getRenderManager, getStateManager, getTimer, getViewPort, handleError, isPauseOnLostFocus, loseFocus, requestClose, rescale, reshape, restart, runQueuedTasks, setAppProfiler, setAssetManager, setLostFocusBehavior, setPauseOnLostFocus, setSettings, setTimer, start, start, start, startCanvas, startCanvas, stop, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pausedSpeed

      public static final float pausedSpeed
      animation/physics speed when paused
      See Also:
    • loggerA

      public static final Logger loggerA
      message logger for this class
    • asCollectGarbage

      public static final String asCollectGarbage
      action string to request JVM garbage collection
      See Also:
    • asEditDisplaySettings

      public static final String asEditDisplaySettings
      action string to activate the display-settings editor
      See Also:
    • asToggleHelp

      public static final String asToggleHelp
      action to toggle the state of the help node
      See Also:
    • asTogglePause

      public static final String asTogglePause
      action to toggle animation and physics simulation: paused/running
      See Also:
    • asToggleWorldAxes

      public static final String asToggleWorldAxes
      action to toggle visualization of world axes
      See Also:
  • Constructor Details

    • AcorusDemo

      protected AcorusDemo()
      Instantiate a demo with the appstates favored by SimpleApplication (AudioListenerState, ConstantVerifierState, DebugKeysAppState, FlyCamAppState, and StatsAppState) pre-attached. A DefaultInputMode and a ScreenshotAppState will be attached during initialization.
    • AcorusDemo

      protected AcorusDemo(com.jme3.app.state.AppState... initialAppStates)
      Instantiate a demo with the specified appstates pre-attached. A DefaultInputMode and a ScreenshotAppState will be attached during initialization.
      Parameters:
      initialAppStates - the appstates to be pre-attached (may be null, unaffected)
  • Method Details

    • advanceFloat

      public static float advanceFloat(float[] valuesArray, float startValue, int amount)
      Advance a float selection by the specified (cyclic) amount.
      Parameters:
      valuesArray - an array of values in ascending order (not null, not empty, unaffected)
      startValue - the starting value (found in values[])
      amount - the number of values to advance (may be negative)
      Returns:
      the new (advanced) value
    • advanceInt

      public static int advanceInt(int[] valuesArray, int startValue, int amount)
      Advance an integer selection by the specified (cyclic) amount.
      Parameters:
      valuesArray - an array of values in ascending order (not null, not empty, unaffected)
      startValue - the starting value (found in values[])
      amount - the number of values to advance (may be negative)
      Returns:
      the new (advanced) value
    • advanceString

      public static String advanceString(String[] valuesArray, String startValue, int amount)
      Advance a String selection by the specified (cyclic) amount.
      Parameters:
      valuesArray - an array of values in ascending order (not null, not empty, unaffected)
      startValue - the starting value (found in values[])
      amount - the number of values to advance (may be negative)
      Returns:
      the new (advanced) value
    • areWorldAxesEnabled

      public boolean areWorldAxesEnabled()
      Test whether the world axes are enabled.
      Returns:
      true if enabled, otherwise false
    • attachWorldAxes

      public void attachWorldAxes(float axisLength)
      Add a visualizer for the axes of the world coordinate system.
      Parameters:
      axisLength - the desired length for each axis arrow (in world units, >0)
    • centerCgm

      public static void centerCgm(com.jme3.scene.Spatial cgModel)
      Translate a model's center so that the model rests on the X-Z plane, and its center lies on the Y axis.
      Parameters:
      cgModel - (not null, modified)
    • detailedHelpBounds

      public com.jme3.font.Rectangle detailedHelpBounds(int viewPortWidth, int viewPortHeight)
      Calculate screen bounds for a detailed help node. Meant to be overridden.
      Parameters:
      viewPortWidth - (in pixels, >0)
      viewPortHeight - (in pixels, >0)
      Returns:
      a new instance
    • findMaterial

      public com.jme3.material.Material findMaterial(String name)
      Find the named Material in the library.
      Parameters:
      name - the name of the Material to find (not null)
      Returns:
      the pre-existing instance, or null if not found
    • generateMaterials

      public void generateMaterials()
      Initialize the library of named materials. Invoke during startup.
    • getHelpBuilder

      public HelpBuilder getHelpBuilder()
      Access the HelpBuilder for this application.
      Returns:
      the pre-existing instance (not null)
    • isPaused

      public boolean isPaused()
      Test whether animation is paused.
      Returns:
      true if paused, otherwise false
    • onColorSpaceChange

      public void onColorSpaceChange(com.jme3.texture.image.ColorSpace newSpace)
      Update colors after the renderer's ColorSpace changes.
      Parameters:
      newSpace - the new ColorSpace (not null)
    • onViewPortResize

      public void onViewPortResize(int newWidth, int newHeight)
      Update the GUI layout after the ViewPort gets resized.
      Parameters:
      newWidth - the new width of the ViewPort (in pixels, >0)
      newHeight - the new height of the ViewPort (in pixels, >0)
    • registerMaterial

      public void registerMaterial(String name, com.jme3.material.Material material)
      Add a Material to the library.
      Parameters:
      name - the desired name for the Material, which is also the key that will be used to find it (not null)
      material - (not null, alias created)
    • setCgmHeight

      public static void setCgmHeight(com.jme3.scene.Spatial cgModel, float height)
      Scale the specified C-G model uniformly so that it has the specified height, assuming Y-up orientation.
      Parameters:
      cgModel - (not null, modified)
      height - the desired height (in world units, >0)
    • setHelpVersion

      public void setHelpVersion(HelpVersion newVersion)
      Display the specified version of the help node.
      Parameters:
      newVersion - which version to display (not null)
    • toggleHelp

      public void toggleHelp()
      Toggle between the detailed help node and the minimal version.
    • togglePause

      public void togglePause()
      Toggle the animation and physics simulation: paused/running.
    • toggleWorldAxes

      public void toggleWorldAxes()
      Toggle visualization of world axes.
    • updateHelp

      public void updateHelp()
      Update the help node to reflect changed bindings.
    • acorusInit

      public void acorusInit()
      Initialize this application.
      Specified by:
      acorusInit in class ActionApplication
    • onAction

      public void onAction(String actionString, boolean ongoing, float tpf)
      Process an action that wasn't handled by the active InputMode.
      Specified by:
      onAction in interface com.jme3.input.controls.ActionListener
      Overrides:
      onAction in class ActionApplication
      Parameters:
      actionString - textual description of the action (not null)
      ongoing - true if the action is ongoing, otherwise false
      tpf - the time interval between frames (in seconds, ≥0)
    • onInputModeChange

      public void onInputModeChange(InputMode oldMode, InputMode newMode)
      Callback invoked when the active InputMode changes.
      Overrides:
      onInputModeChange in class ActionApplication
      Parameters:
      oldMode - the old mode, or null if none
      newMode - the new mode, or null if none
    • simpleUpdate

      public void simpleUpdate(float tpf)
      Callback invoked once per frame.
      Overrides:
      simpleUpdate in class ActionApplication
      Parameters:
      tpf - time interval between frames (in seconds, ≥0)