@Test public void compressionTest() throws Exception { BufferedImage input = ImageIO.read(new File("C:\\Users\\flux\\Dropbox\\java\\VoxelShop\\Test Files\\Texture Compression\\sample25.png")); TIntObjectHashMap<int[]> pixels = new TIntObjectHashMap<int[]>(); for (int x = 0, width = input.getWidth(); x < width; x++) { for (int y = 0, height = input.getHeight(); y < height; y++) { int rgb = input.getRGB(x,y); if (((rgb >> 24) & 0xff) != 0) { pixels.put(IntegerTools.makeInt(x, y), new int[]{x, y, rgb}); } } } double[][] uvPoints = new double[][] { new double[] {1.0, 0.0} , new double[] {0.0, 1.0}, new double[] {0.8666666666666667, 0.0} }; int[] newSize = TriTexture.compress(input.getWidth(), input.getHeight(), pixels, uvPoints); System.out.println(input.getWidth() + " " + input.getHeight()); System.out.println(newSize[0] + " " + newSize[1]); int imgSize = 20; int zoom = 50; BufferedImage img = new BufferedImage(imgSize, imgSize, BufferedImage.TYPE_INT_ARGB); for (int[] p : pixels.valueCollection()) { if (p[0] > -1 && p[1] > -1 && p[0] < img.getWidth() && p[1] < img.getHeight()) { img.setRGB(p[0], p[1], p[2]); } } BufferedImage img2 = new BufferedImage(imgSize * zoom, imgSize * zoom, BufferedImage.TYPE_INT_ARGB); img2.getGraphics().drawImage(img.getScaledInstance(imgSize * zoom, imgSize * zoom, 0), 0, 0, null); Graphics2D g2 = (Graphics2D) img2.getGraphics(); g2.setColor(Color.WHITE); for (int[] p : pixels.valueCollection()) { g2.drawRect( (p[0])*zoom, (p[1])*zoom, zoom, zoom); } g2.setColor(Color.RED); g2.drawLine( (int) ((uvPoints[0][0] * newSize[0]) * zoom), (int) ((uvPoints[0][1] * newSize[1]) * zoom), (int) ((uvPoints[1][0] * newSize[0]) * zoom), (int) ((uvPoints[1][1] * newSize[1]) * zoom) ); g2.drawLine( (int) ((uvPoints[2][0] * newSize[0]) * zoom), (int) ((uvPoints[2][1] * newSize[1]) * zoom), (int) ((uvPoints[1][0] * newSize[0]) * zoom), (int) ((uvPoints[1][1] * newSize[1]) * zoom) ); g2.drawLine( (int) ((uvPoints[0][0] * newSize[0]) * zoom), (int) ((uvPoints[0][1] * newSize[1]) * zoom), (int) ((uvPoints[2][0] * newSize[0]) * zoom), (int) ((uvPoints[2][1] * newSize[1]) * zoom) ); try { ImageIO.write(img2, "png", new File("C:\\Users\\flux\\Dropbox\\java\\VoxelShop\\Test Files\\Texture Compression\\sample25_compressed.png")); } catch (IOException e) { e.printStackTrace(); } }
protected static int[] compress(int width, int height, TIntObjectHashMap<int[]> pixels, double[][] uvPoints) { int[] size = new int[] {width, height, 1}; size = TextureTools.compress(size[0], size[1], 0, size[0], false, pixels); size = TextureTools.compress(size[0], size[1], 0, size[1], true, pixels); int[] offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); if (offsetsX[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], size[0], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] > offsetsX[0]) { p[0] = ((p[0] - offsetsX[0]) / size[2]) + offsetsX[0]; } else { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[1]) { p[0] = p[0] / size[2]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[1] / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[0] > 0 || offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[0]) { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } else if (p[0] < offsetsX[1]) { p[0] = (p[0] - offsetsX[0]) / size[2] + offsetsX[0]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[0] + (offsetsX[1] - offsetsX[0]) / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); } } int[] offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); if (offsetsY[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], size[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] > offsetsY[0]) { p[1] = ((p[1] - offsetsY[0]) / size[2]) + offsetsY[0]; } else { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[1]) { p[1] = p[1] / size[2]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[1] / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[0] > 0 || offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[0]) { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } else if (p[1] < offsetsY[1]) { p[1] = (p[1] - offsetsY[0]) / size[2] + offsetsY[0]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[0] + (offsetsY[1] - offsetsY[0]) / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); } } return size; }
TriTexture { protected static int[] compress(int width, int height, TIntObjectHashMap<int[]> pixels, double[][] uvPoints) { int[] size = new int[] {width, height, 1}; size = TextureTools.compress(size[0], size[1], 0, size[0], false, pixels); size = TextureTools.compress(size[0], size[1], 0, size[1], true, pixels); int[] offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); if (offsetsX[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], size[0], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] > offsetsX[0]) { p[0] = ((p[0] - offsetsX[0]) / size[2]) + offsetsX[0]; } else { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[1]) { p[0] = p[0] / size[2]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[1] / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[0] > 0 || offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[0]) { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } else if (p[0] < offsetsX[1]) { p[0] = (p[0] - offsetsX[0]) / size[2] + offsetsX[0]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[0] + (offsetsX[1] - offsetsX[0]) / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); } } int[] offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); if (offsetsY[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], size[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] > offsetsY[0]) { p[1] = ((p[1] - offsetsY[0]) / size[2]) + offsetsY[0]; } else { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[1]) { p[1] = p[1] / size[2]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[1] / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[0] > 0 || offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[0]) { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } else if (p[1] < offsetsY[1]) { p[1] = (p[1] - offsetsY[0]) / size[2] + offsetsY[0]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[0] + (offsetsY[1] - offsetsY[0]) / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); } } return size; } }
TriTexture { protected static int[] compress(int width, int height, TIntObjectHashMap<int[]> pixels, double[][] uvPoints) { int[] size = new int[] {width, height, 1}; size = TextureTools.compress(size[0], size[1], 0, size[0], false, pixels); size = TextureTools.compress(size[0], size[1], 0, size[1], true, pixels); int[] offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); if (offsetsX[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], size[0], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] > offsetsX[0]) { p[0] = ((p[0] - offsetsX[0]) / size[2]) + offsetsX[0]; } else { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[1]) { p[0] = p[0] / size[2]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[1] / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[0] > 0 || offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[0]) { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } else if (p[0] < offsetsX[1]) { p[0] = (p[0] - offsetsX[0]) / size[2] + offsetsX[0]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[0] + (offsetsX[1] - offsetsX[0]) / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); } } int[] offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); if (offsetsY[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], size[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] > offsetsY[0]) { p[1] = ((p[1] - offsetsY[0]) / size[2]) + offsetsY[0]; } else { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[1]) { p[1] = p[1] / size[2]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[1] / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[0] > 0 || offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[0]) { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } else if (p[1] < offsetsY[1]) { p[1] = (p[1] - offsetsY[0]) / size[2] + offsetsY[0]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[0] + (offsetsY[1] - offsetsY[0]) / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); } } return size; } TriTexture(TriTexture tex, TriTextureManager textureManager);  TriTexture(ArrayList<TriTexture> textures, TickAction tickAction, TriTextureManager textureManager);  TriTexture(TriTexture one, TriTexture two, TriTextureManager textureManager);  TriTexture(
            TexTriUV uv1, int xf1, int yf1,
            TexTriUV uv2, int xf2, int yf2,
            TexTriUV uv3, int xf3, int yf3,
            final int side,
            int depth,
            boolean usePadding,
            TexTriangle texTri, final Data data,
            TriTextureManager textureManager,
            boolean exportTexturedVoxels,
            boolean useSkewedUvs
    ); }
