Class KinematicRagdollControl

java.lang.Object
com.jme3.bullet.control.AbstractPhysicsControl
com.jme3.bullet.control.KinematicRagdollControl
All Implemented Interfaces:
PhysicsCollisionListener, PhysicsControl, Savable, Control, JmeCloneable, Cloneable

@Deprecated public class KinematicRagdollControl extends AbstractPhysicsControl implements PhysicsCollisionListener, JmeCloneable
Deprecated.
This control is still a WIP, use it at your own risk
To use this control you need a model with an AnimControl and a SkeletonControl.
This should be the case if you imported an animated model from Ogre or blender.
Note enabling/disabling the control add/removes it from the physics space

This control creates collision shapes for all bones in the skeleton when you invoke spatial.addControl(ragdollControl).

  • The shape is HullCollision shape based on the vertices associated with each bone and based on a tweakable weight threshold (see setWeightThreshold)
  • If you don't want each bone to be a collision shape, you can specify what bone to use by using the addBoneName method
    By using this method, bone that are not used to create a shape, are "merged" to their parent to create the collision shape.

There are 2 modes for this control :

  • The kinematic modes :
    this is the default behavior, this means that the collision shapes of the body are able to interact with physics enabled objects. in this mode physics shapes follow the motion of the animated skeleton (for example animated by a key framed animation) this mode is enabled by calling setKinematicMode();
  • The ragdoll modes:
    To enable this behavior, you need to invoke the setRagdollMode() method. In this mode the character is entirely controlled by physics, so it will fall under the gravity and move if any force is applied to it.

This class is shared between JBullet and Native Bullet.

  • Field Details

    • logger

      protected static final Logger logger
      Deprecated.
      list of registered collision listeners
    • listeners

      protected List<RagdollCollisionListener> listeners
      Deprecated.
    • boneList

      protected final Set<String> boneList
      Deprecated.
    • modelPosition

      protected final Vector3f modelPosition
      Deprecated.
    • modelRotation

      protected final Quaternion modelRotation
      Deprecated.
    • baseRigidBody

      protected final PhysicsRigidBody baseRigidBody
      Deprecated.
    • targetModel

      protected Spatial targetModel
      Deprecated.
      model being controlled
    • skeleton

      protected Skeleton skeleton
      Deprecated.
      skeleton being controlled
    • preset

      protected RagdollPreset preset
      Deprecated.
    • initScale

      protected Vector3f initScale
      Deprecated.
    • mode

      Deprecated.
    • debug

      protected boolean debug
      Deprecated.
    • blendedControl

      protected boolean blendedControl
      Deprecated.
    • weightThreshold

      protected float weightThreshold
      Deprecated.
    • blendStart

      protected float blendStart
      Deprecated.
    • blendTime

      protected float blendTime
      Deprecated.
      blending interval for animations (in seconds, ≥0)
    • eventDispatchImpulseThreshold

      protected float eventDispatchImpulseThreshold
      Deprecated.
    • rootMass

      protected float rootMass
      Deprecated.
    • totalMass

      protected float totalMass
      Deprecated.
      accumulate total mass of ragdoll when control is added to a scene
  • Constructor Details

    • KinematicRagdollControl

      public KinematicRagdollControl()
      Deprecated.
      Instantiate an enabled control.
    • KinematicRagdollControl

      public KinematicRagdollControl(float weightThreshold)
      Deprecated.
      Instantiate an enabled control with the specified weight threshold.
      Parameters:
      weightThreshold - (>0, <1)
    • KinematicRagdollControl

      public KinematicRagdollControl(RagdollPreset preset, float weightThreshold)
      Deprecated.
      Instantiate an enabled control with the specified preset and weight threshold.
      Parameters:
      preset - (not null)
      weightThreshold - (>0, <1)
    • KinematicRagdollControl

      public KinematicRagdollControl(RagdollPreset preset)
      Deprecated.
      Instantiate an enabled control with the specified preset.
      Parameters:
      preset - (not null)
  • Method Details

    • update

      public void update(float tpf)
      Deprecated.
      Update this control. Invoked once per frame during the logical-state update, provided the control is added to a scene. Do not invoke directly from user code.
      Specified by:
      update in interface Control
      Overrides:
      update in class AbstractPhysicsControl
      Parameters:
      tpf - the time interval between frames (in seconds, ≥0)
    • ragDollUpdate

      protected void ragDollUpdate(float tpf)
      Deprecated.
      Update this control in Ragdoll mode, based on Bullet physics.
      Parameters:
      tpf - the time interval between frames (in seconds, ≥0)
    • kinematicUpdate

      protected void kinematicUpdate(float tpf)
      Deprecated.
      Update this control in Kinematic mode, based on bone animation tracks.
      Parameters:
      tpf - the time interval between frames (in seconds, ≥0)
    • updateBone

      public void updateBone(KinematicRagdollControl.PhysicsBoneLink link, float tpf, TempVars vars, Quaternion tmpRot1, Quaternion[] tmpRot2, Bone tipBone, Vector3f target, int depth, int maxDepth)
      Deprecated.
      Update a bone and its ancestors in IK mode. Note: recursive!
      Parameters:
      link - the bone link for the affected bone (may be null)
      tpf - the time interval between frames (in seconds, ≥0)
      vars - unused
      tmpRot1 - temporary storage used in calculations (not null)
      tmpRot2 - temporary storage used in calculations (not null)
      tipBone - (not null)
      target - the location target in model space (not null, unaffected)
      depth - depth of the recursion (≥0)
      maxDepth - recursion limit (≥0)
    • matchPhysicObjectToBone

      protected void matchPhysicObjectToBone(KinematicRagdollControl.PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1)
      Deprecated.
      Alter the transforms of a rigidBody to match the transforms of a bone. This is used to make the ragdoll follow animated motion in Kinematic mode
      Parameters:
      link - the bone link connecting the bone and the rigidBody
      position - temporary storage used in calculations (not null)
      tmpRot1 - temporary storage used in calculations (not null)
    • reBuild

      public void reBuild()
      Deprecated.
      Rebuild the ragdoll. This is useful if you applied scale on the ragdoll after it was initialized. Same as re-attaching.
    • createSpatialData

      protected void createSpatialData(Spatial model)
      Deprecated.
      Create spatial-dependent data. Invoked when this control is added to a scene.
      Specified by:
      createSpatialData in class AbstractPhysicsControl
      Parameters:
      model - the controlled spatial (not null)
    • removeSpatialData

      protected void removeSpatialData(Spatial spat)
      Deprecated.
      Destroy spatial-dependent data. Invoked when this control is removed from a spatial.
      Specified by:
      removeSpatialData in class AbstractPhysicsControl
      Parameters:
      spat - the previously controlled spatial (not null)
    • addBoneName

      public void addBoneName(String name)
      Deprecated.
      Add a bone name to this control. Repeated invocations of this method can be used to specify which bones to use when generating collision shapes.

      Not allowed after attaching the control.

      Parameters:
      name - the name of the bone to add
    • scanSpatial

      protected void scanSpatial(Spatial model)
      Deprecated.
      Generate physics shapes and bone links for the skeleton.
      Parameters:
      model - the spatial with the model's SkeletonControl (not null)
    • boneRecursion

      protected void boneRecursion(Spatial model, Bone bone, PhysicsRigidBody parent, int recursionCount, Map<Integer,List<Float>> pointsMap)
      Deprecated.
      Generate a physics shape and bone links for the specified bone. Note: recursive!
      Parameters:
      model - the spatial with the model's SkeletonControl (not null)
      bone - the bone to be linked (not null)
      parent - the body linked to the parent bone (not null)
      recursionCount - depth of the recursion (≥1)
      pointsMap - (not null)
    • setJointLimit

      public void setJointLimit(String boneName, float maxX, float minX, float maxY, float minY, float maxZ, float minZ)
      Deprecated.
      Alter the limits of the joint connecting the specified bone to its parent. Can only be invoked after adding the control to a spatial.
      Parameters:
      boneName - the name of the bone
      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)
    • getJoint

      public SixDofJoint getJoint(String boneName)
      Deprecated.
      Return the joint between the specified bone and its parent. This return null if it's invoked before adding the control to a spatial
      Parameters:
      boneName - the name of the bone
      Returns:
      the joint between the given bone and its parent
    • setPhysicsLocation

      protected void setPhysicsLocation(Vector3f vec)
      Deprecated.
      Description copied from class: AbstractPhysicsControl
      Translate the physics object to the specified location.
      Specified by:
      setPhysicsLocation in class AbstractPhysicsControl
      Parameters:
      vec - desired location (not null, unaffected)
    • setPhysicsRotation

      protected void setPhysicsRotation(Quaternion quat)
      Deprecated.
      Description copied from class: AbstractPhysicsControl
      Rotate the physics object to the specified orientation.
      Specified by:
      setPhysicsRotation in class AbstractPhysicsControl
      Parameters:
      quat - desired orientation (not null, unaffected)
    • addPhysics

      protected void addPhysics(PhysicsSpace space)
      Deprecated.
      Description copied from class: AbstractPhysicsControl
      Add all managed physics objects to the specified space.
      Specified by:
      addPhysics in class AbstractPhysicsControl
      Parameters:
      space - which physics space to add to (not null)
    • removePhysics

      protected void removePhysics(PhysicsSpace space)
      Deprecated.
      Description copied from class: AbstractPhysicsControl
      Remove all managed physics objects from the specified space.
      Specified by:
      removePhysics in class AbstractPhysicsControl
      Parameters:
      space - which physics space to remove from (not null)
    • collision

      public void collision(PhysicsCollisionEvent event)
      Deprecated.
      For internal use only: callback for collision event
      Specified by:
      collision in interface PhysicsCollisionListener
      Parameters:
      event - (not null)
    • setMode

      protected void setMode(KinematicRagdollControl.Mode mode)
      Deprecated.
      Enable or disable the ragdoll behaviour. if ragdollEnabled is true, the character motion will only be powered by physics else, the character will be animated by the keyframe animation, but will be able to physically interact with its physics environment
      Parameters:
      mode - an enum value (not null)
    • blendToKinematicMode

      public void blendToKinematicMode(float blendTime)
      Deprecated.
      Smoothly blend from Ragdoll mode to Kinematic mode This is useful to blend ragdoll actual position to a keyframe animation for example
      Parameters:
      blendTime - the blending time between ragdoll to anim.
    • setKinematicMode

      public void setKinematicMode()
      Deprecated.
      Put the control into Kinematic mode. In this mode, the collision shapes follow the movements of the skeleton while interacting with the physics environment.
    • setRagdollMode

      public void setRagdollMode()
      Deprecated.
      Sets the control into Ragdoll mode The skeleton is entirely controlled by physics.
    • setIKMode

      public void setIKMode()
      Deprecated.
      Sets the control into Inverse Kinematics mode. The affected bones are affected by IK. physics.
    • getMode

      public KinematicRagdollControl.Mode getMode()
      Deprecated.
      returns the mode of this control
      Returns:
      an enum value
    • addCollisionListener

      public void addCollisionListener(RagdollCollisionListener listener)
      Deprecated.
      Add a collision listener to this control.
      Parameters:
      listener - (not null, alias created)
    • setRootMass

      public void setRootMass(float rootMass)
      Deprecated.
      Alter the ragdoll's root mass.
      Parameters:
      rootMass - the desired mass (≥0)
    • getTotalMass

      public float getTotalMass()
      Deprecated.
      Read the ragdoll's total mass.
      Returns:
      mass (≥0)
    • getWeightThreshold

      public float getWeightThreshold()
      Deprecated.
      Read the ragdoll's weight threshold.
      Returns:
      threshold
    • setWeightThreshold

      public void setWeightThreshold(float weightThreshold)
      Deprecated.
      Alter the ragdoll's weight threshold.
      Parameters:
      weightThreshold - the desired threshold
    • getEventDispatchImpulseThreshold

      public float getEventDispatchImpulseThreshold()
      Deprecated.
      Read the ragdoll's event-dispatch impulse threshold.
      Returns:
      threshold
    • setEventDispatchImpulseThreshold

      public void setEventDispatchImpulseThreshold(float eventDispatchImpulseThreshold)
      Deprecated.
      Alter the ragdoll's event-dispatch impulse threshold.
      Parameters:
      eventDispatchImpulseThreshold - desired threshold
    • setCcdMotionThreshold

      public void setCcdMotionThreshold(float value)
      Deprecated.
      Alter the CcdMotionThreshold of all rigid bodies in the ragdoll.
      Parameters:
      value - the desired threshold value (velocity, >0) or zero to disable CCD (default=0)
      See Also:
    • setCcdSweptSphereRadius

      public void setCcdSweptSphereRadius(float value)
      Deprecated.
      Alter the CcdSweptSphereRadius of all rigid bodies in the ragdoll.
      Parameters:
      value - the desired radius of the sphere used for continuous collision detection (≥0)
      See Also:
    • getBoneRigidBody

      public PhysicsRigidBody getBoneRigidBody(String boneName)
      Deprecated.
      Access the rigidBody associated with the named bone.
      Parameters:
      boneName - the name of the bone
      Returns:
      the associated rigidBody.
    • render

      public void render(RenderManager rm, ViewPort vp)
      Deprecated.
      Render this control. Invoked once per view port per frame, provided the control is added to a scene. Should be invoked only by a subclass or by the RenderManager.
      Specified by:
      render in interface Control
      Overrides:
      render in class AbstractPhysicsControl
      Parameters:
      rm - the render manager (not null)
      vp - the view port to render (not null)
    • jmeClone

      public Object jmeClone()
      Deprecated.
      Create a shallow clone for the JME cloner.
      Specified by:
      jmeClone in interface JmeCloneable
      Returns:
      a new control (not null)
    • setIKTarget

      public Vector3f setIKTarget(Bone bone, Vector3f worldPos, int chainLength)
      Deprecated.
      Add a target for inverse kinematics.
      Parameters:
      bone - which bone the IK applies to (not null)
      worldPos - the world coordinates of the goal (not null)
      chainLength - number of bones in the chain
      Returns:
      a new instance (not null, already added to ikTargets)
    • removeIKTarget

      public void removeIKTarget(Bone bone)
      Deprecated.
      Remove the inverse-kinematics target for the specified bone.
      Parameters:
      bone - which bone has the target (not null, modified)
    • removeAllIKTargets

      public void removeAllIKTargets()
      Deprecated.
      Remove all inverse-kinematics targets.
    • applyUserControl

      public void applyUserControl()
      Deprecated.
      Ensure that user control is enabled for any bones used by inverse kinematics and disabled for any other bones.
    • getIkRotSpeed

      public float getIkRotSpeed()
      Deprecated.
      Read the rotation speed for inverse kinematics.
      Returns:
      speed (≥0)
    • setIkRotSpeed

      public void setIkRotSpeed(float ikRotSpeed)
      Deprecated.
      Alter the rotation speed for inverse kinematics.
      Parameters:
      ikRotSpeed - the desired speed (≥0, default=7)
    • getIKThreshold

      public float getIKThreshold()
      Deprecated.
      Read the distance threshold for inverse kinematics.
      Returns:
      distance threshold
    • setIKThreshold

      public void setIKThreshold(float IKThreshold)
      Deprecated.
      Alter the distance threshold for inverse kinematics.
      Parameters:
      IKThreshold - the desired distance threshold (default=0.1)
    • getLimbDampening

      public float getLimbDampening()
      Deprecated.
      Read the limb damping.
      Returns:
      the viscous damping ratio (0→no damping, 1→critically damped)
    • setLimbDampening

      public void setLimbDampening(float limbDampening)
      Deprecated.
      Alter the limb damping.
      Parameters:
      limbDampening - the desired viscous damping ratio (0→no damping, 1→critically damped, default=0.6)
    • getBone

      public Bone getBone(String name)
      Deprecated.
      Access the named bone.
      Parameters:
      name - which bone to access
      Returns:
      the pre-existing instance, or null if not found
    • write

      public void write(JmeExporter ex) throws IOException
      Deprecated.
      Serialize this control, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Overrides:
      write in class AbstractPhysicsControl
      Parameters:
      ex - exporter (not null)
      Throws:
      IOException - from exporter
    • read

      public void read(JmeImporter im) throws IOException
      Deprecated.
      De-serialize this control, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Overrides:
      read in class AbstractPhysicsControl
      Parameters:
      im - importer (not null)
      Throws:
      IOException - from importer