Ragdoll :
- New test with sinbad - Added bone selection for building the collision shapes - Moved Radoll classes to proper package git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7236 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
14e4b79170
commit
3378222dfa
@ -235,7 +235,7 @@ public final class Bone implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Updates the world transforms for this bone, and, possibly the attach node if not null.
|
* Updates the world transforms for this bone, and, possibly the attach node if not null.
|
||||||
*/
|
*/
|
||||||
final void updateWorldVectors() {
|
public final void updateWorldVectors() {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
|
||||||
//rotation
|
//rotation
|
||||||
@ -382,6 +382,15 @@ public final class Bone implements Savable {
|
|||||||
worldRot.set(rotation);
|
worldRot.set(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Vector3f tmpVec=new Vector3f();
|
||||||
|
protected Quaternion tmpQuat=new Quaternion();
|
||||||
|
public Quaternion getTmpQuat() {
|
||||||
|
return tmpQuat;
|
||||||
|
}
|
||||||
|
public Vector3f getTmpVec() {
|
||||||
|
return tmpVec;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the attachment node.
|
* Returns the attachment node.
|
||||||
* Attach models and effects to this node to make
|
* Attach models and effects to this node to make
|
||||||
|
@ -487,7 +487,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void runControlUpdate(float tpf) {
|
private void runControlUpdate(float tpf) {
|
||||||
if (controls.size() == 0) {
|
if (controls.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +507,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable {
|
|||||||
* @see Spatial#getControl(java.lang.Class)
|
* @see Spatial#getControl(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
public void runControlRender(RenderManager rm, ViewPort vp) {
|
public void runControlRender(RenderManager rm, ViewPort vp) {
|
||||||
if (controls.size() == 0) {
|
if (controls.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +167,7 @@ public class TempVars {
|
|||||||
* General quaternions.
|
* General quaternions.
|
||||||
*/
|
*/
|
||||||
public final Quaternion quat1 = new Quaternion();
|
public final Quaternion quat1 = new Quaternion();
|
||||||
|
public final Quaternion quat2 = new Quaternion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Eigen
|
* Eigen
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.jme3.bullet.control;
|
package com.jme3.bullet.control;
|
||||||
|
|
||||||
|
import com.jme3.bullet.control.radoll.RagdollPreset;
|
||||||
|
import com.jme3.bullet.control.radoll.HumanoidRagdollPreset;
|
||||||
import com.jme3.animation.AnimControl;
|
import com.jme3.animation.AnimControl;
|
||||||
import com.jme3.animation.Bone;
|
import com.jme3.animation.Bone;
|
||||||
import com.jme3.animation.Skeleton;
|
import com.jme3.animation.Skeleton;
|
||||||
@ -12,12 +14,10 @@ import com.jme3.bullet.collision.PhysicsCollisionObject;
|
|||||||
import com.jme3.bullet.collision.RagdollCollisionListener;
|
import com.jme3.bullet.collision.RagdollCollisionListener;
|
||||||
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
|
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
|
||||||
import com.jme3.bullet.collision.shapes.HullCollisionShape;
|
import com.jme3.bullet.collision.shapes.HullCollisionShape;
|
||||||
import com.jme3.bullet.joints.PhysicsJoint;
|
|
||||||
import com.jme3.bullet.joints.SixDofJoint;
|
import com.jme3.bullet.joints.SixDofJoint;
|
||||||
import com.jme3.bullet.objects.PhysicsRigidBody;
|
import com.jme3.bullet.objects.PhysicsRigidBody;
|
||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.math.FastMath;
|
|
||||||
import com.jme3.math.Quaternion;
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
@ -35,6 +35,7 @@ import java.nio.FloatBuffer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -61,6 +62,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
protected float eventDispatchImpulseThreshold = 10;
|
protected float eventDispatchImpulseThreshold = 10;
|
||||||
protected float eventDiscardImpulseThreshold = 3;
|
protected float eventDiscardImpulseThreshold = 3;
|
||||||
protected RagdollPreset preset = new HumanoidRagdollPreset();
|
protected RagdollPreset preset = new HumanoidRagdollPreset();
|
||||||
|
protected List<String> boneList = new LinkedList<String>();
|
||||||
|
|
||||||
public RagdollControl() {
|
public RagdollControl() {
|
||||||
}
|
}
|
||||||
@ -78,6 +80,8 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
if (control) {
|
if (control) {
|
||||||
|
|
||||||
Quaternion q2 = vars.quat1;
|
Quaternion q2 = vars.quat1;
|
||||||
|
Quaternion q3 = vars.quat2;
|
||||||
|
Vector3f p2 = vars.vect2;
|
||||||
// skeleton.reset();
|
// skeleton.reset();
|
||||||
for (PhysicsBoneLink link : boneLinks.values()) {
|
for (PhysicsBoneLink link : boneLinks.values()) {
|
||||||
|
|
||||||
@ -101,9 +105,12 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (boneList.isEmpty()) {
|
||||||
link.bone.setUserControl(true);
|
link.bone.setUserControl(true);
|
||||||
link.bone.setUserTransformsWorld(position, q2);
|
link.bone.setUserTransformsWorld(position, q2);
|
||||||
|
} else {
|
||||||
|
setTransform(link.bone, position, q2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,6 +119,9 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
for (PhysicsBoneLink link : boneLinks.values()) {
|
for (PhysicsBoneLink link : boneLinks.values()) {
|
||||||
//the ragdoll does not control the skeleton
|
//the ragdoll does not control the skeleton
|
||||||
link.bone.setUserControl(false);
|
link.bone.setUserControl(false);
|
||||||
|
if (!link.rigidBody.isKinematic()) {
|
||||||
|
link.rigidBody.setKinematic(true);
|
||||||
|
}
|
||||||
|
|
||||||
Vector3f position = vars.vect1;
|
Vector3f position = vars.vect1;
|
||||||
Quaternion rotation = vars.quat1;
|
Quaternion rotation = vars.quat1;
|
||||||
@ -134,6 +144,21 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setTransform(Bone bone, Vector3f pos, Quaternion rot) {
|
||||||
|
bone.setUserControl(true);
|
||||||
|
bone.setUserTransformsWorld(pos, rot);
|
||||||
|
for (Bone childBone : bone.getChildren()) {
|
||||||
|
if (!boneList.contains(childBone.getName())) {
|
||||||
|
Vector3f tmpVec = childBone.getTmpVec();
|
||||||
|
Quaternion tmpQuat = childBone.getTmpQuat();
|
||||||
|
rot.mult(childBone.getLocalPosition(), tmpVec).addLocal(pos);
|
||||||
|
tmpQuat.set(rot).multLocal(childBone.getLocalRotation());
|
||||||
|
setTransform(childBone, tmpVec, tmpQuat);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Control cloneForSpatial(Spatial spatial) {
|
public Control cloneForSpatial(Spatial spatial) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
@ -178,7 +203,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addBoneName(String name) {
|
public void addBoneName(String name) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
boneList.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanSpatial(Spatial model) {
|
private void scanSpatial(Spatial model) {
|
||||||
@ -204,7 +229,8 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void boneRecursion(Spatial model, Bone bone, PhysicsRigidBody parent, int reccount) {
|
private void boneRecursion(Spatial model, Bone bone, PhysicsRigidBody parent, int reccount) {
|
||||||
|
PhysicsRigidBody parentShape = parent;
|
||||||
|
if (boneList.isEmpty() || boneList.contains(bone.getName())) {
|
||||||
//get world space position of the bone
|
//get world space position of the bone
|
||||||
Vector3f pos = bone.getModelSpacePosition().add(model.getLocalTranslation());
|
Vector3f pos = bone.getModelSpacePosition().add(model.getLocalTranslation());
|
||||||
// Quaternion rot = bone.getModelSpaceRotation().mult(initRotation);
|
// Quaternion rot = bone.getModelSpaceRotation().mult(initRotation);
|
||||||
@ -219,6 +245,7 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
PhysicsBoneLink link = new PhysicsBoneLink();
|
PhysicsBoneLink link = new PhysicsBoneLink();
|
||||||
link.bone = bone;
|
link.bone = bone;
|
||||||
link.rigidBody = shapeNode;
|
link.rigidBody = shapeNode;
|
||||||
|
|
||||||
link.initalWorldRotation = bone.getModelSpaceRotation().clone();
|
link.initalWorldRotation = bone.getModelSpaceRotation().clone();
|
||||||
// link.mass = 10.0f / (float) reccount;
|
// link.mass = 10.0f / (float) reccount;
|
||||||
|
|
||||||
@ -236,6 +263,8 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
link.pivotB = new Vector3f(0, 0, 0f);
|
link.pivotB = new Vector3f(0, 0, 0f);
|
||||||
|
|
||||||
SixDofJoint joint = new SixDofJoint(parent, shapeNode, link.pivotA, link.pivotB, true);
|
SixDofJoint joint = new SixDofJoint(parent, shapeNode, link.pivotA, link.pivotB, true);
|
||||||
|
joint.getTranslationalLimitMotor().setUpperLimit(new Vector3f(0, 0, 0));
|
||||||
|
joint.getTranslationalLimitMotor().setLowerLimit(new Vector3f(0, 0, 0));
|
||||||
//TODO find a way to correctly compute/import joints (maybe based on their names)
|
//TODO find a way to correctly compute/import joints (maybe based on their names)
|
||||||
preset.setupJointForBone(bone.getName(), joint);
|
preset.setupJointForBone(bone.getName(), joint);
|
||||||
//setJointLimit(joint, 0, 0, 0, 0, 0, 0);
|
//setJointLimit(joint, 0, 0, 0, 0, 0, 0);
|
||||||
@ -245,12 +274,15 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
}
|
}
|
||||||
boneLinks.put(bone.getName(), link);
|
boneLinks.put(bone.getName(), link);
|
||||||
shapeNode.setUserObject(link);
|
shapeNode.setUserObject(link);
|
||||||
|
parentShape = shapeNode;
|
||||||
|
}
|
||||||
|
|
||||||
for (Iterator<Bone> it = bone.getChildren().iterator(); it.hasNext();) {
|
for (Iterator<Bone> it = bone.getChildren().iterator(); it.hasNext();) {
|
||||||
Bone childBone = it.next();
|
Bone childBone = it.next();
|
||||||
boneRecursion(model, childBone, shapeNode, reccount++);
|
boneRecursion(model, childBone, parentShape, reccount++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,17 +355,31 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HullCollisionShape makeShape(Bone bone, Spatial model) {
|
private HullCollisionShape makeShape(Bone bone, Spatial model) {
|
||||||
int boneIndex = skeleton.getBoneIndex(bone);
|
|
||||||
|
List<Integer> boneIndices = null;
|
||||||
|
if (boneList.isEmpty()) {
|
||||||
|
boneIndices = new LinkedList<Integer>();
|
||||||
|
boneIndices.add(skeleton.getBoneIndex(bone));
|
||||||
|
} else {
|
||||||
|
boneIndices = getBoneIndices(bone, skeleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ArrayList<Float> points = new ArrayList<Float>();
|
ArrayList<Float> points = new ArrayList<Float>();
|
||||||
if (model instanceof Geometry) {
|
if (model instanceof Geometry) {
|
||||||
Geometry g = (Geometry) model;
|
Geometry g = (Geometry) model;
|
||||||
points.addAll(getPoints(g.getMesh(), boneIndex, bone.getModelSpacePosition()));
|
for (Integer index : boneIndices) {
|
||||||
|
points.addAll(getPoints(g.getMesh(), index, bone.getModelSpacePosition()));
|
||||||
|
}
|
||||||
} else if (model instanceof Node) {
|
} else if (model instanceof Node) {
|
||||||
Node node = (Node) model;
|
Node node = (Node) model;
|
||||||
for (Spatial s : node.getChildren()) {
|
for (Spatial s : node.getChildren()) {
|
||||||
if (s instanceof Geometry) {
|
if (s instanceof Geometry) {
|
||||||
Geometry g = (Geometry) s;
|
Geometry g = (Geometry) s;
|
||||||
points.addAll(getPoints(g.getMesh(), boneIndex, bone.getModelSpacePosition()));
|
for (Integer index : boneIndices) {
|
||||||
|
points.addAll(getPoints(g.getMesh(), index, bone.getModelSpacePosition()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,6 +391,17 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
return new HullCollisionShape(p);
|
return new HullCollisionShape(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Integer> getBoneIndices(Bone bone, Skeleton skeleton) {
|
||||||
|
List<Integer> list = new LinkedList<Integer>();
|
||||||
|
list.add(skeleton.getBoneIndex(bone));
|
||||||
|
for (Bone chilBone : bone.getChildren()) {
|
||||||
|
if (!boneList.contains(chilBone.getName())) {
|
||||||
|
list.addAll(getBoneIndices(chilBone, skeleton));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
protected List<Float> getPoints(Mesh mesh, int boneIndex, Vector3f offset) {
|
protected List<Float> getPoints(Mesh mesh, int boneIndex, Vector3f offset) {
|
||||||
|
|
||||||
FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
|
FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
|
||||||
@ -529,10 +586,22 @@ public class RagdollControl implements PhysicsControl, PhysicsCollisionListener
|
|||||||
|
|
||||||
this.control = control;
|
this.control = control;
|
||||||
for (PhysicsBoneLink link : boneLinks.values()) {
|
for (PhysicsBoneLink link : boneLinks.values()) {
|
||||||
link.bone.setUserControl(control);
|
// link.bone.setUserControl(control);
|
||||||
link.rigidBody.setKinematic(!control);
|
link.rigidBody.setKinematic(!control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (Bone bone : skeleton.getRoots()) {
|
||||||
|
setUserControl(bone, control);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUserControl(Bone bone, boolean bool) {
|
||||||
|
bone.setUserControl(bool);
|
||||||
|
for (Bone child : bone.getChildren()) {
|
||||||
|
setUserControl(child, bool);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasControl() {
|
public boolean hasControl() {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package com.jme3.bullet.control;
|
package com.jme3.bullet.control.radoll;
|
||||||
|
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package com.jme3.bullet.control;
|
package com.jme3.bullet.control.radoll;
|
||||||
|
|
||||||
import com.jme3.bullet.joints.SixDofJoint;
|
import com.jme3.bullet.joints.SixDofJoint;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -91,11 +91,11 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
bulletAppState = new BulletAppState();
|
bulletAppState = new BulletAppState();
|
||||||
bulletAppState.setEnabled(true);
|
bulletAppState.setEnabled(true);
|
||||||
stateManager.attach(bulletAppState);
|
stateManager.attach(bulletAppState);
|
||||||
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
//bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||||
setupLight();
|
setupLight();
|
||||||
|
|
||||||
model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
|
model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
|
||||||
// model.setLocalTranslation(5, 0, 5);
|
// model.setLocalTranslation(5, 0, 5);
|
||||||
// model.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_X));
|
// model.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_X));
|
||||||
|
|
||||||
@ -109,24 +109,26 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
skeletonDebug.setLocalTranslation(model.getLocalTranslation());
|
skeletonDebug.setLocalTranslation(model.getLocalTranslation());
|
||||||
|
|
||||||
//Note: PhysicsRagdollControl is still TODO, constructor will change
|
//Note: PhysicsRagdollControl is still TODO, constructor will change
|
||||||
ragdoll = new RagdollControl(1.0f);
|
ragdoll = new RagdollControl(0.7f);
|
||||||
|
setupSinbad(ragdoll);
|
||||||
ragdoll.addCollisionListener(this);
|
ragdoll.addCollisionListener(this);
|
||||||
model.addControl(ragdoll);
|
model.addControl(ragdoll);
|
||||||
|
|
||||||
float eighth_pi = FastMath.PI * 0.125f;
|
float eighth_pi = FastMath.PI * 0.125f;
|
||||||
|
|
||||||
//Oto's head is almost rigid
|
//Oto's head is almost rigid
|
||||||
ragdoll.setJointLimit("head", 0, 0, eighth_pi, -eighth_pi, 0, 0);
|
// ragdoll.setJointLimit("head", 0, 0, eighth_pi, -eighth_pi, 0, 0);
|
||||||
|
|
||||||
getPhysicsSpace().add(ragdoll);
|
getPhysicsSpace().add(ragdoll);
|
||||||
speed = 1.3f;
|
speed = 1.3f;
|
||||||
|
|
||||||
rootNode.attachChild(model);
|
rootNode.attachChild(model);
|
||||||
|
// rootNode.attachChild(skeletonDebug);
|
||||||
flyCam.setMoveSpeed(50);
|
flyCam.setMoveSpeed(50);
|
||||||
|
|
||||||
|
|
||||||
final AnimChannel channel = control.createChannel();
|
final AnimChannel channel = control.createChannel();
|
||||||
channel.setAnim("Walk");
|
channel.setAnim("Dance");
|
||||||
|
|
||||||
inputManager.addListener(new ActionListener() {
|
inputManager.addListener(new ActionListener() {
|
||||||
|
|
||||||
@ -137,6 +139,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
if (name.equals("shoot") && isPressed) {
|
if (name.equals("shoot") && isPressed) {
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (name.equals("stop") && isPressed) {
|
||||||
|
bulletAppState.setEnabled(!bulletAppState.isEnabled());
|
||||||
|
|
||||||
}
|
}
|
||||||
if (name.equals("shoot") && !isPressed) {
|
if (name.equals("shoot") && !isPressed) {
|
||||||
Geometry bulletg = new Geometry("bullet", bullet);
|
Geometry bulletg = new Geometry("bullet", bullet);
|
||||||
@ -155,9 +161,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "toggle", "shoot");
|
}, "toggle", "shoot","stop");
|
||||||
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
|
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
|
||||||
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||||
|
inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_H));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +215,8 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
|
|
||||||
public void collide(Bone bone, PhysicsCollisionObject object) {
|
public void collide(Bone bone, PhysicsCollisionObject object) {
|
||||||
|
|
||||||
if(object.getUserObject()!=null && object.getUserObject() instanceof Geometry){
|
if (object.getUserObject() != null && object.getUserObject() instanceof Geometry) {
|
||||||
Geometry geom=(Geometry)object.getUserObject();
|
Geometry geom = (Geometry) object.getUserObject();
|
||||||
if ("Floor".equals(geom.getName())) {
|
if ("Floor".equals(geom.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -218,12 +225,105 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
|
|
||||||
if (!ragdoll.hasControl()) {
|
if (!ragdoll.hasControl()) {
|
||||||
|
|
||||||
// bulletTime();
|
//bulletTime();
|
||||||
ragdoll.setControl(true);
|
ragdoll.setControl(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupSinbad(RagdollControl ragdoll) {
|
||||||
|
ragdoll.addBoneName("Ulna.L");
|
||||||
|
ragdoll.addBoneName("Ulna.R");
|
||||||
|
ragdoll.addBoneName("Chest");
|
||||||
|
ragdoll.addBoneName("Foot.L");
|
||||||
|
ragdoll.addBoneName("Foot.R");
|
||||||
|
ragdoll.addBoneName("Hand.R");
|
||||||
|
ragdoll.addBoneName("Hand.L");
|
||||||
|
ragdoll.addBoneName("Neck");
|
||||||
|
ragdoll.addBoneName("Head");
|
||||||
|
ragdoll.addBoneName("Root");
|
||||||
|
ragdoll.addBoneName("Stomach");
|
||||||
|
ragdoll.addBoneName("Waist");
|
||||||
|
ragdoll.addBoneName("Humerus.L");
|
||||||
|
ragdoll.addBoneName("Humerus.R");
|
||||||
|
ragdoll.addBoneName("Thigh.L");
|
||||||
|
ragdoll.addBoneName("Thigh.R");
|
||||||
|
ragdoll.addBoneName("Calf.L");
|
||||||
|
ragdoll.addBoneName("Calf.R");
|
||||||
|
ragdoll.addBoneName("Clavicle.L");
|
||||||
|
ragdoll.addBoneName("Clavicle.R");
|
||||||
|
|
||||||
|
// <boneparent bone="ThumbMed.R" parent="ThumbProx.R" />
|
||||||
|
// <boneparent bone="IndexFingerMed.R" parent="IndexFingerProx.R" />
|
||||||
|
// <boneparent bone="Clavicle.R" parent="Chest" />
|
||||||
|
// <boneparent bone="PinkyDist.L" parent="PinkyMed.L" />
|
||||||
|
// <boneparent bone="IndexFingerDist.R" parent="IndexFingerMed.R" />
|
||||||
|
// <boneparent bone="Cheek.L" parent="Head" />
|
||||||
|
// <boneparent bone="MiddleFingerMed.L" parent="MiddleFingerProx.L" />
|
||||||
|
// <boneparent bone="Jaw" parent="Head" />
|
||||||
|
// <boneparent bone="TongueMid" parent="TongueBase" />
|
||||||
|
// <boneparent bone="Ulna.L" parent="Humerus.L" />
|
||||||
|
// <boneparent bone="Handle.R" parent="Hand.R" />
|
||||||
|
// <boneparent bone="Ulna.R" parent="Humerus.R" />
|
||||||
|
// <boneparent bone="Chest" parent="Stomach" />
|
||||||
|
// <boneparent bone="Foot.L" parent="Calf.L" />
|
||||||
|
// <boneparent bone="Foot.R" parent="Calf.R" />
|
||||||
|
// <boneparent bone="Hand.R" parent="Ulna.R" />
|
||||||
|
// <boneparent bone="IndexFingerDist.L" parent="IndexFingerMed.L" />
|
||||||
|
// <boneparent bone="Cheek.R" parent="Head" />
|
||||||
|
// <boneparent bone="PinkyDist.R" parent="PinkyMed.R" />
|
||||||
|
// <boneparent bone="IndexFingerProx.R" parent="Hand.R" />
|
||||||
|
// <boneparent bone="Handle.L" parent="Hand.L" />
|
||||||
|
// <boneparent bone="RingFingerProx.R" parent="Hand.R" />
|
||||||
|
// <boneparent bone="LowerLip" parent="Jaw" />
|
||||||
|
// <boneparent bone="Neck" parent="Chest" />
|
||||||
|
// <boneparent bone="TongueBase" parent="Jaw" />
|
||||||
|
// <boneparent bone="Head" parent="Neck" />
|
||||||
|
// <boneparent bone="Sheath.R" parent="Chest" />
|
||||||
|
// <boneparent bone="Stomach" parent="Waist" />
|
||||||
|
// <boneparent bone="Toe.L" parent="Foot.L" />
|
||||||
|
// <boneparent bone="MiddleFingerProx.L" parent="Hand.L" />
|
||||||
|
// <boneparent bone="RingFingerMed.L" parent="RingFingerProx.L" />
|
||||||
|
// <boneparent bone="PinkyMed.L" parent="PinkyProx.L" />
|
||||||
|
// <boneparent bone="MiddleFingerMed.R" parent="MiddleFingerProx.R" />
|
||||||
|
// <boneparent bone="ThumbProx.L" parent="Hand.L" />
|
||||||
|
// <boneparent bone="PinkyMed.R" parent="PinkyProx.R" />
|
||||||
|
// <boneparent bone="Clavicle.L" parent="Chest" />
|
||||||
|
// <boneparent bone="MiddleFingerProx.R" parent="Hand.R" />
|
||||||
|
// <boneparent bone="Toe.R" parent="Foot.R" />
|
||||||
|
// <boneparent bone="Sheath.L" parent="Chest" />
|
||||||
|
// <boneparent bone="TongueTip" parent="TongueMid" />
|
||||||
|
// <boneparent bone="RingFingerProx.L" parent="Hand.L" />
|
||||||
|
// <boneparent bone="Waist" parent="Root" />
|
||||||
|
// <boneparent bone="MiddleFingerDist.R" parent="MiddleFingerMed.R" />
|
||||||
|
// <boneparent bone="Hand.L" parent="Ulna.L" />
|
||||||
|
// <boneparent bone="Humerus.R" parent="Clavicle.R" />
|
||||||
|
// <boneparent bone="RingFingerDist.L" parent="RingFingerMed.L" />
|
||||||
|
// <boneparent bone="Eye.L" parent="Head" />
|
||||||
|
// <boneparent bone="Humerus.L" parent="Clavicle.L" />
|
||||||
|
// <boneparent bone="RingFingerDist.R" parent="RingFingerMed.R" />
|
||||||
|
// <boneparent bone="MiddleFingerDist.L" parent="MiddleFingerMed.L" />
|
||||||
|
// <boneparent bone="IndexFingerMed.L" parent="IndexFingerProx.L" />
|
||||||
|
// <boneparent bone="ThumbMed.L" parent="ThumbProx.L" />
|
||||||
|
// <boneparent bone="Thigh.L" parent="Root" />
|
||||||
|
// <boneparent bone="UpperLip" parent="Head" />
|
||||||
|
// <boneparent bone="RingFingerMed.R" parent="RingFingerProx.R" />
|
||||||
|
// <boneparent bone="Eye.R" parent="Head" />
|
||||||
|
// <boneparent bone="Brow.L" parent="Head" />
|
||||||
|
// <boneparent bone="Brow.C" parent="Head" />
|
||||||
|
// <boneparent bone="Calf.L" parent="Thigh.L" />
|
||||||
|
// <boneparent bone="PinkyProx.L" parent="Hand.L" />
|
||||||
|
// <boneparent bone="ThumbDist.L" parent="ThumbMed.L" />
|
||||||
|
// <boneparent bone="ThumbProx.R" parent="Hand.R" />
|
||||||
|
// <boneparent bone="ThumbDist.R" parent="ThumbMed.R" />
|
||||||
|
// <boneparent bone="Calf.R" parent="Thigh.R" />
|
||||||
|
// <boneparent bone="PinkyProx.R" parent="Hand.R" />
|
||||||
|
// <boneparent bone="IndexFingerProx.L" parent="Hand.L" />
|
||||||
|
// <boneparent bone="Brow.R" parent="Head" />
|
||||||
|
// <boneparent bone="Thigh.R" parent="Root" />
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void bulletTime() {
|
private void bulletTime() {
|
||||||
speed = 0.1f;
|
speed = 0.1f;
|
||||||
elTime = 0;
|
elTime = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user