TriTexture { protected static int[] compress(int width, int height, TIntObjectHashMap<int[]> pixels, double[][] uvPoints) { int[] size = new int[] {width, height, 1}; size = TextureTools.compress(size[0], size[1], 0, size[0], false, pixels); size = TextureTools.compress(size[0], size[1], 0, size[1], true, pixels); int[] offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); if (offsetsX[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], size[0], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] > offsetsX[0]) { p[0] = ((p[0] - offsetsX[0]) / size[2]) + offsetsX[0]; } else { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[1]) { p[0] = p[0] / size[2]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[1] / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[0] > 0 || offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[0]) { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } else if (p[0] < offsetsX[1]) { p[0] = (p[0] - offsetsX[0]) / size[2] + offsetsX[0]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[0] + (offsetsX[1] - offsetsX[0]) / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); } } int[] offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); if (offsetsY[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], size[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] > offsetsY[0]) { p[1] = ((p[1] - offsetsY[0]) / size[2]) + offsetsY[0]; } else { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[1]) { p[1] = p[1] / size[2]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[1] / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[0] > 0 || offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[0]) { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } else if (p[1] < offsetsY[1]) { p[1] = (p[1] - offsetsY[0]) / size[2] + offsetsY[0]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[0] + (offsetsY[1] - offsetsY[0]) / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); } } return size; } TriTexture(TriTexture tex, TriTextureManager textureManager);  TriTexture(ArrayList<TriTexture> textures, TickAction tickAction, TriTextureManager textureManager);  TriTexture(TriTexture one, TriTexture two, TriTextureManager textureManager);  TriTexture(
            TexTriUV uv1, int xf1, int yf1,
            TexTriUV uv2, int xf2, int yf2,
            TexTriUV uv3, int xf3, int yf3,
            final int side,
            int depth,
            boolean usePadding,
            TexTriangle texTri, final Data data,
            TriTextureManager textureManager,
            boolean exportTexturedVoxels,
            boolean useSkewedUvs
    ); final int getSampleRGB(); final void setParentTexture(TriTexture parentTexture, int[] leftTop, int orientationFlag); final int getId(); final int getPixelCount(); final int getArea(); final float jaccard(TriTexture other); final BufferedImage getImage(); final TriTexture getTopTexture(); final boolean hasValidUV(); final boolean hasParent(); final boolean makeChild(TriTexture child, int pos[]); @SuppressWarnings("SuspiciousNameCombination") final void validateUVMapping(); }
