Exemplo n.º 1
0
  /**
   * The method applies bone's current position to all of the traces of the given animations.
   *
   * @param boneContext the bone context
   * @param space the bone's evaluation space
   * @param referenceAnimData the object containing the animations
   */
  protected void applyAnimData(BoneContext boneContext, Space space, AnimData referenceAnimData) {
    ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
    Transform transform = constraintHelper.getBoneTransform(space, boneContext.getBone());

    AnimData animData = blenderContext.getAnimData(boneContext.getBoneOma());

    for (Animation animation : referenceAnimData.anims) {
      BoneTrack parentTrack = (BoneTrack) animation.getTracks()[0];

      float[] times = parentTrack.getTimes();
      Vector3f[] translations = new Vector3f[times.length];
      Quaternion[] rotations = new Quaternion[times.length];
      Vector3f[] scales = new Vector3f[times.length];
      Arrays.fill(translations, transform.getTranslation());
      Arrays.fill(rotations, transform.getRotation());
      Arrays.fill(scales, transform.getScale());
      for (Animation anim : animData.anims) {
        anim.addTrack(
            new BoneTrack(
                animData.skeleton.getBoneIndex(boneContext.getBone()),
                times,
                translations,
                rotations,
                scales));
      }
    }
    blenderContext.setAnimData(boneContext.getBoneOma(), animData);
  }
 /** @return the arrays of time for this track */
 public float[] getTimes() {
   if (boneTrack != null) {
     return boneTrack.getTimes();
   }
   return spatialTrack.getTimes();
 }