use of com.jme3.scene.debug.SkeletonDebugger in project jmonkeyengine by jMonkeyEngine.
the class TestOgreComplexAnim method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
control = model.getControl(AnimControl.class);
AnimChannel feet = control.createChannel();
AnimChannel leftHand = control.createChannel();
AnimChannel rightHand = control.createChannel();
// feet will dodge
feet.addFromRootBone("hip.right");
feet.addFromRootBone("hip.left");
feet.setAnim("Dodge");
feet.setSpeed(2);
feet.setLoopMode(LoopMode.Cycle);
// will blend over 15 seconds to stand
feet.setAnim("Walk", 15);
feet.setSpeed(0.25f);
feet.setLoopMode(LoopMode.Cycle);
// left hand will pull
leftHand.addFromRootBone("uparm.right");
leftHand.setAnim("pull");
leftHand.setSpeed(.5f);
// will blend over 15 seconds to stand
leftHand.setAnim("stand", 15);
// right hand will push
rightHand.addBone("spinehigh");
rightHand.addFromRootBone("uparm.left");
rightHand.setAnim("push");
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat.getAdditionalRenderState().setDepthTest(false);
skeletonDebug.setMaterial(mat);
model.attachChild(skeletonDebug);
rootNode.attachChild(model);
}
use of com.jme3.scene.debug.SkeletonDebugger in project jmonkeyengine by jMonkeyEngine.
the class TestAnimBlendBug method simpleInitApp.
@Override
public void simpleInitApp() {
inputManager.addMapping("One", new KeyTrigger(KeyInput.KEY_1));
inputManager.addListener(this, "One");
flyCam.setMoveSpeed(100f);
cam.setLocation(new Vector3f(0f, 150f, -325f));
cam.lookAt(new Vector3f(0f, 100f, 0f), Vector3f.UNIT_Y);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
Node model1 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
Node model2 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
// Node model2 = model1.clone();
model1.setLocalTranslation(-60, 0, 0);
model2.setLocalTranslation(60, 0, 0);
AnimControl control1 = model1.getControl(AnimControl.class);
animNames = control1.getAnimationNames().toArray(new String[0]);
channel1 = control1.createChannel();
AnimControl control2 = model2.getControl(AnimControl.class);
channel2 = control2.createChannel();
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton1", control1.getSkeleton());
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat.getAdditionalRenderState().setDepthTest(false);
skeletonDebug.setMaterial(mat);
model1.attachChild(skeletonDebug);
skeletonDebug = new SkeletonDebugger("skeleton2", control2.getSkeleton());
skeletonDebug.setMaterial(mat);
model2.attachChild(skeletonDebug);
rootNode.attachChild(model1);
rootNode.attachChild(model2);
}
use of com.jme3.scene.debug.SkeletonDebugger in project jmonkeyengine by jMonkeyEngine.
the class TestBoneRagdoll method simpleInitApp.
public void simpleInitApp() {
initCrossHairs();
initMaterial();
cam.setLocation(new Vector3f(0.26924422f, 6.646658f, 22.265987f));
cam.setRotation(new Quaternion(-2.302544E-4f, 0.99302495f, -0.117888905f, -0.0019395084f));
bulletAppState = new BulletAppState();
bulletAppState.setEnabled(true);
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 1.0f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(1.0f);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
setupLight();
model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
// model.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_X));
//debug view
AnimControl control = model.getControl(AnimControl.class);
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
Material mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat2.getAdditionalRenderState().setWireframe(true);
mat2.setColor("Color", ColorRGBA.Green);
mat2.getAdditionalRenderState().setDepthTest(false);
skeletonDebug.setMaterial(mat2);
skeletonDebug.setLocalTranslation(model.getLocalTranslation());
//Note: PhysicsRagdollControl is still TODO, constructor will change
ragdoll = new KinematicRagdollControl(0.5f);
setupSinbad(ragdoll);
ragdoll.addCollisionListener(this);
model.addControl(ragdoll);
float eighth_pi = FastMath.PI * 0.125f;
ragdoll.setJointLimit("Waist", eighth_pi, eighth_pi, eighth_pi, eighth_pi, eighth_pi, eighth_pi);
ragdoll.setJointLimit("Chest", eighth_pi, eighth_pi, 0, 0, eighth_pi, eighth_pi);
//Oto's head is almost rigid
// ragdoll.setJointLimit("head", 0, 0, eighth_pi, -eighth_pi, 0, 0);
getPhysicsSpace().add(ragdoll);
speed = 1.3f;
rootNode.attachChild(model);
// rootNode.attachChild(skeletonDebug);
flyCam.setMoveSpeed(50);
animChannel = control.createChannel();
animChannel.setAnim("Dance");
control.addListener(this);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("toggle") && isPressed) {
Vector3f v = new Vector3f();
v.set(model.getLocalTranslation());
v.y = 0;
model.setLocalTranslation(v);
Quaternion q = new Quaternion();
float[] angles = new float[3];
model.getLocalRotation().toAngles(angles);
q.fromAngleAxis(angles[1], Vector3f.UNIT_Y);
model.setLocalRotation(q);
if (angles[0] < 0) {
animChannel.setAnim("StandUpBack");
ragdoll.blendToKinematicMode(0.5f);
} else {
animChannel.setAnim("StandUpFront");
ragdoll.blendToKinematicMode(0.5f);
}
}
if (name.equals("bullet+") && isPressed) {
bulletSize += 0.1f;
}
if (name.equals("bullet-") && isPressed) {
bulletSize -= 0.1f;
}
if (name.equals("stop") && isPressed) {
ragdoll.setEnabled(!ragdoll.isEnabled());
ragdoll.setRagdollMode();
}
if (name.equals("shoot") && !isPressed) {
Geometry bulletg = new Geometry("bullet", bullet);
bulletg.setMaterial(matBullet);
bulletg.setLocalTranslation(cam.getLocation());
bulletg.setLocalScale(bulletSize);
bulletCollisionShape = new SphereCollisionShape(bulletSize);
RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, bulletSize * 10);
bulletNode.setCcdMotionThreshold(0.001f);
bulletNode.setLinearVelocity(cam.getDirection().mult(80));
bulletg.addControl(bulletNode);
rootNode.attachChild(bulletg);
getPhysicsSpace().add(bulletNode);
}
if (name.equals("boom") && !isPressed) {
Geometry bulletg = new Geometry("bullet", bullet);
bulletg.setMaterial(matBullet);
bulletg.setLocalTranslation(cam.getLocation());
bulletg.setLocalScale(bulletSize);
bulletCollisionShape = new SphereCollisionShape(bulletSize);
BombControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1);
bulletNode.setForceFactor(8);
bulletNode.setExplosionRadius(20);
bulletNode.setCcdMotionThreshold(0.001f);
bulletNode.setLinearVelocity(cam.getDirection().mult(180));
bulletg.addControl(bulletNode);
rootNode.attachChild(bulletg);
getPhysicsSpace().add(bulletNode);
}
}
}, "toggle", "shoot", "stop", "bullet+", "bullet-", "boom");
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping("boom", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("bullet-", new KeyTrigger(KeyInput.KEY_COMMA));
inputManager.addMapping("bullet+", new KeyTrigger(KeyInput.KEY_PERIOD));
}
use of com.jme3.scene.debug.SkeletonDebugger in project jmonkeyengine by jMonkeyEngine.
the class FbxNode method createScene.
public static Spatial createScene(FbxNode fbxNode) {
Spatial jmeSpatial = fbxNode.getJmeObject();
if (jmeSpatial instanceof Node) {
// Attach children to Node
Node jmeNode = (Node) jmeSpatial;
for (FbxNode fbxChild : fbxNode.children) {
if (!(fbxChild instanceof FbxLimbNode)) {
createScene(fbxChild);
FbxNode preferredParent = fbxChild.getPreferredParent();
Spatial jmeChild = fbxChild.getJmeObject();
if (preferredParent != null) {
System.out.println("Preferred parent for " + fbxChild + " is " + preferredParent);
Node jmePreferredParent = (Node) preferredParent.getJmeObject();
relocateSpatial(jmeChild, fbxChild.jmeWorldNodeTransform, preferredParent.jmeWorldNodeTransform);
jmePreferredParent.attachChild(jmeChild);
} else {
jmeNode.attachChild(jmeChild);
}
}
}
}
if (fbxNode.skeleton != null) {
jmeSpatial.addControl(new AnimControl(fbxNode.skeleton));
jmeSpatial.addControl(new SkeletonControl(fbxNode.skeleton));
SkeletonDebugger sd = new SkeletonDebugger("debug", fbxNode.skeleton);
Material mat = new Material(fbxNode.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.getAdditionalRenderState().setDepthTest(false);
mat.setColor("Color", ColorRGBA.Green);
sd.setMaterial(mat);
((Node) jmeSpatial).attachChild(sd);
}
return jmeSpatial;
}
Aggregations