Class VectorVisualizer

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

public class VectorVisualizer extends SubtreeControl
A SubtreeControl to visualize a vector.

The controlled spatial must be a Node.

A new Control is disabled by default. When enabled, it attaches an arrow geometry to its subtree.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
    magic width value used to specify a solid arrow

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

    enabled, spatial
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    No-argument constructor needed by SavableClassUtil.
     
    VectorVisualizer(com.jme3.asset.AssetManager manager, float width)
    Instantiate a (disabled) arrow.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    com.jme3.math.ColorRGBA
    color(com.jme3.math.ColorRGBA storeResult)
    Determine the color of the arrow.
    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.
    boolean
    Determine the depth-test setting.
    float
    Determine the line width of the arrow.
    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 color)
    Alter the color of the arrow.
    void
    setDepthTest(boolean newSetting)
    Alter the depth-test setting.
    void
    setEnabled(boolean newState)
    Alter the visibility of the visualization.
    void
    setLineWidth(float width)
    Alter the line width.
    void
    setTipOffset(com.jme3.math.Vector3f offset)
    Alter the offset of the arrow's tip in local coordinates.
    com.jme3.math.Vector3f
    Determine the location of the arrow's tip.
    com.jme3.math.Vector3f
    tipOffset(com.jme3.math.Vector3f storeResult)
    Determine the offset of the arrow's tip in local coordinates.
    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
  • Field Details

    • widthForSolid

      public static final float widthForSolid
      magic width value used to specify a solid arrow
      See Also:
  • Constructor Details

    • VectorVisualizer

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

      public VectorVisualizer(com.jme3.asset.AssetManager manager, float width)
      Instantiate a (disabled) arrow.
      Parameters:
      manager - for loading material definitions (not null, alias created)
      width - thickness of the arrow (in pixels, ≥0)
  • Method Details

    • color

      public com.jme3.math.ColorRGBA color(com.jme3.math.ColorRGBA storeResult)
      Determine the color of the arrow.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the color value (either storeResult or a new instance)
    • 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 line width of the arrow.
      Returns:
      width (in pixels, ≥1) or 0 for a solid arrow
    • setColor

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

      public void setDepthTest(boolean newSetting)
      Alter the depth-test setting. The test provides depth cues, but often hides the arrow.
      Parameters:
      newSetting - true to enable test, false to disable it
    • setLineWidth

      public void setLineWidth(float width)
      Alter the line width.
      Parameters:
      width - (in pixels, ≥1) or 0 for a solid arrow
    • setTipOffset

      public void setTipOffset(com.jme3.math.Vector3f offset)
      Alter the offset of the arrow's tip in local coordinates.
      Parameters:
      offset - the desired offset (not null, unaffected)
    • tipLocation

      public com.jme3.math.Vector3f tipLocation()
      Determine the location of the arrow's tip.
      Returns:
      a new vector (in world coordinates) or null if not displayed
    • tipOffset

      public com.jme3.math.Vector3f tipOffset(com.jme3.math.Vector3f storeResult)
      Determine the offset of the arrow's tip in local coordinates.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      the offset (in local coordinates, either storeResult or a new instance)
    • 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