Java 类com.badlogic.gdx.graphics.g3d.model.Animation 实例源码

项目:libgdxcn    文件:BaseAnimationController.java   
/** Apply two animations, blending the second onto to first using weight. */
protected void applyAnimations (final Animation anim1, final float time1, final Animation anim2, final float time2,
    final float weight) {
    if (anim2 == null || weight == 0.f)
        applyAnimation(anim1, time1);
    else if (anim1 == null || weight == 1.f)
        applyAnimation(anim2, time2);
    else if (applying)
        throw new GdxRuntimeException("Call end() first");
    else {
        begin();
        apply(anim1, time1, 1.f);
        apply(anim2, time2, weight);
        end();
    }
}
项目:libgdxcn    文件:Model.java   
private void loadAnimations (Iterable<ModelAnimation> modelAnimations) {
    for (final ModelAnimation anim : modelAnimations) {
        Animation animation = new Animation();
        animation.id = anim.id;
        for (ModelNodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.nodeId);
            if (node == null) continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            for (ModelNodeKeyframe kf : nanim.keyframes) {
                if (kf.keytime > animation.duration) animation.duration = kf.keytime;
                NodeKeyframe keyframe = new NodeKeyframe();
                keyframe.keytime = kf.keytime;
                keyframe.rotation.set(kf.rotation == null ? node.rotation : kf.rotation);
                keyframe.scale.set(kf.scale == null ? node.scale : kf.scale);
                keyframe.translation.set(kf.translation == null ? node.translation : kf.translation);
                nodeAnim.keyframes.add(keyframe);
            }
            if (nodeAnim.keyframes.size > 0) animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0) animations.add(animation);
    }
}
项目:libgdxcn    文件:SkeletonTest.java   
protected void switchAnimation () {
    for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
        int animIndex = 0;
        if (e.value.current != null) {
            for (int i = 0; i < e.key.animations.size; i++) {
                final Animation animation = e.key.animations.get(i);
                if (e.value.current.animation == animation) {
                    animIndex = i;
                    break;
                }
            }
        }
        animIndex = (animIndex + 1) % e.key.animations.size;
        e.value.animate(e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
    }
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
protected void switchAnimation () {
    for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
        int animIndex = 0;
        if (e.value.current != null) {
            for (int i = 0; i < e.key.animations.size; i++) {
                final Animation animation = e.key.animations.get(i);
                if (e.value.current.animation == animation) {
                    animIndex = i;
                    break;
                }
            }
        }
        animIndex = (animIndex + 1) % e.key.animations.size;
        e.value.animate(e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
    }
}
项目:libgdxcn    文件:ModelTest.java   
protected void switchAnimation () {
    for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
        int animIndex = 0;
        if (e.value.current != null) {
            for (int i = 0; i < e.key.animations.size; i++) {
                final Animation animation = e.key.animations.get(i);
                if (e.value.current.animation == animation) {
                    animIndex = i;
                    break;
                }
            }
        }
        animIndex = (animIndex + 1) % (e.key.animations.size + 1);
        e.value.animate((animIndex == e.key.animations.size) ? null : e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
    }
}
项目:gdx-proto    文件:HeadlessModel.java   
private void loadAnimations (Iterable<ModelAnimation> modelAnimations) {
    for (final ModelAnimation anim : modelAnimations) {
        Animation animation = new Animation();
        animation.id = anim.id;
        for (ModelNodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.nodeId);
            if (node == null) continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            for (ModelNodeKeyframe kf : nanim.keyframes) {
                if (kf.keytime > animation.duration) animation.duration = kf.keytime;
                NodeKeyframe keyframe = new NodeKeyframe();
                keyframe.keytime = kf.keytime;
                keyframe.rotation.set(kf.rotation == null ? node.rotation : kf.rotation);
                keyframe.scale.set(kf.scale == null ? node.scale : kf.scale);
                keyframe.translation.set(kf.translation == null ? node.translation : kf.translation);
                nodeAnim.keyframes.add(keyframe);
            }
            if (nodeAnim.keyframes.size > 0) animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0) animations.add(animation);
    }
}
项目:amatsukaze    文件:SkeletonTest.java   
protected void switchAnimation () {
    for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
        int animIndex = 0;
        if (e.value.current != null) {
            for (int i = 0; i < e.key.animations.size; i++) {
                final Animation animation = e.key.animations.get(i);
                if (e.value.current.animation == animation) {
                    animIndex = i;
                    break;
                }
            }
        }
        animIndex = (animIndex + 1) % e.key.animations.size;
        e.value.animate(e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
    }
}
项目:amatsukaze    文件:ShaderCollectionTest.java   
protected void switchAnimation () {
    for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
        int animIndex = 0;
        if (e.value.current != null) {
            for (int i = 0; i < e.key.animations.size; i++) {
                final Animation animation = e.key.animations.get(i);
                if (e.value.current.animation == animation) {
                    animIndex = i;
                    break;
                }
            }
        }
        animIndex = (animIndex + 1) % e.key.animations.size;
        e.value.animate(e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
    }
}
项目:amatsukaze    文件:ModelTest.java   
protected void switchAnimation () {
    for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
        int animIndex = 0;
        if (e.value.current != null) {
            for (int i = 0; i < e.key.animations.size; i++) {
                final Animation animation = e.key.animations.get(i);
                if (e.value.current.animation == animation) {
                    animIndex = i;
                    break;
                }
            }
        }
        animIndex = (animIndex + 1) % (e.key.animations.size + 1);
        e.value.animate((animIndex == e.key.animations.size) ? null : e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
    }
}
项目:vtm    文件:SharedModel.java   
private void copyAnimations (final Iterable<Animation> source) {
    for (final Animation anim : source) {
        Animation animation = new Animation();
        animation.id = anim.id;
        animation.duration = anim.duration;
        for (final NodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.node.id);
            if (node == null)
                continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            for (final NodeKeyframe kf : nanim.keyframes) {
                NodeKeyframe keyframe = new NodeKeyframe();
                keyframe.keytime = kf.keytime;
                keyframe.rotation.set(kf.rotation);
                keyframe.scale.set(kf.scale);
                keyframe.translation.set(kf.translation);
                nodeAnim.keyframes.add(keyframe);
            }
            if (nodeAnim.keyframes.size > 0)
                animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0)
            animations.add(animation);
    }
}
项目:libgdxcn    文件:AnimationController.java   
private AnimationDesc obtain (final Animation anim, float offset, float duration, int loopCount, float speed,
    final AnimationListener listener) {
    if (anim == null) return null;
    final AnimationDesc result = animationPool.obtain();
    result.animation = anim;
    result.listener = listener;
    result.loopCount = loopCount;
    result.speed = speed;
    result.offset = offset;
    result.duration = duration < 0 ? (anim.duration - offset) : duration;
    result.time = speed < 0 ? result.duration : 0.f;
    return result;
}
项目:libgdxcn    文件:AnimationController.java   
private AnimationDesc obtain (final String id, float offset, float duration, int loopCount, float speed,
    final AnimationListener listener) {
    if (id == null) return null;
    final Animation anim = target.getAnimation(id);
    if (anim == null) throw new GdxRuntimeException("Unknown animation: " + id);
    return obtain(anim, offset, duration, loopCount, speed, listener);
}
项目:libgdxcn    文件:Model.java   
/** @param id The ID of the animation to fetch.
 * @param ignoreCase whether to use case sensitivity when comparing the animation id.
 * @return The {@link Animation} with the specified id, or null if not available. */
