コード例 #1
0
ファイル: BoneContext.java プロジェクト: btodorov88/IN4189
  /**
   * This method builds the bone. It recursively builds the bone's children.
   *
   * @param bones a list of bones where the newly created bone will be added
   * @param boneOMAs the map between bone and its old memory address
   * @param blenderContext the blender context
   * @return newly created bone
   */
  public Bone buildBone(List<Bone> bones, Map<Bone, Long> boneOMAs, BlenderContext blenderContext) {
    Long boneOMA = boneStructure.getOldMemoryAddress();
    bone = new Bone(boneName);
    bones.add(bone);
    boneOMAs.put(bone, boneOMA);
    blenderContext.addLoadedFeatures(boneOMA, boneName, boneStructure, bone);

    Matrix4f pose = this.restMatrix.clone();
    ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);

    Vector3f poseLocation = pose.toTranslationVector();
    Quaternion rotation = pose.toRotationQuat();
    Vector3f scale = objectHelper.getScale(pose);

    bone.setBindTransforms(poseLocation, rotation, scale);
    for (BoneContext child : children) {
      bone.addChild(child.buildBone(bones, boneOMAs, blenderContext));
    }

    this.computePoseTransform();

    return bone;
  }