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


Java BoneTrack.getTimes方法代码示例

本文整理汇总了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;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:AnimationUtils.java

示例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);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:36,代码来源:AnimationUtils.java


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