public Animation getAnimation (final String id, boolean ignoreCase) {
    final int n = animations.size;
    Animation animation;
    if (ignoreCase) {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equalsIgnoreCase(id)) return animation;
    } else {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equals(id)) return animation;
    }
    return null;
}
项目:libgdxcn    文件:ModelInstance.java   
private void copyAnimations (final Iterable<Animation> source, boolean shareKeyframes) {
    for (final Animation anim : source) {
        Animation animation = new Animation();
        animation.id = anim.id;
        animation.duration = anim.duration;
        for (final NodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.node.id);
            if (node == null) continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            if (shareKeyframes)
                nodeAnim.keyframes = nanim.keyframes;
            else {
                for (final NodeKeyframe kf : nanim.keyframes) {

                    NodeKeyframe keyframe = new NodeKeyframe();
                    keyframe.keytime = kf.keytime;
                    keyframe.rotation.set(kf.rotation);
                    keyframe.scale.set(kf.scale);
                    keyframe.translation.set(kf.translation);
                    nodeAnim.keyframes.add(keyframe);
                }
            }
            if (nodeAnim.keyframes.size > 0) animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0) animations.add(animation);
    }
}
项目:libgdxcn    文件:ModelInstance.java   
/** @param id The ID of the animation to fetch.
 * @param ignoreCase whether to use case sensitivity when comparing the animation id.
 * @return The {@link Animation} with the specified id, or null if not available. */
public Animation getAnimation (final String id, boolean ignoreCase) {
    final int n = animations.size;
    Animation animation;
    if (ignoreCase) {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equalsIgnoreCase(id)) return animation;
    } else {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equals(id)) return animation;
    }
    return null;
}
项目:HelixEngine    文件:ModelDisplayable.java   
public boolean animateIfAnimationExists(String id) {
  for (Animation animation : instance.animations) {
    if (animation.id.equalsIgnoreCase(id)) {
      animationController.setAnimation(id);

      return true;
    }
  }

  return false;
}
项目:bladecoder-adventure-engine    文件:Sprite3DRenderer.java   
@Override
public String[] getInternalAnimations(AnimationDesc anim) {
    retrieveSource(anim.source);

    Array<Animation> animations = ((ModelCacheEntry)sourceCache.get(anim.source)).modelInstance.animations;
    String[] result = new String[animations.size];

    for (int i = 0; i < animations.size; i++) {
        Animation a = animations.get(i);
        result[i] = a.id;
    }

    return result;
}
项目:gdx-proto    文件:HeadlessModel.java   
/** @param id The ID of the animation to fetch.
 * @param ignoreCase whether to use case sensitivity when comparing the animation id.
 * @return The {@link com.badlogic.gdx.graphics.g3d.model.Animation} with the specified id, or null if not available. */
