Class RagUtils

java.lang.Object
com.jme3.bullet.animation.RagUtils

public final class RagUtils extends Object
Utility methods used by DynamicAnimControl and associated classes.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Map<String,jme3utilities.math.VectorSet>
    coordsMap(com.jme3.scene.Mesh[] meshes, String[] managerMap)
    Assign each mesh vertex to a bone/torso link and add its location (mesh coordinates in bind pose) to that link's list.
    static com.jme3.animation.Bone
    findMainBone(com.jme3.animation.Skeleton skeleton, com.jme3.scene.Mesh[] targetMeshes)
    Find the main root bone of a Skeleton, based on its total mesh weight.
    static com.jme3.anim.Joint
    findMainJoint(com.jme3.anim.Armature armature, com.jme3.scene.Mesh[] targetMeshes)
    Find the main root joint of an Armature, based on its total mesh weight.
    static String
    findManager(com.jme3.scene.Mesh mesh, int vertexIndex, int[] iArray, float[] wArray, String[] managerMap)
    Determine which physics link should manage the specified mesh vertex.
    static com.jme3.scene.control.AbstractControl
    findSControl(com.jme3.scene.Spatial subtree)
    Access the SkeletonControl or SkinningControl in the specified subtree, assuming it doesn't contain more than one.
    static List<com.jme3.scene.Mesh>
    listDacMeshes(com.jme3.scene.Spatial subtree, List<com.jme3.scene.Mesh> storeResult)
    Enumerate all animated meshes in the specified subtree of a scene graph, skipping spatials tagged with "JmePhysicsIgnore".
    Enumerate all physics joints that connect bodies in the specified array.
    makeCylinder(jme3utilities.math.VectorSet vectorSet, com.jme3.math.Vector3f scaleFactors)
    Create a transformed CylinderCollisionShape that bounds the locations in the specified VectorSet.
    static jme3utilities.math.RectangularSolid
    makeRectangularSolid(jme3utilities.math.VectorSet vectorSet, com.jme3.math.Vector3f scaleFactors)
    Instantiate a compact RectangularSolid that bounds the sample locations contained in a VectorSet.
    static void
    meshToLocal(com.jme3.animation.Bone parentBone, com.jme3.math.Transform transform)
    Convert a transform from the mesh coordinate system to the local coordinate system of the specified bone.
    static com.jme3.math.Transform[]
    readTransformArray(com.jme3.export.InputCapsule capsule, String fieldName)
    Read an array of transforms from an input capsule.
    static com.jme3.math.Transform
    relativeTransform(com.jme3.scene.Spatial startSpatial, com.jme3.scene.Node ancestorNode, com.jme3.math.Transform storeResult)
    Calculate a coordinate transform for the specified Spatial relative to a specified ancestor node.
    static void
    validate(com.jme3.anim.Armature armature)
    Validate an Armature for use with DynamicAnimControl.
    static void
    validate(com.jme3.animation.Skeleton skeleton)
    Validate a Skeleton for use with DynamicAnimControl.
    static void
    validate(com.jme3.scene.Spatial model)
    Validate a model for use with DynamicAnimControl.

    Methods inherited from class java.lang.Object

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

    • coordsMap

      public static Map<String,jme3utilities.math.VectorSet> coordsMap(com.jme3.scene.Mesh[] meshes, String[] managerMap)
      Assign each mesh vertex to a bone/torso link and add its location (mesh coordinates in bind pose) to that link's list.

      A software skin update must precede any request for vertex locations. TODO use the Wes library to avoid this limitation?

      Parameters:
      meshes - array of animated meshes to use (not null, unaffected)
      managerMap - a map from bone indices to managing link names (not null, unaffected)
      Returns:
      a new map from bone/torso names to sets of vertex coordinates
    • findMainBone

      public static com.jme3.animation.Bone findMainBone(com.jme3.animation.Skeleton skeleton, com.jme3.scene.Mesh[] targetMeshes)
      Find the main root bone of a Skeleton, based on its total mesh weight.
      Parameters:
      skeleton - the skeleton (not null, unaffected)
      targetMeshes - an array of animated meshes to provide bone weights (not null)
      Returns:
      a root bone, or null if none found
    • findMainJoint

      public static com.jme3.anim.Joint findMainJoint(com.jme3.anim.Armature armature, com.jme3.scene.Mesh[] targetMeshes)
      Find the main root joint of an Armature, based on its total mesh weight.
      Parameters:
      armature - the Armature (not null, unaffected)
      targetMeshes - an array of animated meshes to provide weights (not null)
      Returns:
      a root joint, or null if none found
    • findManager

      public static String findManager(com.jme3.scene.Mesh mesh, int vertexIndex, int[] iArray, float[] wArray, String[] managerMap)
      Determine which physics link should manage the specified mesh vertex.
      Parameters:
      mesh - the mesh containing the vertex (not null, unaffected)
      vertexIndex - the vertex index in the mesh (≥0)
      iArray - temporary storage for bone indices (not null, modified)
      wArray - temporary storage for bone weights (not null, modified)
      managerMap - a map from bone indices to bone/torso names (not null, unaffected)
      Returns:
      a bone/torso name
    • findSControl

      public static com.jme3.scene.control.AbstractControl findSControl(com.jme3.scene.Spatial subtree)
      Access the SkeletonControl or SkinningControl in the specified subtree, assuming it doesn't contain more than one.
      Parameters:
      subtree - a subtree of a scene graph (may be null, unaffected)
      Returns:
      the pre-existing instance, or null if none or multiple
    • listDacMeshes

      public static List<com.jme3.scene.Mesh> listDacMeshes(com.jme3.scene.Spatial subtree, List<com.jme3.scene.Mesh> storeResult)
      Enumerate all animated meshes in the specified subtree of a scene graph, skipping spatials tagged with "JmePhysicsIgnore". Note: recursive!
      Parameters:
      subtree - the subtree to analyze (may be null, aliases created)
      storeResult - storage for results (added to if not null)
      Returns:
      an expanded List (either storeResult or a new List)
    • listInternalJoints

      public static Set<PhysicsJoint> listInternalJoints(PhysicsBody... bodies)
      Enumerate all physics joints that connect bodies in the specified array.
      Parameters:
      bodies - the array to search (not null, unaffected)
      Returns:
      a new Set of pre-existing instances
    • makeCylinder

      public static CompoundCollisionShape makeCylinder(jme3utilities.math.VectorSet vectorSet, com.jme3.math.Vector3f scaleFactors)
      Create a transformed CylinderCollisionShape that bounds the locations in the specified VectorSet.
      Parameters:
      vectorSet - the set of locations (not null, numVectors>1, unaffected)
      scaleFactors - scale factors to apply to local coordinates (not null, unaffected)
      Returns:
      a new shape
    • makeRectangularSolid

      public static jme3utilities.math.RectangularSolid makeRectangularSolid(jme3utilities.math.VectorSet vectorSet, com.jme3.math.Vector3f scaleFactors)
      Instantiate a compact RectangularSolid that bounds the sample locations contained in a VectorSet.
      Parameters:
      vectorSet - the set of locations (not null, numVectors>1, contents unaffected)
      scaleFactors - scale factors to apply to local coordinates (not null, unaffected)
      Returns:
      a new RectangularSolid
    • meshToLocal

      public static void meshToLocal(com.jme3.animation.Bone parentBone, com.jme3.math.Transform transform)
      Convert a transform from the mesh coordinate system to the local coordinate system of the specified bone.
      Parameters:
      parentBone - (not null)
      transform - the transform to convert (not null, modified)
    • readTransformArray

      public static com.jme3.math.Transform[] readTransformArray(com.jme3.export.InputCapsule capsule, String fieldName) throws IOException
      Read an array of transforms from an input capsule.
      Parameters:
      capsule - the input capsule (not null)
      fieldName - the name of the field to read (not null)
      Returns:
      a new array or null
      Throws:
      IOException - from capsule
    • relativeTransform

      public static com.jme3.math.Transform relativeTransform(com.jme3.scene.Spatial startSpatial, com.jme3.scene.Node ancestorNode, com.jme3.math.Transform storeResult)
      Calculate a coordinate transform for the specified Spatial relative to a specified ancestor node. The result incorporates the transform of the starting Spatial, but not that of the ancestor.
      Parameters:
      startSpatial - the starting Spatial (not null, unaffected)
      ancestorNode - the ancestor node (not null, unaffected)
      storeResult - storage for the result (modified if not null)
      Returns:
      a coordinate transform (either storeResult or a new vector, not null)
    • validate

      public static void validate(com.jme3.anim.Armature armature)
      Validate an Armature for use with DynamicAnimControl.
      Parameters:
      armature - the Armature to validate (not null, unaffected)
    • validate

      public static void validate(com.jme3.animation.Skeleton skeleton)
      Validate a Skeleton for use with DynamicAnimControl.
      Parameters:
      skeleton - the Skeleton to validate (not null, unaffected)
    • validate

      public static void validate(com.jme3.scene.Spatial model)
      Validate a model for use with DynamicAnimControl.
      Parameters:
      model - the model to validate (not null, unaffected)
      Throws:
      IllegalArgumentException - for an invalid model