@Nullable private static BufferedImage getBufferedImage(TextureAtlasSprite textureAtlasSprite) { final int iconWidth = textureAtlasSprite.getIconWidth(); final int iconHeight = textureAtlasSprite.getIconHeight(); final int frameCount = textureAtlasSprite.getFrameCount(); if (iconWidth <= 0 || iconHeight <= 0 || frameCount <= 0) { return null; } BufferedImage bufferedImage = new BufferedImage(iconWidth, iconHeight * frameCount, BufferedImage.TYPE_4BYTE_ABGR); for (int i = 0; i < frameCount; i++) { int[][] frameTextureData = textureAtlasSprite.getFrameTextureData(i); int[] largestMipMapTextureData = frameTextureData[0]; bufferedImage.setRGB(0, i * iconHeight, iconWidth, iconHeight, largestMipMapTextureData, 0, iconWidth); } return bufferedImage; }
int[][] quadData = bakedQuad.getSprite().getFrameTextureData(i); for (int[] aQuadData : quadData) { for (int anAQuadData : aQuadData) {
private boolean hasTransparency(TabulaCubeContainer cube, TextureAtlasSprite sprite) { int textureWidth = this.model.getTextureWidth(); int textureHeight = this.model.getTextureHeight(); int width = sprite.getIconWidth(); int height = sprite.getIconHeight(); int frameCount = sprite.getFrameCount(); if (frameCount > 0) { for (int i = 0; i < frameCount; i++) { int[] pixels = sprite.getFrameTextureData(i)[0]; int[] textureOffset = cube.getTextureOffset(); int[] dimensions = cube.getDimensions(); int textureX = (textureOffset[0] * width) / textureWidth; int textureY = (textureOffset[1] * height) / textureHeight; int dimensionX = (dimensions[0] * width) / textureWidth; int dimensionY = (dimensions[1] * height) / textureHeight; int dimensionZ = (dimensions[2] * width) / textureWidth; boolean hasTransparencyTop = this.hasTransparency(pixels, textureX + dimensionZ, textureY, dimensionX * 2, dimensionZ, width, height); boolean hasTransparencyBottom = this.hasTransparency(pixels, textureX, textureY + dimensionZ, (dimensionX + dimensionZ) * 2, dimensionY, width, height); if (hasTransparencyTop || hasTransparencyBottom) { return true; } } } return false; }
private boolean hasTransparency(TabulaCubeContainer cube, TextureAtlasSprite sprite) { int textureWidth = this.model.getTextureWidth(); int textureHeight = this.model.getTextureHeight(); int width = sprite.getIconWidth(); int height = sprite.getIconHeight(); int frameCount = sprite.getFrameCount(); if (frameCount > 0) { for (int i = 0; i < frameCount; i++) { int[] pixels = sprite.getFrameTextureData(i)[0]; int[] textureOffset = cube.getTextureOffset(); int[] dimensions = cube.getDimensions(); int textureX = (textureOffset[0] * width) / textureWidth; int textureY = (textureOffset[1] * height) / textureHeight; int dimensionX = (dimensions[0] * width) / textureWidth; int dimensionY = (dimensions[1] * height) / textureHeight; int dimensionZ = (dimensions[2] * width) / textureWidth; boolean hasTransparencyTop = this.hasTransparency(pixels, textureX + dimensionZ, textureY, dimensionX * 2, dimensionZ, width, height); boolean hasTransparencyBottom = this.hasTransparency(pixels, textureX, textureY + dimensionZ, (dimensionX + dimensionZ) * 2, dimensionY, width, height); if (hasTransparencyTop || hasTransparencyBottom) { return true; } } } return false; }
TextureUtil.uploadTextureMipmap(loadedSprite.getFrameTextureData(0), loadedSprite.getIconWidth(), loadedSprite.getIconHeight(), loadedSprite.getOriginX(), loadedSprite.getOriginY(), false, false); for (TextureAtlasSprite sprite : spritesNeedingUpload) { spritesNeedingUpload.remove(sprite); TextureUtil.uploadTextureMipmap(sprite.getFrameTextureData(0), sprite.getIconWidth(), sprite.getIconHeight(), sprite.getOriginX(), sprite.getOriginY(), false, false);
TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");