TriTexture { protected static int[] compress(int width, int height, TIntObjectHashMap<int[]> pixels, double[][] uvPoints) { int[] size = new int[] {width, height, 1}; size = TextureTools.compress(size[0], size[1], 0, size[0], false, pixels); size = TextureTools.compress(size[0], size[1], 0, size[1], true, pixels); int[] offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); if (offsetsX[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], size[0], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] > offsetsX[0]) { p[0] = ((p[0] - offsetsX[0]) / size[2]) + offsetsX[0]; } else { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[1]) { p[0] = p[0] / size[2]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[1] / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); offsetsX = TextureTools.getOffsets(size[0], size[1], false, pixels); } } if (offsetsX[0] > 0 || offsetsX[1] < size[0]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsX[0], offsetsX[1], false, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[0] *= oldSize[0]; if (p[0] < offsetsX[0]) { p[0] += (offsetsX[0] - p[0]) * (1 - 1d / size[2]); } else if (p[0] < offsetsX[1]) { p[0] = (p[0] - offsetsX[0]) / size[2] + offsetsX[0]; } else { p[0] = (p[0] - offsetsX[1]) * (1d / size[2]) + offsetsX[0] + (offsetsX[1] - offsetsX[0]) / size[2]; } p[0] /= size[0]; } size = repairPixel(size[0], size[1], pixels, uvPoints, false); } } int[] offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); if (offsetsY[0] > 0) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], size[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] > offsetsY[0]) { p[1] = ((p[1] - offsetsY[0]) / size[2]) + offsetsY[0]; } else { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], 0, offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[1]) { p[1] = p[1] / size[2]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[1] / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); offsetsY = TextureTools.getOffsets(size[0], size[1], true, pixels); } } if (offsetsY[0] > 0 || offsetsY[1] < size[1]) { int[] oldSize = new int[] {size[0], size[1]}; size = TextureTools.compress(size[0], size[1], offsetsY[0], offsetsY[1], true, pixels); if (size[2] > 1) { for (double[] p : uvPoints) { p[1] *= oldSize[1]; if (p[1] < offsetsY[0]) { p[1] += (offsetsY[0] - p[1]) * (1 - 1d / size[2]); } else if (p[1] < offsetsY[1]) { p[1] = (p[1] - offsetsY[0]) / size[2] + offsetsY[0]; } else { p[1] = (p[1] - offsetsY[1]) * (1d / size[2]) + offsetsY[0] + (offsetsY[1] - offsetsY[0]) / size[2]; } p[1] /= size[1]; } size = repairPixel(size[0], size[1], pixels, uvPoints, true); } } return size; } TriTexture(TriTexture tex, TriTextureManager textureManager);  TriTexture(ArrayList<TriTexture> textures, TickAction tickAction, TriTextureManager textureManager);  TriTexture(TriTexture one, TriTexture two, TriTextureManager textureManager);  TriTexture(
            TexTriUV uv1, int xf1, int yf1,
            TexTriUV uv2, int xf2, int yf2,
            TexTriUV uv3, int xf3, int yf3,
            final int side,
            int depth,
            boolean usePadding,
            TexTriangle texTri, final Data data,
            TriTextureManager textureManager,
            boolean exportTexturedVoxels,
            boolean useSkewedUvs
    ); final int getSampleRGB(); final void setParentTexture(TriTexture parentTexture, int[] leftTop, int orientationFlag); final int getId(); final int getPixelCount(); final int getArea(); final float jaccard(TriTexture other); final BufferedImage getImage(); final TriTexture getTopTexture(); final boolean hasValidUV(); final boolean hasParent(); final boolean makeChild(TriTexture child, int pos[]); @SuppressWarnings("SuspiciousNameCombination") final void validateUVMapping(); final int width; final int height; }