Class ArmatureNode

java.lang.Object
com.jme3.scene.Spatial
com.jme3.scene.Node
com.jme3.scene.debug.custom.ArmatureNode
All Implemented Interfaces:
HasLocalTransform, CloneableSmartAsset, Collidable, Savable, JmeCloneable, Cloneable

public class ArmatureNode extends Node
Renders an Armature for debugging purposes. It can display either wires connecting the heads of bones (if no length data is available) or full bone shapes (from head to tail) when length data is supplied.
  • Field Details

    • PIXEL_BOX

      public static final float PIXEL_BOX
      The size of the picking box in pixels for joint selection.
      See Also:
  • Constructor Details

    • ArmatureNode

      public ArmatureNode(Armature armature, Node joints, Node wires, Node outlines, List<Joint> deformingJoints)
      Creates a wire with bone lengths data. If the data is supplied then the wires will show each full bone (from head to tail).
      Parameters:
      armature - the armature that will be shown
      joints - the Node to visualize joints
      wires - the Node to visualize wires
      outlines - the Node to visualize outlines
      deformingJoints - a list of joints
  • Method Details

    • createSkeletonGeoms

      protected final void createSkeletonGeoms(Joint joint, Node joints, Node wires, Node outlines, List<Joint> deformingJoints)
      Recursively creates the geometries for a given joint and its children.
      Parameters:
      joint - The current joint for which to create geometries.
      joints - The node for joint geometries.
      wires - The node for bone wire geometries.
      outlines - The node for bone outline geometries.
      deformingJoints - A list of deforming joints.
    • setCamera

      public void setCamera(Camera camera)
      Sets the camera to be used for 2D picking calculations.
      Parameters:
      camera - The camera to set.
    • select

      protected Joint select(Geometry geo)
      Selects a joint based on its associated geometry. If the selected geometry is already the current selection, no change occurs. Resets the selection if geometry is null.
      Parameters:
      geo - The geometry representing the joint or bone to select.
      Returns:
      The newly selected Joint, or null if no joint was selected or the selection was reset.
    • getSelectedJoint

      protected Joint getSelectedJoint()
      Returns the currently selected joint.
      Returns:
      The Joint that is currently selected, or null if no joint is selected.
    • updateSkeletonGeoms

      protected final void updateSkeletonGeoms(Joint joint)
      Updates the geometries associated with a given joint and its children to reflect their current model transforms. This method is called recursively.
      Parameters:
      joint - The joint to update.
    • setHeadColor

      public void setHeadColor(Joint joint, ColorRGBA color)
      Sets the color of the head geometry for a specific joint.
      Parameters:
      joint - The joint whose head color is to be set.
      color - The new color for the joint head.
    • setHeadColor

      public void setHeadColor(ColorRGBA color)
      Sets the color of all joint head geometries.
      Parameters:
      color - The new color for all joint heads.
    • setLineColor

      public void setLineColor(ColorRGBA color)
      Sets the color of all bone line geometries.
      Parameters:
      color - The new color for all bone lines.
    • pick

      public int pick(Vector2f cursor, CollisionResults results)
      Performs a 2D pick operation to find joints or bones near the given cursor position. This method primarily checks for joint heads within a PIXEL_BOX box around the cursor, and then checks for bone wires.
      Parameters:
      cursor - The 2D screen coordinates of the pick ray origin.
      results - The CollisionResults to store the pick results.
      Returns:
      The number of collisions found.
    • collideWith

      public int collideWith(Collidable other, CollisionResults results)
      Collides this ArmatureNode with a Collidable object, typically a Ray. It prioritizes 2D picking for joint heads and then performs a distance-based check for bone wires.
      Specified by:
      collideWith in interface Collidable
      Overrides:
      collideWith in class Node
      Parameters:
      other - The Collidable object to collide with.
      results - The CollisionResults to store the collision information.
      Returns:
      The number of collisions found.
    • updateGeometry

      public void updateGeometry()
      The method updates the geometry according to the positions of the bones.