本文整理汇总了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;
}
示例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);
}
示例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 };
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}