Esempio n. 1
0
  private void getMaterials(BufferedInputStream stream, byte[] bytes) throws IOException {
    ByteArrayInputStream ba =
        new ByteArrayInputStream(bytes, header.offsetSkins - 68, bytes.length - header.offsetSkins);
    LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);

    for (int i = 0; i < header.numSkins; i++) {
      String skinPath = is.readString(64);
      StringBuffer texture = new StringBuffer(packageID);
      texture.append(":drawable/");

      skinPath = skinPath.substring(skinPath.lastIndexOf("/") + 1, skinPath.length());
      StringBuffer textureName = new StringBuffer(skinPath.toLowerCase());
      int dotIndex = textureName.lastIndexOf(".");
      if (dotIndex > -1) texture.append(textureName.substring(0, dotIndex));
      else texture.append(textureName);

      currentTextureName = texture.toString();
      textureAtlas.addBitmapAsset(new BitmapAsset(currentTextureName, currentTextureName));
    }
  }
Esempio n. 2
0
  private void getFrames(BufferedInputStream stream, byte[] bytes) throws IOException {
    ByteArrayInputStream ba =
        new ByteArrayInputStream(
            bytes, header.offsetFrames - 68, bytes.length - header.offsetFrames);
    LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);
    ArrayList<Number3d> firstFrameVerts = new ArrayList<Number3d>();

    for (int i = 0; i < header.numFrames; i++) {
      float scaleX = is.readFloat();
      float scaleY = is.readFloat();
      float scaleZ = is.readFloat();
      float translateX = is.readFloat();
      float translateY = is.readFloat();
      float translateZ = is.readFloat();
      String name = is.readString(16);

      if (name.indexOf("_") > 0) name = name.subSequence(0, name.lastIndexOf("_")).toString();
      else name = name.substring(0, 6).replaceAll("[0-9]{1,2}$", "");

      Log.d(Min3d.TAG, "frame name: " + name);
      float vertices[] = new float[header.numVerts * 3];
      int index = 0;

      for (int j = 0; j < header.numVerts; j++) {
        vertices[index++] = scaleX * is.readUnsignedByte() + translateX;
        vertices[index++] = scaleY * is.readUnsignedByte() + translateY;
        vertices[index++] = scaleZ * is.readUnsignedByte() + translateZ;

        int normalIndex = is.readUnsignedByte();
        if (i == 0)
          co.vertices.add(
              new Number3d(vertices[index - 3], vertices[index - 2], vertices[index - 1]));
      }

      frames[i] = new KeyFrame(name, vertices);
    }
  }