当前位置: 首页>>代码示例>>Java>>正文


Java Animation.getTracks方法代码示例

本文整理汇总了Java中com.jme3.animation.Animation.getTracks方法的典型用法代码示例。如果您正苦于以下问题:Java Animation.getTracks方法的具体用法?Java Animation.getTracks怎么用?Java Animation.getTracks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.animation.Animation的用法示例。


在下文中一共展示了Animation.getTracks方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractAnimation

import com.jme3.animation.Animation; //导入方法依赖的package包/类
/**
 * Extract an animation from a source animation.
 *
 * @param source     the source animation.
 * @param newName    the new name of a sub animation.
 * @param startFrame the start frame.
 * @param endFrame   the end frame.
 * @return the new sub animation.
 */
@NotNull
@FromAnyThread
public static Animation extractAnimation(@NotNull final Animation source, @NotNull final String newName,
                                         final int startFrame, final int endFrame) {

    final Track[] sourceTracks = source.getTracks();
    final BoneTrack firstSourceTrack = (BoneTrack) sourceTracks[0];
    final float[] sourceTimes = firstSourceTrack.getTimes();

    final float newLength = (source.getLength() / (float) sourceTimes.length) * (float) (endFrame - startFrame);
    final Animation result = new Animation(newName, newLength);
    final Array<Track> newTracks = ArrayFactory.newArray(Track.class);

    for (final Track sourceTrack : sourceTracks) {
        if (sourceTrack instanceof BoneTrack) {
            newTracks.add(extractBoneTrack((BoneTrack) sourceTrack, startFrame, endFrame));
        }
    }

    result.setTracks(newTracks.toArray(Track.class));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:AnimationUtils.java

示例2: exploreSpatial

import com.jme3.animation.Animation; //导入方法依赖的package包/类
void exploreSpatial(Spatial s) {
	AnimControl ac = s.getControl(AnimControl.class);
	if (ac != null) {
		TreeItem<Object> itemL1 = new TreeItem<>();
		itemL1.setValue(s);
		rootItem.getChildren().add(itemL1);
		for(String aname : ac.getAnimationNames()) {
			TreeItem<Object> animItem = new TreeItem<>();
			Animation anim = ac.getAnim(aname);
			animItem.setValue(anim);
			itemL1.getChildren().add(animItem);
			for(Track t : anim.getTracks()) {
				TreeItem<Object> trackItem = new TreeItem<>();
				trackItem.setValue(t);
				animItem.getChildren().add(trackItem);
			}
		}
	}
	rootItem.setExpanded(true);
}
 
开发者ID:davidB,项目名称:jme3_ext_spatial_explorer,代码行数:21,代码来源:AnimationExplorer.java

示例3: computeAnimationTimeBoundaries

import com.jme3.animation.Animation; //导入方法依赖的package包/类
/**
 * 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.MIN_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 };
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:25,代码来源:SimulationNode.java

示例4: hasChildren

import com.jme3.animation.Animation; //导入方法依赖的package包/类
@Override
@FXThread
public boolean hasChildren(@NotNull final NodeTree<?> nodeTree) {

    final Animation element = getElement();
    final Track[] tracks = element.getTracks();

    return tracks != null && tracks.length > 0 && nodeTree instanceof ModelNodeTree;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:10,代码来源:AnimationTreeNode.java

示例5: getChildren

import com.jme3.animation.Animation; //导入方法依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final Animation element = getElement();
    final Track[] tracks = element.getTracks();

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class, tracks.length);
    ArrayUtils.forEach(tracks, track -> result.add(FACTORY_REGISTRY.createFor(track)));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:AnimationTreeNode.java

示例6: getFrameCount

import com.jme3.animation.Animation; //导入方法依赖的package包/类
/**
 * Get frame count of an animation/
 *
 * @param animation the animation.
 * @return the frame count or -1.
 */
@FromAnyThread
public static int getFrameCount(@NotNull final Animation animation) {

    int min = Integer.MAX_VALUE;

    final Track[] tracks = animation.getTracks();
    for (final Track track : tracks) {
        if (track instanceof BoneTrack) {
            min = Math.min(min, ((BoneTrack) track).getTimes().length);
        }
    }

    return min == Integer.MAX_VALUE ? -1 : min;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:AnimationUtils.java

示例7: setAnimation

import com.jme3.animation.Animation; //导入方法依赖的package包/类
public void setAnimation(Animation animation) {
    _animation = animation;
    _txtStartFrame.setValue(0);
    if (animation.getTracks().length <= 0) {
        throw new IllegalArgumentException("No Tracks found");
    }
    if (animation.getTracks()[0].getClass() != BoneTrack.class) {
        throw new UnsupportedOperationException("Only Bonetracks are supported");
    }

    _txtEndFrame.setValue(((BoneTrack) animation.getTracks()[0]).getTimes().length);
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:13,代码来源:ExtractSubAnimationDialog.java


注:本文中的com.jme3.animation.Animation.getTracks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。