예제 #1
0
  /**
   * This method reads mesh indexes
   *
   * @param objectStructure structure of the object that has the armature modifier applied
   * @param meshStructure the structure of the object's mesh
   * @param blenderContext the blender context
   * @throws BlenderFileException this exception is thrown when the blend file structure is somehow
   *     invalid or corrupted
   */
  private void readVerticesWeightsData(
      Structure objectStructure, Structure meshStructure, BlenderContext blenderContext)
      throws BlenderFileException {
    ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
    Structure defBase = (Structure) objectStructure.getFieldValue("defbase");
    Map<Integer, Integer> groupToBoneIndexMap =
        armatureHelper.getGroupToBoneIndexMap(defBase, blenderContext);

    int[] bonesGroups = new int[] {0};
    MeshContext meshContext = blenderContext.getMeshContext(meshStructure.getOldMemoryAddress());

    VertexBuffer[] boneWeightsAndIndex =
        this.getBoneWeightAndIndexBuffer(
            meshStructure,
            meshContext.getVertexList().size(),
            bonesGroups,
            meshContext.getVertexReferenceMap(),
            groupToBoneIndexMap,
            blenderContext);
    this.verticesWeights = boneWeightsAndIndex[0];
    this.verticesWeightsIndices = boneWeightsAndIndex[1];
    this.boneGroups = bonesGroups[0];
  }