Ejemplo n.º 1
0
  private static void linkTrianglesToBones(
      E3DActor actor, HashMap orphanedTriangleBoneAttachments) {
    ArrayList triangleList = actor.getTriangleList();
    E3DTriangle triangle = null;
    for (int i = 0; i < triangleList.size(); i++) {
      triangle = (E3DTriangle) triangleList.get(i);

      if (orphanedTriangleBoneAttachments.containsKey(triangle)) {
        VertexBoneInformation boneInfo =
            (VertexBoneInformation) orphanedTriangleBoneAttachments.get(triangle);
        E3DBone bone;

        for (int b = 0; b < 3; b++) {
          bone = actor.getSkeleton().findBoneByID(boneInfo.boneIDs[b]);
          if (bone != null) bone.attachVertex(triangle.getVertex(b));
          else
            actor
                .getEngine()
                .getLogger()
                .writeLine(
                    E3DEngineLogger.SEVERITY_WARNING,
                    "The bone: "
                        + E3DStringHelper.getNonNullableString(boneInfo.boneIDs[b])
                        + " could not be found in the actor thus vertices were not linked to it.");
        }
      }
    }
  }
Ejemplo n.º 2
0
  private static void linkOrphanedBonesToNewBone(
      E3DActor actor, E3DBone possibleParentBone, E3DHashListMap orphanedBones) {
    if (orphanedBones.containsKey(possibleParentBone.getBoneID())) {
      ArrayList boneList = (ArrayList) orphanedBones.get(possibleParentBone.getBoneID());
      for (int i = 0; i < boneList.size(); i++) {
        E3DBone childBone = (E3DBone) boneList.get(i);

        actor.getSkeleton().addBone(childBone, possibleParentBone.getBoneID());

        // Try to recursively link other orphans to the newly attached bones
        linkOrphanedBonesToNewBone(actor, childBone, orphanedBones);
      }

      // We had to have added all of these, so remove them
      orphanedBones.remove(possibleParentBone.getBoneID());
    }
  }