public CreepAnimControl(Creep creep) { this.creep = creep; // animations of creep animControl = creep.getCreepModel().getControl(AnimControl.class); animControl.addListener(this); // chanels channelAttack = animControl.createChannel(); channelDead = animControl.createChannel(); channelRunBase = animControl.createChannel(); channelRunTop = animControl.createChannel(); // random tool random = new Random(); }
// Gerneral function void setupPlayerControl() { this.animControl = ((Node) spatial).getChild("PlayerMesh").getControl(AnimControl.class); animChannel = animControl.createChannel(); if (playerInfo.getRole().equals(PlayerRole.GoalKeeper)) { animChannel.setAnim("Idle"); chasingBall = false; } else { animChannel.setAnim("RunFast"); chasingBall = true; } }
@Override public void setEnabled(boolean enabled) { // Pause and unpause super.setEnabled(enabled); if (enabled) { gameGUIManager.loadAndGotoScreen("editPlayer"); model = (Node) app.getAssetManager().loadModel("Models/Player/PlayerAni.j3o"); app.getRootNode().attachChild(model); app.getFlyByCamera().setDragToRotate(true); playerModel = (Node) model.getChild("PlayerMesh"); AnimControl animControl = playerModel.getControl(AnimControl.class); AnimChannel animChannel = animControl.createChannel(); animChannel.setAnim("Idle"); // System.out.println("Call me!"); app.getCamera().setLocation(model.getChild("CamNode").getWorldTranslation()); app.getCamera().lookAt(model.getChild("LookAtNode").getWorldTranslation(), Vector3f.UNIT_Y); } else { } }
/** Plays the specified animation or does nothing if the animation is not mapped. */ public void play(String animation) { log.debug("play(" + animation + ")"); if (Objects.equal(this.animation, animation)) { return; } List<Mapping> list = getMappings(animation, false); if (list == null) { list = getMappings(defaultAnimation, false); if (list == null) { // Just clear everything and hope for the best anim.clearChannels(); return; } } // Make sure there are enough channels while (anim.getNumChannels() < list.size()) { anim.createChannel(); } // Set the channels to the appropriate animation int i; for (i = 0; i < list.size(); i++) { Mapping m = list.get(i); AnimChannel channel = anim.getChannel(i); channel.setAnim(m.animation); channel.setSpeed(m.speed); } // Reset the rest for (; i < anim.getNumChannels(); i++) { AnimChannel channel = anim.getChannel(i); channel.reset(true); } }
private void initChannels() { fullBodyChannel = animControl.createChannel(); headChannel.setLoopMode(LoopMode.Loop); headChannel = animControl.createChannel(); headChannel.setLoopMode(LoopMode.Loop); leftArmChannel = animControl.createChannel(); leftArmChannel.setLoopMode(LoopMode.Loop); rightArmChannel = animControl.createChannel(); rightArmChannel.setLoopMode(LoopMode.Loop); leftLegChannel = animControl.createChannel(); leftLegChannel.setLoopMode(LoopMode.Loop); rightLegChannel = animControl.createChannel(); rightLegChannel.setLoopMode(LoopMode.Loop); }
private AnimChannel createRightArmChannels() { AnimChannel channel = animControl.createChannel(); channel.addFromRootBone("RightShoulder"); return channel; }
private AnimChannel createNeckChannel() { AnimChannel channel = animControl.createChannel(); channel.addFromRootBone("Neck"); return channel; }
private void setAnimationFullBody(String animationName, float blendTime, LoopMode loopMode) { animControl.clearChannels(); fullBodyChannel = animControl.createChannel(); fullBodyChannel.setLoopMode(loopMode); fullBodyChannel.setAnim(animationName, blendTime); }