Search in sources :

Example 6 with Animation

use of com.badlogic.gdx.graphics.g3d.model.Animation in project libgdx by libgdx.

the class SkeletonTest method switchAnimation.

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);
    }
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ObjectMap(com.badlogic.gdx.utils.ObjectMap) AnimationController(com.badlogic.gdx.graphics.g3d.utils.AnimationController) Animation(com.badlogic.gdx.graphics.g3d.model.Animation)

Example 7 with Animation

use of com.badlogic.gdx.graphics.g3d.model.Animation in project libgdx by libgdx.

the class ModelInstance method getAnimation.

/** @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;
}
Also used : Animation(com.badlogic.gdx.graphics.g3d.model.Animation) NodeAnimation(com.badlogic.gdx.graphics.g3d.model.NodeAnimation)

Example 8 with Animation

use of com.badlogic.gdx.graphics.g3d.model.Animation in project libgdx by libgdx.

the class ModelTest method switchAnimation.

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);
    }
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ObjectMap(com.badlogic.gdx.utils.ObjectMap) AnimationController(com.badlogic.gdx.graphics.g3d.utils.AnimationController) Animation(com.badlogic.gdx.graphics.g3d.model.Animation)

Aggregations

Animation (com.badlogic.gdx.graphics.g3d.model.Animation)8 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)4 NodeAnimation (com.badlogic.gdx.graphics.g3d.model.NodeAnimation)4 AnimationController (com.badlogic.gdx.graphics.g3d.utils.AnimationController)4 ObjectMap (com.badlogic.gdx.utils.ObjectMap)3 Node (com.badlogic.gdx.graphics.g3d.model.Node)2 NodeKeyframe (com.badlogic.gdx.graphics.g3d.model.NodeKeyframe)2 ModelAnimation (com.badlogic.gdx.graphics.g3d.model.data.ModelAnimation)2 ModelNodeAnimation (com.badlogic.gdx.graphics.g3d.model.data.ModelNodeAnimation)2 Quaternion (com.badlogic.gdx.math.Quaternion)2 Vector3 (com.badlogic.gdx.math.Vector3)2 Model (com.badlogic.gdx.graphics.g3d.Model)1 BlendingAttribute (com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute)1 ModelNode (com.badlogic.gdx.graphics.g3d.model.data.ModelNode)1 ModelNodeKeyframe (com.badlogic.gdx.graphics.g3d.model.data.ModelNodeKeyframe)1 BoundingBox (com.badlogic.gdx.math.collision.BoundingBox)1