public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { if (channel == shootingChannel) { channel.setAnim("stand"); } }
/** * Set the current animation that is played by this AnimChannel. * <p> * See {@link #setAnim(java.lang.String, float)}. * The blendTime argument by default is 150 milliseconds. * * @param name The name of the animation to play */ public void setAnim(String name){ setAnim(name, DEFAULT_BLEND_TIME); }
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("Walk") && !keyPressed) { if (!channel.getAnimationName().equals("Walk")) { /** Play the "walk" animation! */ channel.setAnim("Walk", 0.50f); channel.setLoopMode(LoopMode.Loop); } } } };
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { if (animName.equals("Dodge")){ channel.setAnim("stand", 0.50f); channel.setLoopMode(LoopMode.DontLoop); channel.setSpeed(1f); } }
@Override public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { if (animName.equals("Punches")) { channel.setAnim("Idle", 0.5f); channel.setLoopMode(LoopMode.DontLoop); channel.setSpeed(1f); } }
/** Use this listener to trigger something after an animation is done. */ public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { if (animName.equals("Walk")) { /** After "walk", reset to "stand". */ channel.setAnim("stand", 0.50f); channel.setLoopMode(LoopMode.DontLoop); channel.setSpeed(1f); } }
animChannel.setAnim("SliceHorizontal"); animChannel.setSpeed(0.3f);
public void onAction(String binding, boolean value, float tpf) { if (binding.equals("Attack") && value){ if (!channel.getAnimationName().equals("Dodge")){ channel.setAnim("Dodge", 0.50f); channel.setLoopMode(LoopMode.Cycle); channel.setSpeed(0.10f); } } }
@Override public void onAction(String binding, boolean value, float tpf) { if (binding.equals("Attack") && value) { if (!channel.getAnimationName().equals("Punches")) { channel.setAnim("Punches", 0.5f); channel.setLoopMode(LoopMode.Cycle); channel.setSpeed(0.5f); } } } }
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { if (channel.getAnimationName().equals("SliceHorizontal")) { channel.setLoopMode(LoopMode.DontLoop); channel.setAnim("IdleTop", 5); channel.setLoopMode(LoopMode.Loop); } }
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { // if(channel.getAnimationName().equals("StandUpFront")){ // channel.setAnim("Dance"); // } if (channel.getAnimationName().equals("StandUpBack") || channel.getAnimationName().equals("StandUpFront")) { channel.setLoopMode(LoopMode.DontLoop); channel.setAnim("IdleTop", 5); channel.setLoopMode(LoopMode.Loop); } // if(channel.getAnimationName().equals("IdleTop")){ // channel.setAnim("StandUpFront"); // } }
@Override public void onPlay() { channel.getControl().setEnabled(true); if (playState == PlayState.Stopped) { channel.setAnim(animationName, blendTime); channel.setSpeed(speed); channel.setLoopMode(loopMode); channel.setTime(0); } }
@Override public void simpleInitApp() { viewPort.setBackgroundColor(ColorRGBA.LightGray); initKeys(); /** Add a light source so we can see the model */ DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal()); rootNode.addLight(dl); /** Load a model that contains animation */ player = (Node) assetManager.loadModel("Models/Oto/OtoOldAnim.j3o"); player.setLocalScale(0.5f); rootNode.attachChild(player); /** Create a controller and channels. */ control = player.getControl(AnimControl.class); control.addListener(this); channel = control.createChannel(); channel.setAnim("stand"); }
private void bulletControl() { shootingChannel.setAnim("Dodge", 0.1f); shootingChannel.setLoopMode(LoopMode.DontLoop); Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(matBullet); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(character.getPhysicsLocation().add(cam.getDirection().mult(5))); RigidBodyControl bulletControl = new BombControl(bulletCollisionShape, 1); bulletControl.setCcdMotionThreshold(0.1f); bulletControl.setLinearVelocity(cam.getDirection().mult(80)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletControl); }
@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); BlenderKey blenderKey = new BlenderKey("Blender/2.4x/BaseMesh_249.blend"); Spatial scene = (Spatial) assetManager.loadModel(blenderKey); rootNode.attachChild(scene); Spatial model = this.findNode(rootNode, "BaseMesh_01"); model.center(); control = model.getControl(AnimControl.class); channel = control.createChannel(); channel.setAnim("run_01"); }
@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); BlenderKey blenderKey = new BlenderKey("Blender/2.4x/animtest.blend"); Spatial scene = (Spatial) assetManager.loadModel(blenderKey); rootNode.attachChild(scene); Spatial model = this.findNode(rootNode, "Cube"); model.center(); control = model.getControl(AnimControl.class); channel = control.createChannel(); channel.setAnim("Action"); }
@Override public void simpleInitApp() { flyCam.setMoveSpeed(10f); flyCam.setDragToRotate(true); setPauseOnLostFocus(false); cam.setLocation(new Vector3f(24.746134f, 13.081396f, 32.72753f)); cam.setRotation(new Quaternion(-0.06867662f, 0.92435044f, -0.19981281f, -0.31770203f)); makeHudText(); 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); for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { Spatial model = (Spatial) assetManager.loadModel("Models/Oto/OtoOldAnim.j3o"); model.setLocalScale(0.1f); model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2); control = model.getControl(AnimControl.class); channel = control.createChannel(); channel.setAnim(animNames[(i + j) % 4]); SkeletonControl skeletonControl = model.getControl(SkeletonControl.class); skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable); skControls.add(skeletonControl); rootNode.attachChild(model); } } inputManager.addListener(this, "toggleHWS"); inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE)); }
@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); Spatial model = (Spatial) assetManager.loadModel("Models/Oto/OtoOldAnim.j3o"); model.center(); control = model.getControl(AnimControl.class); control.addListener(this); channel = control.createChannel(); for (String anim : control.getAnimationNames()) System.out.println(anim); channel.setAnim("stand"); geom = (Geometry)((Node)model).getChild(0); SkeletonControl skeletonControl = model.getControl(SkeletonControl.class); Box b = new Box(.25f,3f,.25f); Geometry item = new Geometry("Item", b); item.move(0, 1.5f, 0); item.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); Node n = skeletonControl.getAttachmentsNode("hand.right"); n.attachChild(item); rootNode.attachChild(model); inputManager.addListener(this, "Attack"); inputManager.addMapping("Attack", new KeyTrigger(KeyInput.KEY_SPACE)); }
animChannel.setAnim("IdleTop"); control.addListener(this);
@Override public void simpleInitApp() { flyCam.setMoveSpeed(10f); cam.setLocation(new Vector3f(6.4f, 7.5f, 12.8f)); 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(ColorRGBA.White); rootNode.addLight(dl); Spatial model = assetManager.loadModel("Models/Jaime/Jaime.j3o"); control = model.getControl(AnimControl.class); SkeletonControl skeletonControl = model.getControl(SkeletonControl.class); model.center(); model.setLocalScale(5f); control.addListener(this); channel = control.createChannel(); channel.setAnim("Idle"); Box box = new Box(0.3f, 0.02f, 0.02f); Geometry saber = new Geometry("saber", box); saber.move(0.4f, 0.05f, 0.01f); Material red = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); saber.setMaterial(red); Node n = skeletonControl.getAttachmentsNode("hand.R"); n.attachChild(saber); rootNode.attachChild(model); inputManager.addListener(this, "Attack"); inputManager.addMapping("Attack", new KeyTrigger(KeyInput.KEY_SPACE)); }