/** * Add a single bone to be influenced by this animation channel. */ public void addBone(Bone bone) { int boneIndex = control.getSkeleton().getBoneIndex(bone); if(affectedBones == null) { affectedBones = new BitSet(control.getSkeleton().getBoneCount()); } affectedBones.set(boneIndex); }
if (animControl.getSkeleton() != skeleton) { throw new UnsupportedOperationException(); Animation anim = animControl.getAnim(animName); if (anim == null) { anim = new Animation(animName, duration); animControl.addAnim(anim); animControl = new AnimControl(null); jmeSpatial.addControl(animControl); animControl.addAnim(anim);
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")); }
AnimControl control = new AnimControl(); HashMap<String, Animation> anims = new HashMap<String, Animation>(animations.size()); for (int i = 0; i < animations.size(); ++i) { anims.put(animation.getName(), animation); control.setAnimations(anims); node.addControl(control);
AnimControl control = new AnimControl(); control.addAnim(animationFactory.buildAnimation()); control.createChannel().setAnim("anim");
@Override public void onPause() { if (channel != null) { channel.getControl().setEnabled(false); } }
/** * No ClassCastException when clear() a Cinematic with AnimationEvent */ @Test public void clearAnimationEvent() { Cinematic sut = new Cinematic(); Node model = new Node("model"); AnimControl ac = new AnimControl(); ac.addAnim(new Animation("animName", 1.0f)); model.addControl(ac); sut.enqueueCinematicEvent(new AnimationEvent(model, "animName")); sut.initialize(null, null); sut.clear(); } }
private AnimControl createAnimControl(Node parent, DAENode animationsNode, List<DAENode> geomElementList, Skeleton skeleton) { Mesh[] meshes = new Mesh[geomElementList.size()]; int index = 0; for (DAENode geomNode : geomElementList) { meshes[index] = geomNode.getParsedData(Mesh.class); index++; } Animation[] animations = createAnimations(animationsNode, skeleton); AnimControl animation = new AnimControl(skeleton); animation.setAnimations(new HashMap<String, Animation>()); for (Animation Animation : animations) { animation.addAnim(Animation); } animation.setEnabled(false); return animation; }
if (control != null) { AnimComposer composer = new AnimComposer(); Skeleton skeleton = control.getSkeleton(); if (skeleton == null) { for (String animName : control.getAnimationNames()) { tracks.clear(); Animation anim = control.getAnim(animName); AnimClip clip = new AnimClip(animName); Joint[] staticJoints = new Joint[joints.length];
boneAnim.setTracks(new BoneTrack[] {boneTrack}); final AnimControl anim = new AnimControl(skeleton); anim.setAnimations(new HashMap<String, Animation>()); anim.addAnim(boneAnim); AnimChannel channel = anim.createChannel(); channel.setAnim("test animation"); channel.setLoopMode(LoopMode.Loop);
AnimControl control = new AnimControl(); HashMap<String, Animation> animations = new HashMap<String, Animation>(); animations.put("anim", spatialAnimation); control.setAnimations(animations); model.addControl(control); control.createChannel().setAnim("anim");
AnimChannel feet = control.createChannel(); AnimChannel leftHand = control.createChannel(); AnimChannel rightHand = control.createChannel(); rightHand.setAnim("push"); SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton()); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true);
@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 applySkinning() { for(FbxBindPose pose : bindMap.values()) pose.fillBindTransforms(); if(limbMap == null) return; List<Bone> bones = new ArrayList<>(); for(FbxNode limb : limbMap.values()) { if(limb.bone != null) { bones.add(limb.bone); limb.buildBindPoseBoneTransform(); } } skeleton = new Skeleton(bones.toArray(new Bone[bones.size()])); skeleton.setBindingPose(); for(FbxNode limb : limbMap.values()) limb.setSkeleton(skeleton); for(FbxSkin skin : skinMap.values()) skin.generateSkinning(); // Attach controls animControl = new AnimControl(skeleton); sceneNode.addControl(animControl); SkeletonControl control = new SkeletonControl(skeleton); sceneNode.addControl(control); }
@Override public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { // Start the real animation Spatial spat = root.getChild(resource.getName()); AnimControl animControl = spat.getControl(AnimControl.class); spat.setCullHint(Spatial.CullHint.Inherit); AnimChannel c = animControl.getChannel(0); LoopMode loopMode = c.getLoopMode(); c.setAnim(ANIM_NAME, 0); if (loopMode != null) { c.setLoopMode(loopMode); } animControl.setEnabled(true); // Hide us control.setEnabled(false); control.getSpatial().setCullHint(Spatial.CullHint.Always); }
animControl.setEnabled(false); animControl.addListener(new AnimEventListener() { animControl.createChannel(); animControl.setEnabled(false); animControl.addListener(new AnimEventListener() { animControl.createChannel(); animControl.setEnabled(false); animControl.addListener(new AnimEventListener() { AnimChannel channel = animControl.createChannel(); if (resource.getFlags().contains(ArtResource.ArtResourceFlag.DOESNT_LOOP)) { channel.setLoopMode(LoopMode.DontLoop);
@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); 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)); }
if (s == null) { s = new HashMap<Integer, AnimChannel>(); int numChannels = model.getControl(AnimControl.class).getNumChannels(); for(int i = 0; i < numChannels; i++){ ((HashMap<Integer, AnimChannel>)s).put(i, model.getControl(AnimControl.class).getChannel(i)); channel = model.getControl(AnimControl.class).createChannel(); map.put(channelIndex, channel); } else {
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");