Package com.ardor3d.extension.animation.skeletal.clip

Examples of com.ardor3d.extension.animation.skeletal.clip.AnimationClipInstance


     * @param clip
     *            the clip to instance.
     * @return our new clip instance.
     */
    public AnimationClipInstance getClipInstance(final AnimationClip clip) {
        AnimationClipInstance instance = _clipInstances.get(clip);
        if (instance == null) {
            instance = new AnimationClipInstance();
            instance.setStartTime(_globalTimer.getTimeInSeconds());
            _clipInstances.put(clip, instance);
        }

        return instance;
    }
View Full Code Here


     *            the clip to pull the instance for.
     * @param globalStartTime
     *            the time to set the clip instance's start as.
     */
    public void resetClipInstance(final AnimationClip clip, final double globalStartTime) {
        final AnimationClipInstance instance = getClipInstance(clip);
        if (instance != null) {
            instance.setStartTime(globalStartTime);
            instance.setActive(true);
        }
    }
View Full Code Here

    /**
     * Sets the current time on our AnimationClip instance, accounting for looping and time scaling.
     */
    public boolean setTime(final double globalTime, final AnimationManager manager) {
        final AnimationClipInstance instance = manager.getClipInstance(_clip);
        if (instance.isActive()) {
            double clockTime = instance.getTimeScale() * (globalTime - instance.getStartTime());

            final double maxTime = _clip.getMaxTimeIndex();
            if (maxTime <= 0) {
                return false;
            }

            // Check for looping.
            if (instance.getLoopCount() == Integer.MAX_VALUE || instance.getLoopCount() > 1
                    && maxTime * instance.getLoopCount() >= Math.abs(clockTime)) {
                if (clockTime < 0) {
                    clockTime = maxTime + clockTime % maxTime;
                } else {
                    clockTime %= maxTime;
                }
            } else if (clockTime < 0) {
                clockTime = maxTime + clockTime;
            }

            // Check for past max time
            if (clockTime > maxTime || clockTime < 0) {
                clockTime = MathUtils.clamp(clockTime, 0, maxTime);
                // signal to any listeners that we have ended our animation.
                instance.fireAnimationFinished();
                // deactivate this instance of the clip
                instance.setActive(false);
            }

            // update the clip with the correct clip local time.
            _clip.update(clockTime, instance);
        }
        return instance.isActive();
    }
View Full Code Here

        manager.resetClipInstance(_clip, globalStartTime);
    }

    @Override
    public boolean isActive(final AnimationManager manager) {
        final AnimationClipInstance instance = manager.getClipInstance(_clip);
        return instance.isActive() && _clip.getMaxTimeIndex() > 0;
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.extension.animation.skeletal.clip.AnimationClipInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.