本文整理汇总了Java中com.jme3.animation.BoneTrack.getTimes方法的典型用法代码示例。如果您正苦于以下问题:Java BoneTrack.getTimes方法的具体用法?Java BoneTrack.getTimes怎么用?Java BoneTrack.getTimes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.animation.BoneTrack
的用法示例。
在下文中一共展示了BoneTrack.getTimes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractAnimation
import com.jme3.animation.BoneTrack; //导入方法依赖的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: extractBoneTrack
import com.jme3.animation.BoneTrack; //导入方法依赖的package包/类
/**
* Extract a bone track from a source animation to sub animation.
*
* @param boneTrack the source bone track.
* @param startFrame the start frame.
* @param endFrame the end frame.
* @return the extracted bone track.
*/
@NotNull
private static BoneTrack extractBoneTrack(@NotNull final BoneTrack boneTrack, final int startFrame,
final int endFrame) {
final float[] sourceTimes = boneTrack.getTimes();
final Vector3f[] newTranslations = new Vector3f[endFrame - startFrame];
final Quaternion[] newRotations = new Quaternion[endFrame - startFrame];
final Vector3f[] newScales = new Vector3f[endFrame - startFrame];
final float[] newTimes = new float[endFrame - startFrame];
for (int i = startFrame; i < endFrame; i++) {
final int newFrame = i - startFrame;
final Vector3f sourceTranslation = boneTrack.getTranslations()[i];
final Vector3f sourceScale = boneTrack.getScales()[i];
final Quaternion sourceRotation = boneTrack.getRotations()[i];
newTimes[newFrame] = sourceTimes[i] - sourceTimes[startFrame];
newTranslations[newFrame] = sourceTranslation.clone();
newRotations[newFrame] = sourceRotation.clone();
newScales[newFrame] = sourceScale.clone();
}
return new BoneTrack(boneTrack.getTargetBoneIndex(), newTimes, newTranslations, newRotations, newScales);
}