Class BoundsVisualizer

java.lang.Object
com.jme3.scene.control.AbstractControl
jme3utilities.SimpleControl
jme3utilities.SubtreeControl
jme3utilities.debug.BoundsVisualizer
All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.scene.control.Control, com.jme3.util.clone.JmeCloneable, Cloneable

public class BoundsVisualizer extends SubtreeControl
A SubtreeControl to visualize the world bounds of a subject spatial.

The controlled spatial must be a Node, but the subject may be a Geometry.

The Control is disabled by default. When enabled, it attaches a Geometry to the subtree.

  • Field Summary

    Fields inherited from class com.jme3.scene.control.AbstractControl

    enabled, spatial
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    No-argument constructor needed by SavableClassUtil.
     
    BoundsVisualizer(com.jme3.asset.AssetManager assetManager)
    Instantiate a disabled control.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Determine which local axis is being used for billboarding.
    Create a shallow copy of this Control.
    void
    cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
    Convert this shallow-cloned Control into a deep-cloned one, using the specified Cloner and original to resolve copied fields.
    protected void
    controlUpdate(float updateInterval)
    Callback invoked when the controlled spatial's geometric state is about to be updated, once per frame while attached and enabled.
    com.jme3.math.ColorRGBA
    copyLineColor(com.jme3.math.ColorRGBA storeResult)
    Copy the color of the lines.
    void
    Disable billboarding.
    void
    enableBillboarding(com.jme3.renderer.Camera camera, int axisIndex)
    Enable billboarding.
    com.jme3.renderer.Camera
    Access the Camera used for billboarding.
    com.jme3.scene.Spatial
    Access the Spatial whose bounds are being visualized.
    boolean
    Determine the depth-test setting.
    float
    Determine the effective line width of the visualization.
    void
    read(com.jme3.export.JmeImporter importer)
    De-serialize this Control from the specified importer, for example when loading from a J3O file.
    void
    setColor(com.jme3.math.ColorRGBA newColor)
    Alter the color of all lines.
    void
    setDepthTest(boolean newSetting)
    Alter the depth test setting.
    void
    setEnabled(boolean newState)
    Alter the visibility of the visualization.
    void
    setLineWidth(float newWidth)
    Alter the effective line width of the visualization.
    void
    Alter the type of Mesh used to visualize spheres.
    void
    setSubject(com.jme3.scene.Spatial newSubject)
    Alter which spatial's bounds are being visualized.
    Read the type of Mesh used to visualize spheres.
    void
    write(com.jme3.export.JmeExporter exporter)
    Serialize this Control to the specified exporter, for example when saving to a J3O file.

    Methods inherited from class jme3utilities.SubtreeControl

    cloneForSpatial, getSubtree, setSpatial, setSubtree

    Methods inherited from class jme3utilities.SimpleControl

    controlRender, isEnabled, toggleEnabled

    Methods inherited from class com.jme3.scene.control.AbstractControl

    getSpatial, jmeClone, render, update

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BoundsVisualizer

      protected BoundsVisualizer()
      No-argument constructor needed by SavableClassUtil.
    • BoundsVisualizer

      public BoundsVisualizer(com.jme3.asset.AssetManager assetManager)
      Instantiate a disabled control.
      Parameters:
      assetManager - for loading material definitions (not null)
  • Method Details

    • billboardAxis

      public int billboardAxis()
      Determine which local axis is being used for billboarding.
      Returns:
      the axis index (≥0, ≤2) or -1 if not billboarding
    • copyLineColor

      public com.jme3.math.ColorRGBA copyLineColor(com.jme3.math.ColorRGBA storeResult)
      Copy the color of the lines.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the color (either storeResult or a new instance)
    • disableBillboarding

      public void disableBillboarding()
      Disable billboarding.
    • enableBillboarding

      public void enableBillboarding(com.jme3.renderer.Camera camera, int axisIndex)
      Enable billboarding. Note: billboarding is implemented only for spheres, not axis-aligned boxes.
      Parameters:
      camera - the camera to use for billboarding (not null, alias created)
      axisIndex - which local axis should point toward the camera: 0→+X, 1→+Y, 2→+Z
    • getCamera

      public com.jme3.renderer.Camera getCamera()
      Access the Camera used for billboarding.
      Returns:
      the pre-existing instance (may be null)
    • getSubject

      public com.jme3.scene.Spatial getSubject()
      Access the Spatial whose bounds are being visualized.
      Returns:
      the pre-existing instance (may be null)
    • isDepthTest

      public boolean isDepthTest()
      Determine the depth-test setting.

      The test provides depth cues, but might hide portions of the visualization.

      Returns:
      true if the test is enabled, otherwise false
    • lineWidth

      public float lineWidth()
      Determine the effective line width of the visualization.
      Returns:
      width (in pixels, ≥0)
    • setColor

      public void setColor(com.jme3.math.ColorRGBA newColor)
      Alter the color of all lines.
      Parameters:
      newColor - (not null, unaffected)
    • setDepthTest

      public void setDepthTest(boolean newSetting)
      Alter the depth test setting. The test provides depth cues, but might hide portions of the visualization.
      Parameters:
      newSetting - true to enable test, false to disable it
    • setLineWidth

      public void setLineWidth(float newWidth)
      Alter the effective line width of the visualization.
      Parameters:
      newWidth - (in pixels, ≥0, values <1 hide the lines)
    • setSphereType

      public void setSphereType(SphereMeshes type)
      Alter the type of Mesh used to visualize spheres.
      Parameters:
      type - (not null)
    • setSubject

      public void setSubject(com.jme3.scene.Spatial newSubject)
      Alter which spatial's bounds are being visualized.
      Parameters:
      newSubject - which spatial (may be null, alias created)
    • sphereType

      public SphereMeshes sphereType()
      Read the type of Mesh used to visualize spheres.
      Returns:
      an enum value (not null)
    • clone

      Create a shallow copy of this Control.
      Overrides:
      clone in class SubtreeControl
      Returns:
      a new control, equivalent to this one
      Throws:
      CloneNotSupportedException - if superclass isn't cloneable
    • cloneFields

      public void cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
      Convert this shallow-cloned Control into a deep-cloned one, using the specified Cloner and original to resolve copied fields.
      Specified by:
      cloneFields in interface com.jme3.util.clone.JmeCloneable
      Overrides:
      cloneFields in class SubtreeControl
      Parameters:
      cloner - the Cloner currently cloning this Control
      original - the instance from which this Control was shallow-cloned
    • controlUpdate

      protected void controlUpdate(float updateInterval)
      Callback invoked when the controlled spatial's geometric state is about to be updated, once per frame while attached and enabled.
      Overrides:
      controlUpdate in class SimpleControl
      Parameters:
      updateInterval - time interval between updates (in seconds, ≥0)
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this Control from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Overrides:
      read in class SubtreeControl
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • setEnabled

      public void setEnabled(boolean newState)
      Alter the visibility of the visualization.
      Overrides:
      setEnabled in class SubtreeControl
      Parameters:
      newState - if true, reveal the visualization; if false, hide it
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this Control to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Overrides:
      write in class SubtreeControl
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter