public class KinematicRagdollControl extends AbstractPhysicsControl implements PhysicsCollisionListener, com.jme3.util.clone.JmeCloneable
This control creates collision shapes for each bones of the skeleton when you call spatial.addControl(ragdollControl).
There are 2 modes for this control :
| Modifier and Type | Class and Description |
|---|---|
static class |
KinematicRagdollControl.Mode |
class |
KinematicRagdollControl.PhysicsBoneLink |
| Modifier and Type | Field and Description |
|---|---|
protected PhysicsRigidBody |
baseRigidBody |
protected boolean |
blendedControl |
protected float |
blendStart |
protected float |
blendTime |
protected java.util.Map<java.lang.String,KinematicRagdollControl.PhysicsBoneLink> |
boneLinks |
protected java.util.Set<java.lang.String> |
boneList |
protected boolean |
debug |
protected float |
eventDispatchImpulseThreshold |
protected com.jme3.math.Vector3f |
initScale |
protected java.util.List<RagdollCollisionListener> |
listeners |
protected static java.util.logging.Logger |
logger |
protected KinematicRagdollControl.Mode |
mode |
protected com.jme3.math.Vector3f |
modelPosition |
protected com.jme3.math.Quaternion |
modelRotation |
protected RagdollPreset |
preset |
protected float |
rootMass |
protected com.jme3.animation.Skeleton |
skeleton |
protected com.jme3.scene.Spatial |
targetModel |
protected float |
totalMass |
protected float |
weightThreshold |
added, applyLocal, enabled, space, spatial| Constructor and Description |
|---|
KinematicRagdollControl()
contruct a KinematicRagdollControl
|
KinematicRagdollControl(float weightThreshold) |
KinematicRagdollControl(RagdollPreset preset) |
KinematicRagdollControl(RagdollPreset preset,
float weightThreshold) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBoneName(java.lang.String name)
Add a bone name to this control Using this method you can specify which
bones of the skeleton will be used to build the collision shapes.
|
void |
addCollisionListener(RagdollCollisionListener listener)
add a
|
protected void |
addPhysics(PhysicsSpace space)
Called when the physics object is supposed to add all objects it needs to
manage to the physics space.
|
void |
applyUserControl() |
void |
blendToKinematicMode(float blendTime)
Smoothly blend from Ragdoll mode to Kinematic mode This is useful to
blend ragdoll actual position to a keyframe animation for example
|
protected void |
boneRecursion(com.jme3.scene.Spatial model,
com.jme3.animation.Bone bone,
PhysicsRigidBody parent,
int reccount,
java.util.Map<java.lang.Integer,java.util.List<java.lang.Float>> pointsMap) |
com.jme3.scene.control.Control |
cloneForSpatial(com.jme3.scene.Spatial spatial) |
void |
collision(PhysicsCollisionEvent event)
For internal use only callback for collisionevent
|
protected void |
createSpatialData(com.jme3.scene.Spatial model)
Called when the control is added to a new spatial, create any
spatial-dependent data here.
|
com.jme3.animation.Bone |
getBone(java.lang.String name) |
PhysicsRigidBody |
getBoneRigidBody(java.lang.String boneName)
return the rigidBody associated to the given bone
|
float |
getEventDispatchImpulseThreshold() |
float |
getIkRotSpeed() |
float |
getIKThreshold() |
SixDofJoint |
getJoint(java.lang.String boneName)
Return the joint between the given bone and its parent.
|
float |
getLimbDampening() |
KinematicRagdollControl.Mode |
getMode()
retruns the mode of this control
|
float |
getTotalMass() |
float |
getWeightThreshold() |
java.lang.Object |
jmeClone() |
protected void |
kinematicUpdate(float tpf) |
protected void |
matchPhysicObjectToBone(KinematicRagdollControl.PhysicsBoneLink link,
com.jme3.math.Vector3f position,
com.jme3.math.Quaternion tmpRot1)
Set the transforms of a rigidBody to match the transforms of a bone.
|
protected void |
ragDollUpdate(float tpf) |
void |
read(com.jme3.export.JmeImporter im)
de-serialize this control
|
void |
reBuild()
rebuild the ragdoll this is useful if you applied scale on the ragdoll
after it's been initialized, same as reattaching.
|
void |
removeAllIKTargets() |
void |
removeIKTarget(com.jme3.animation.Bone bone) |
protected void |
removePhysics(PhysicsSpace space)
Called when the physics object is supposed to remove all objects added to
the physics space.
|
protected void |
removeSpatialData(com.jme3.scene.Spatial spat)
Called when the control is removed from a spatial, remove any
spatial-dependent data here.
|
void |
render(com.jme3.renderer.RenderManager rm,
com.jme3.renderer.ViewPort vp)
For internal use only specific render for the ragdoll(if debugging)
|
protected void |
scanSpatial(com.jme3.scene.Spatial model) |
void |
setCcdMotionThreshold(float value)
Set the CcdMotionThreshold of all the bone's rigidBodies of the ragdoll
|
void |
setCcdSweptSphereRadius(float value)
Set the CcdSweptSphereRadius of all the bone's rigidBodies of the ragdoll
|
void |
setEventDispatchImpulseThreshold(float eventDispatchImpulseThreshold) |
void |
setIKMode()
Sets the control into Inverse Kinematics mode.
|
void |
setIkRotSpeed(float ikRotSpeed) |
com.jme3.math.Vector3f |
setIKTarget(com.jme3.animation.Bone bone,
com.jme3.math.Vector3f worldPos,
int chainLength) |
void |
setIKThreshold(float IKThreshold) |
void |
setJointLimit(java.lang.String boneName,
float maxX,
float minX,
float maxY,
float minY,
float maxZ,
float minZ)
Set the joint limits for the joint between the given bone and its parent.
|
void |
setKinematicMode()
Set the control into Kinematic mode In theis mode, the collision shapes
follow the movements of the skeleton, and can interact with physical
environement
|
void |
setLimbDampening(float limbDampening) |
protected void |
setMode(KinematicRagdollControl.Mode mode)
Enable or disable the ragdoll behaviour.
|
protected void |
setPhysicsLocation(com.jme3.math.Vector3f vec)
Called when the physics object is supposed to move to the spatial
position.
|
protected void |
setPhysicsRotation(com.jme3.math.Quaternion quat)
Called when the physics object is supposed to move to the spatial
rotation.
|
void |
setRagdollMode()
Sets the control into Ragdoll mode The skeleton is entirely controlled by
physics.
|
void |
setRootMass(float rootMass) |
void |
setWeightThreshold(float weightThreshold) |
void |
update(float tpf) |
void |
updateBone(KinematicRagdollControl.PhysicsBoneLink link,
float tpf,
com.jme3.util.TempVars vars,
com.jme3.math.Quaternion tmpRot1,
com.jme3.math.Quaternion[] tmpRot2,
com.jme3.animation.Bone tipBone,
com.jme3.math.Vector3f target,
int depth,
int maxDepth) |
void |
write(com.jme3.export.JmeExporter ex)
serialize this control
|
applyPhysicsTransform, cloneFields, getPhysicsSpace, getSpatialRotation, getSpatialTranslation, isApplyPhysicsLocal, isEnabled, setApplyPhysicsLocal, setEnabled, setPhysicsSpace, setSpatialprotected static final java.util.logging.Logger logger
protected java.util.List<RagdollCollisionListener> listeners
protected final java.util.Set<java.lang.String> boneList
protected final java.util.Map<java.lang.String,KinematicRagdollControl.PhysicsBoneLink> boneLinks
protected final com.jme3.math.Vector3f modelPosition
protected final com.jme3.math.Quaternion modelRotation
protected final PhysicsRigidBody baseRigidBody
protected com.jme3.scene.Spatial targetModel
protected com.jme3.animation.Skeleton skeleton
protected RagdollPreset preset
protected com.jme3.math.Vector3f initScale
protected KinematicRagdollControl.Mode mode
protected boolean debug
protected boolean blendedControl
protected float weightThreshold
protected float blendStart
protected float blendTime
protected float eventDispatchImpulseThreshold
protected float rootMass
protected float totalMass
public KinematicRagdollControl()
public KinematicRagdollControl(float weightThreshold)
public KinematicRagdollControl(RagdollPreset preset, float weightThreshold)
public KinematicRagdollControl(RagdollPreset preset)
public void update(float tpf)
update in interface com.jme3.scene.control.Controlupdate in class AbstractPhysicsControlprotected void ragDollUpdate(float tpf)
protected void kinematicUpdate(float tpf)
public void updateBone(KinematicRagdollControl.PhysicsBoneLink link, float tpf, com.jme3.util.TempVars vars, com.jme3.math.Quaternion tmpRot1, com.jme3.math.Quaternion[] tmpRot2, com.jme3.animation.Bone tipBone, com.jme3.math.Vector3f target, int depth, int maxDepth)
protected void matchPhysicObjectToBone(KinematicRagdollControl.PhysicsBoneLink link, com.jme3.math.Vector3f position, com.jme3.math.Quaternion tmpRot1)
link - the link containing the bone and the rigidBodyposition - just a temp vector for positiontmpRot1 - just a temp quaternion for rotationpublic void reBuild()
protected void createSpatialData(com.jme3.scene.Spatial model)
AbstractPhysicsControlcreateSpatialData in class AbstractPhysicsControlmodel - The new spatial, guaranteed not to be nullprotected void removeSpatialData(com.jme3.scene.Spatial spat)
AbstractPhysicsControlremoveSpatialData in class AbstractPhysicsControlspat - The old spatial, guaranteed not to be nullpublic void addBoneName(java.lang.String name)
name - protected void scanSpatial(com.jme3.scene.Spatial model)
protected void boneRecursion(com.jme3.scene.Spatial model,
com.jme3.animation.Bone bone,
PhysicsRigidBody parent,
int reccount,
java.util.Map<java.lang.Integer,java.util.List<java.lang.Float>> pointsMap)
public void setJointLimit(java.lang.String boneName,
float maxX,
float minX,
float maxY,
float minY,
float maxZ,
float minZ)
boneName - the name of the bonemaxX - 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 z axis (in radians)maxZ - the maximum rotation on the z axis (in radians)minZ - the minimum rotation on the z axis (in radians)public SixDofJoint getJoint(java.lang.String boneName)
boneName - the name of the boneprotected void setPhysicsLocation(com.jme3.math.Vector3f vec)
AbstractPhysicsControlsetPhysicsLocation in class AbstractPhysicsControlprotected void setPhysicsRotation(com.jme3.math.Quaternion quat)
AbstractPhysicsControlsetPhysicsRotation in class AbstractPhysicsControlprotected void addPhysics(PhysicsSpace space)
AbstractPhysicsControladdPhysics in class AbstractPhysicsControlprotected void removePhysics(PhysicsSpace space)
AbstractPhysicsControlremovePhysics in class AbstractPhysicsControlpublic void collision(PhysicsCollisionEvent event)
collision in interface PhysicsCollisionListenerevent - protected void setMode(KinematicRagdollControl.Mode mode)
ragdollEnabled - public void blendToKinematicMode(float blendTime)
blendTime - the blending time between ragdoll to anim.public void setKinematicMode()
public void setRagdollMode()
public void setIKMode()
public KinematicRagdollControl.Mode getMode()
public void addCollisionListener(RagdollCollisionListener listener)
listener - public void setRootMass(float rootMass)
public float getTotalMass()
public float getWeightThreshold()
public void setWeightThreshold(float weightThreshold)
public float getEventDispatchImpulseThreshold()
public void setEventDispatchImpulseThreshold(float eventDispatchImpulseThreshold)
public void setCcdMotionThreshold(float value)
value - PhysicsRigidBody.setCcdMotionThreshold(float)public void setCcdSweptSphereRadius(float value)
value - PhysicsRigidBody.setCcdSweptSphereRadius(float)public PhysicsRigidBody getBoneRigidBody(java.lang.String boneName)
boneName - the name of the bonepublic void render(com.jme3.renderer.RenderManager rm,
com.jme3.renderer.ViewPort vp)
render in interface com.jme3.scene.control.Controlrender in class AbstractPhysicsControlrm - vp - public com.jme3.scene.control.Control cloneForSpatial(com.jme3.scene.Spatial spatial)
cloneForSpatial in interface com.jme3.scene.control.Controlpublic java.lang.Object jmeClone()
jmeClone in interface com.jme3.util.clone.JmeCloneablepublic com.jme3.math.Vector3f setIKTarget(com.jme3.animation.Bone bone,
com.jme3.math.Vector3f worldPos,
int chainLength)
public void removeIKTarget(com.jme3.animation.Bone bone)
public void removeAllIKTargets()
public void applyUserControl()
public float getIkRotSpeed()
public void setIkRotSpeed(float ikRotSpeed)
public float getIKThreshold()
public void setIKThreshold(float IKThreshold)
public float getLimbDampening()
public void setLimbDampening(float limbDampening)
public com.jme3.animation.Bone getBone(java.lang.String name)
public void write(com.jme3.export.JmeExporter ex)
throws java.io.IOException
write in interface com.jme3.export.Savablewrite in class AbstractPhysicsControlex - java.io.IOExceptionpublic void read(com.jme3.export.JmeImporter im)
throws java.io.IOException
read in interface com.jme3.export.Savableread in class AbstractPhysicsControlim - java.io.IOException