/**
   * 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);
  }
Exemple #2
0
 private static BoneTrack getFirstTrackForBone(Animation animation, int boneIndex) {
   BoneTrack result = null;
   for (Track track : animation.getTracks()) {
     if (track instanceof BoneTrack) {
       BoneTrack boneTrack = (BoneTrack) track;
       if (boneIndex == boneTrack.getTargetBoneIndex()) {
         return boneTrack;
       }
     }
   }
   return result;
 }
 /**
  * The method determines if the bone has animations.
  *
  * @param boneOMA OMA of the bone
  * @return <b>true</b> if the bone has animations and <b>false</b> otherwise
  */
 protected boolean hasAnimation(Long boneOMA) {
   AnimData animData = blenderContext.getAnimData(boneOMA);
   if (animData != null) {
     Bone bone = blenderContext.getBoneContext(boneOMA).getBone();
     int boneIndex = animData.skeleton.getBoneIndex(bone);
     for (Animation animation : animData.anims) {
       for (Track track : animation.getTracks()) {
         if (track instanceof BoneTrack && ((BoneTrack) track).getTargetBoneIndex() == boneIndex) {
           return true;
         }
       }
     }
   }
   return false;
 }