private void getTriangles(BufferedInputStream stream, byte[] bytes) throws IOException { ByteArrayInputStream ba = new ByteArrayInputStream( bytes, header.offsetTriangles - 68, bytes.length - header.offsetTriangles); LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba); int[] indices = new int[header.numTriangles * 3]; int index = 0; for (int i = 0; i < header.numTriangles; i++) { int[] vertexIDs = new int[3]; int[] uvIDS = new int[3]; indices[index + 2] = vertexIDs[2] = is.readUnsignedShort(); indices[index + 1] = vertexIDs[1] = is.readUnsignedShort(); indices[index] = vertexIDs[0] = is.readUnsignedShort(); index += 3; uvIDS[2] = is.readUnsignedShort(); uvIDS[1] = is.readUnsignedShort(); uvIDS[0] = is.readUnsignedShort(); ParseObjectFace f = new ParseObjectFace(); f.v = vertexIDs; f.uv = uvIDS; f.hasn = f.hasuv = true; f.faceLength = 3; f.materialKey = currentTextureName; co.numFaces++; co.faces.add(f); co.calculateFaceNormal(f); } for (int j = 0; j < header.numFrames; j++) { frames[j].setIndices(indices); } }