Class RagdollUtils

java.lang.Object
com.jme3.bullet.control.ragdoll.RagdollUtils

public class RagdollUtils extends Object
Utility methods used by KinematicRagdollControl.

This class is shared between JBullet and Native Bullet.

  • Method Details

    • setJointLimit

      public static void setJointLimit(SixDofJoint joint, float maxX, float minX, float maxY, float minY, float maxZ, float minZ)
      Alter the limits of the specified 6-DOF joint.
      Parameters:
      joint - which joint to alter (not null)
      maxX - the maximum rotation on the X axis (in radians)
      minX - the minimum rotation on the X axis (in radians)
      maxY - the maximum rotation on the Y axis (in radians)
      minY - the minimum rotation on the Y axis (in radians)
      maxZ - the maximum rotation on the Z axis (in radians)
      minZ - the minimum rotation on the Z axis (in radians)
    • buildPointMap

      public static Map<Integer,List<Float>> buildPointMap(Spatial model)
      Build a map of mesh vertices in a subtree of the scene graph.
      Parameters:
      model - the root of the subtree (may be null)
      Returns:
      a new map (not null)
    • makeShapeFromPointMap

      public static HullCollisionShape makeShapeFromPointMap(Map<Integer,List<Float>> pointsMap, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition)
      Create a hull collision shape from linked vertices to this bone. Vertices must have previously been gathered using buildPointMap().
      Parameters:
      pointsMap - map from bone indices to coordinates (not null, unaffected)
      boneIndices - (not null, unaffected)
      initialScale - scale factors (not null, unaffected)
      initialPosition - location (not null, unaffected)
      Returns:
      a new shape (not null)
    • getBoneIndices

      public static List<Integer> getBoneIndices(Bone bone, Skeleton skeleton, Set<String> boneList)
      Enumerate the bone indices of the specified bone and all its descendents.
      Parameters:
      bone - the input bone (not null)
      skeleton - the skeleton containing the bone (not null)
      boneList - a set of bone names (not null, unaffected)
      Returns:
      a new list (not null)
    • makeShapeFromVerticeWeights

      public static HullCollisionShape makeShapeFromVerticeWeights(Spatial model, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition, float weightThreshold)
      Create a hull collision shape from linked vertices to this bone.
      Parameters:
      model - the model on which to base the shape
      boneIndices - indices of relevant bones (not null, unaffected)
      initialScale - scale factors
      initialPosition - location
      weightThreshold - minimum weight for inclusion
      Returns:
      a new shape
    • setTransform

      public static void setTransform(Bone bone, Vector3f pos, Quaternion rot, boolean restoreBoneControl, Set<String> boneList)
      Updates a bone position and rotation. if the child bones are not in the bone list this means, they are not associated with a physics shape. So they have to be updated
      Parameters:
      bone - the bone
      pos - the position
      rot - the rotation
      restoreBoneControl - true → user-control flag should be set
      boneList - the names of all bones without collision shapes (not null, unaffected)
    • setUserControl

      public static void setUserControl(Bone bone, boolean bool)
      Alter the user-control flags of a bone and all its descendents.
      Parameters:
      bone - the ancestor bone (not null, modified)
      bool - true to enable user control, false to disable
    • hasVertices

      public static boolean hasVertices(int boneIndex, Mesh[] targets, float weightThreshold)
      Test whether the indexed bone has at least one vertex in the specified meshes with a weight greater than the specified threshold.
      Parameters:
      boneIndex - the index of the bone (≥0)
      targets - the meshes to search (not null, no null elements)
      weightThreshold - the threshold (≥0, ≤1)
      Returns:
      true if at least 1 vertex found, otherwise false
    • readIndex

      public static int readIndex(Buffer buffer, int k)
      Read an index from a buffer.
      Parameters:
      buffer - a buffer of bytes or shorts (not null)
      k - the position from which the index will be read
      Returns:
      the index value (≥0)