private void setupAnimationController() { animationControl = model.getControl(AnimControl.class); animationControl.addListener(this); animationChannel = animationControl.createChannel(); shootingChannel = animationControl.createChannel(); shootingChannel.addBone(animationControl.getSkeleton().getBone("uparm.right")); shootingChannel.addBone(animationControl.getSkeleton().getBone("arm.right")); shootingChannel.addBone(animationControl.getSkeleton().getBone("hand.right")); }
AnimChannel animChannel = animControl.createChannel();
channel = model.getControl(AnimControl.class).createChannel(); map.put(channelIndex, channel); } else {
@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"); }
AnimChannel feet = control.createChannel(); AnimChannel leftHand = control.createChannel(); AnimChannel rightHand = control.createChannel();
@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); 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); 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)); }
control.createChannel().setAnim("anim");
@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 = control.createChannel(); 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)); }
control = model.getControl(AnimControl.class); channel = control.createChannel(); channel.setAnim(animNames[(i + j) % 4]); channel.setLoopMode(LoopMode.DontLoop);
control.createChannel().setAnim("anim");
animChannel = control.createChannel(); animChannel.setAnim("Dance"); control.addListener(this);
@Override public void visit(Spatial spatial) { AnimControl animControl = (AnimControl) spatial.getControl(AnimControl.class); if (animControl != null) { AnimChannel channel = animControl.createChannel(); channel.setAnim("anim"); AnimationLoader.setLoopModeOnChannel(spatial, channel); } } });
@Override public void visit(Spatial spatial) { AnimControl animControl = spatial.getControl(AnimControl.class); if (animControl != null) { AnimChannel channel = animControl.createChannel(); channel.setAnim("anim"); AnimationLoader.setLoopModeOnChannel(spatial, channel); // Don't batch animated objects, seems not to work spatial.setBatchHint(Spatial.BatchHint.Never); } } });
public void onAction(String string, boolean bln, float f) { if (controlledAnimation != null) { AnimChannel channel = controlledAnimation.createChannel(); channel.setSpeed(0.001f); channel.setAnim("l_hip_rotateY"); controlledAnimation.setEnabled(!controlledAnimation.isEnabled()); } } }, "animate");
@Override public void visit(Spatial spatial) { AnimControl animControl = spatial.getControl(AnimControl.class); if (animControl != null) { AnimChannel channel = animControl.createChannel(); channel.setAnim("anim"); channel.setLoopMode(LoopMode.Loop); if (randomizeAnimation) { channel.setSpeed(FastMath.nextRandomInt(6, 10) / 10f); channel.setTime(FastMath.nextRandomFloat() * channel.getAnimMaxTime()); } // Don't batch animated objects, seems not to work object.setBatchHint(Spatial.BatchHint.Never); } } });
protected void moveViaAnimation(Vector3f newPosition, Quaternion newOrientation, float duration) { clearMoveAnimationBindings(); Vector3f currentPosition = myNode.getLocalTranslation(); Quaternion currentOrientation = myNode.getLocalRotation(); if (newPosition == null) { newPosition = currentPosition; } if (newOrientation == null) { newOrientation = currentOrientation; } AnimationFactory aniFactory = new AnimationFactory(duration, MOVE_ANIM_NAME); // First add starting position/rotation to timeline at index 0 aniFactory.addKeyFrameTranslation(0, currentPosition); aniFactory.addKeyFrameRotation(0, currentOrientation); // Now add new position/rotation at duration: aniFactory.addTimeTranslation(duration, newPosition); aniFactory.addTimeRotation(duration, newOrientation); // Finally the Animation is generated and linked to the geometry via an AnimationControl Animation moveAnimation = aniFactory.buildAnimation(); figureControl.addAnim(moveAnimation); myNode.addControl(figureControl); AnimChannel moveChannel = figureControl.createChannel(); moveChannel.setAnim(MOVE_ANIM_NAME, 0f); // Oddly, it seems this needs to be set *after* starting the animation with setAnim: moveChannel.setLoopMode(LoopMode.DontLoop); }