Package com.jme3.bullet.control.ragdoll
Class RagdollUtils
java.lang.Object
com.jme3.bullet.control.ragdoll.RagdollUtils
Utility methods used by KinematicRagdollControl.
This class is shared between JBullet and Native Bullet.
-
Method Summary
Modifier and TypeMethodDescriptionbuildPointMap(Spatial model) Build a map of mesh vertices in a subtree of the scene graph.getBoneIndices(Bone bone, Skeleton skeleton, Set<String> boneList) Enumerate the bone indices of the specified bone and all its descendents.static booleanhasVertices(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.static HullCollisionShapemakeShapeFromPointMap(Map<Integer, List<Float>> pointsMap, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition) Create a hull collision shape from linked vertices to this bone.static HullCollisionShapemakeShapeFromVerticeWeights(Spatial model, List<Integer> boneIndices, Vector3f initialScale, Vector3f initialPosition, float weightThreshold) Create a hull collision shape from linked vertices to this bone.static intRead an index from a buffer.static voidsetJointLimit(SixDofJoint joint, float maxX, float minX, float maxY, float minY, float maxZ, float minZ) Alter the limits of the specified 6-DOF joint.static voidsetTransform(Bone bone, Vector3f pos, Quaternion rot, boolean restoreBoneControl, Set<String> boneList) Updates a bone position and rotation.static voidsetUserControl(Bone bone, boolean bool) Alter the user-control flags of a bone and all its descendents.
-
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
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
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 shapeboneIndices- indices of relevant bones (not null, unaffected)initialScale- scale factorsinitialPosition- locationweightThreshold- 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 bonepos- the positionrot- the rotationrestoreBoneControl- true → user-control flag should be setboneList- the names of all bones without collision shapes (not null, unaffected)
-
setUserControl
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
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
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)
-