/** * Creates an Animation based on the keyFrames previously added to the helper. * @return the generated animation */ public Animation buildAnimation() { interpolateTime(); interpolate(keyFramesTranslation, Type.Translation); interpolate(keyFramesRotation, Type.Rotation); interpolate(keyFramesScale, Type.Scale); SpatialTrack spatialTrack = new SpatialTrack(times, translations, rotations, scales); //creating the animation Animation spatialAnimation = new Animation(name, duration); spatialAnimation.setTracks(new SpatialTrack[]{spatialTrack}); return spatialAnimation; }
SpatialTrack[] tracks = action.toTracks(node, blenderContext); if (tracks != null && tracks.length > 0) { Animation spatialAnimation = new Animation(action.getName(), action.getAnimationTime()); spatialAnimation.setTracks(tracks); animations.add(spatialAnimation); blenderContext.addAnimation((Long) node.getUserData(ObjectHelper.OMA_MARKER), spatialAnimation); for (int i = 0; i < animations.size(); ++i) { Animation animation = animations.get(i); anims.put(animation.getName(), animation);
float animStart = animInfo.firstFrame / this.animFrameRate; float animStop = animInfo.lastFrame / this.animFrameRate; Animation anim = new Animation(animInfo.name, length); else track = new BoneTrack(limb.boneIndex, times, translations, rotations); anim.addTrack(track); Track[] tracks = anim.getTracks(); if(tracks == null || tracks.length == 0) continue; anim = new Animation(animInfo.name, realLength); for(Track track : tracks) anim.addTrack(track); anims.put(anim.getName(), anim);
blendFrom.setTime(timeBlendFrom, 1f - blendAmount, control, this, vars); blendFrom.getLength(), loopModeBlendFrom); if (timeBlendFrom < 0){ animation.setTime(time, blendAmount, control, this, vars); time += tpf * speed; if (animation.getLength() > 0){ if (!notified && (time >= animation.getLength() || time < 0)) { if (loopMode == LoopMode.DontLoop) { control.notifyAnimCycleDone(this, animation.getName()); time = AnimationUtils.clampWrapTime(time, animation.getLength(), loopMode); if (time < 0){
float animStart = animInfo.firstFrame / this.animFrameRate; float animStop = animInfo.lastFrame / this.animFrameRate; Animation anim = new Animation(animInfo.name, length); else track = new BoneTrack(limb.boneIndex, times, translations, rotations); anim.addTrack(track); anims.put(anim.getName(), anim);
/** * @return The name of the currently playing animation, or null if * none is assigned. * * @see AnimChannel#setAnim(java.lang.String) */ public String getAnimationName() { return animation != null ? animation.getName() : null; }
Animation anim = new Animation(); anim.setName(name); int skinIndex = -1; if (trackData.length > anim.getLength()) { anim.setLength(trackData.length); SpatialTrack track = new SpatialTrack(trackData.times, trackData.translations, trackData.rotations, trackData.scales); track.setTrackSpatial(s); anim.addTrack(track); } else if (node instanceof BoneWrapper) { BoneWrapper b = (BoneWrapper) node; anim.addTrack(track); if (!usedBones.contains(bone) && !equalBindAndLocalTransforms(bone)) { float[] times = new float[]{0, anim.getLength()}; anim.addTrack(track);
/** * 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(); } }
animation.setTracks(trackList); tracks.clear(); } else if (qName.equals("keyframe")) {
for (Track track : animation.getTracks()) { float time = ((BoneTrack) track).getTimes()[frame]; track.setTime(time, 1, animControl, animChannel, vars); if (newTrack != null) { boolean trackReplaced = false; for (Track track : animation.getTracks()) { if (((BoneTrack) track).getTargetBoneIndex() == trackEntry.getKey().intValue()) { animation.removeTrack(track); animation.addTrack(newTrack); trackReplaced = true; break; animation.addTrack(newTrack);
/** * @return The length of the currently playing animation, or zero * if no animation is playing. * * @see AnimChannel#getTime() */ public float getAnimMaxTime(){ return animation != null ? animation.getLength() : 0f; }
/** * Computes the maximum frame and time for the animation. Different tracks * can have different lengths so here the maximum one is being found. * * @param animation * the animation * @return maximum frame and time of the animation */ private float[] computeAnimationTimeBoundaries(Animation animation) { int maxFrame = Integer.MIN_VALUE; float maxTime = -Float.MAX_VALUE; for (Track track : animation.getTracks()) { if (track instanceof BoneTrack) { maxFrame = Math.max(maxFrame, ((BoneTrack) track).getTranslations().length); maxTime = Math.max(maxTime, ((BoneTrack) track).getTimes()[((BoneTrack) track).getTimes().length - 1]); } else if (track instanceof SpatialTrack) { maxFrame = Math.max(maxFrame, ((SpatialTrack) track).getTranslations().length); maxTime = Math.max(maxTime, ((SpatialTrack) track).getTimes()[((SpatialTrack) track).getTimes().length - 1]); } else { throw new IllegalStateException("Unsupported track type for simuation: " + track); } } return new float[] { maxFrame, maxTime }; }
/** * Adds an animation to be available for playing to this * <code>AnimControl</code>. * @param anim The animation to add. */ public void addAnim(Animation anim) { animationMap.put(anim.getName(), anim); }
blendFrom.setTime(timeBlendFrom, 1f - blendAmount, control, this, vars); blendFrom.getLength(), loopModeBlendFrom); if (timeBlendFrom < 0){ animation.setTime(time, blendAmount, control, this, vars); time += tpf * speed; if (animation.getLength() > 0){ if (!notified && (time >= animation.getLength() || time < 0)) { if (loopMode == LoopMode.DontLoop) { control.notifyAnimCycleDone(this, animation.getName()); time = clampWrapTime(time, animation.getLength(), loopMode); if (time < 0){
String name = SAXUtil.parseString(attribs.getValue("name")); float length = SAXUtil.parseFloat(attribs.getValue("length")); animation = new Animation(name, length); } else if (qName.equals("bonehierarchy")) { assert elementStack.peek().equals("skeleton");
animation.setTracks(trackList); tracks.clear(); } else if (qName.equals("keyframe")) {
for (Track track : animation.getTracks()) { for (int frame = 0; frame < maxFrame; ++frame) { spatial.setLocalTranslation(((SpatialTrack) track).getTranslations()[frame]); animation.removeTrack(track); animation.addTrack(newTrack);
/** * @param speed Set the speed of the animation channel. The speed * is a scale value starting from 0.0, at 1.0 the animation will play * at its default speed. */ public void setSpeed(float speed) { this.speed = speed; if(blendTime>0){ this.speedBlendFrom = speed; blendTime = Math.min(blendTime, animation.getLength() / speed); blendRate = 1/ blendTime; } }