public Animation getAnimation (final String id, boolean ignoreCase) {
    final int n = animations.size;
    Animation animation;
    if (ignoreCase) {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equalsIgnoreCase(id)) return animation;
    } else {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equals(id)) return animation;
    }
    return null;
}
项目:vtm    文件:SharedModel.java   
/** @param id The ID of the animation to fetch.
 * @param ignoreCase whether to use case sensitivity when comparing the animation id.
 * @return The {@link Animation} with the specified id, or null if not available. */
public Animation getAnimation(final String id, boolean ignoreCase) {
    final int n = animations.size;
    Animation animation;
    if (ignoreCase) {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equalsIgnoreCase(id))
                return animation;
    } else {
        for (int i = 0; i < n; i++)
            if ((animation = animations.get(i)).id.equals(id))
                return animation;
    }
    return null;
}
项目:libgdxcn    文件:BaseAnimationController.java   
/** Apply an animation, must be called between {{@link #begin()} and {{@link #end()}.
 * @param weight The blend weight of this animation relative to the previous applied animations. */
protected void apply (final Animation animation, final float time, final float weight) {
    if (!applying) throw new GdxRuntimeException("You must call begin() before adding an animation");
    applyAnimation(transforms, transformPool, weight, animation, time);
}
项目:libgdxcn    文件:BaseAnimationController.java   
/** Apply a single animation to the {@link ModelInstance} and update the it to reflect the changes. */
protected void applyAnimation (final Animation animation, final float time) {
    if (applying) throw new GdxRuntimeException("Call end() first");
    applyAnimation(null, null, 1.f, animation, time);
    target.calculateTransforms();
}
项目:libgdxcn    文件:BaseAnimationController.java   
/** Remove the specified animation, by marking the affected nodes as not animated. When switching animation, this should be call
 * prior to applyAnimation(s). */
protected void removeAnimation (final Animation animation) {
    for (final NodeAnimation nodeAnim : animation.nodeAnimations) {
        nodeAnim.node.isAnimated = false;
    }
}
项目:libgdxcn    文件:AnimationController.java   
/** Set the active animation, replacing any current animation. */
protected AnimationDesc setAnimation (final Animation anim, float offset, float duration, int loopCount, float speed,
    final AnimationListener listener) {
    return setAnimation(obtain(anim, offset, duration, loopCount, speed, listener));
}
项目:libgdxcn    文件:AnimationController.java   
/** Changes the current animation by blending the new on top of the old during the transition time. */
protected AnimationDesc animate (final Animation anim, float offset, float duration, int loopCount, float speed,
    final AnimationListener listener, float transitionTime) {
    return animate(obtain(anim, offset, duration, loopCount, speed, listener), transitionTime);
}
项目:libgdxcn    文件:AnimationController.java   
/** Queue an animation to be applied when the current is finished. If current is continuous it will be synced on next loop. */
protected AnimationDesc queue (final Animation anim, float offset, float duration, int loopCount, float speed,
    final AnimationListener listener, float transitionTime) {
    return queue(obtain(anim, offset, duration, loopCount, speed, listener), transitionTime);
}
项目:libgdxcn    文件:AnimationController.java   
/** Apply an action animation on top of the current animation. */
protected AnimationDesc action (final Animation anim, float offset, float duration, int loopCount, float speed,
    final AnimationListener listener, float transitionTime) {
    return action(obtain(anim, offset, duration, loopCount, speed, listener), transitionTime);
}
项目:libgdxcn    文件:Model.java   
/** @param id The ID of the animation to fetch (case sensitive).
 * @return The {@link Animation} with the specified id, or null if not available. */
public Animation getAnimation (final String id) {
    return getAnimation(id, true);
}
项目:libgdxcn    文件:ModelInstance.java   
/** @param id The ID of the animation to fetch (case sensitive).
 * @return The {@link Animation} with the specified id, or null if not available. */
public Animation getAnimation (final String id) {
    return getAnimation(id, true);
}
项目:gdx-proto    文件:HeadlessModel.java   
/** @param id The ID of the animation to fetch (case sensitive).
 * @return The {@link com.badlogic.gdx.graphics.g3d.model.Animation} with the specified id, or null if not available. */
public Animation getAnimation (final String id) {
    return getAnimation(id, true);
}
项目:vtm    文件:SharedModel.java   
/** @param id The ID of the animation to fetch (case sensitive).
 * @return The {@link Animation} with the specified id, or null if not available. */
public Animation getAnimation(final String id) {
    return getAnimation(id, true);
}