private void renderIcon(int par1, int par2, TextureAtlasSprite par3Icon, int par4, int par5, int brightness) { Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, ClientProxy.POSITION_TEX_LMAP); tessellator.getBuffer().pos(par1 + 0, par2 + par5, 0).tex(par3Icon.getMinU(), par3Icon.getMaxV()).lightmap(brightness, brightness).endVertex(); tessellator.getBuffer().pos(par1 + par4, par2 + par5, 0).tex(par3Icon.getMaxU(), par3Icon.getMaxV()).lightmap(brightness, brightness).endVertex(); tessellator.getBuffer().pos(par1 + par4, par2 + 0, 0).tex(par3Icon.getMaxU(), par3Icon.getMinV()).lightmap(brightness, brightness).endVertex(); tessellator.getBuffer().pos(par1 + 0, par2 + 0, 0).tex(par3Icon.getMinU(), par3Icon.getMinV()).lightmap(brightness, brightness).endVertex(); tessellator.draw(); }
uv.u1 = texture.getInterpolatedU( x1 * 16 ); uv.v1 = texture.getInterpolatedV( z1 * 16 ); uv.u2 = texture.getInterpolatedU( x2 * 16 ); uv.v2 = texture.getInterpolatedV( z2 * 16 ); break; case UP: uv.u1 = texture.getInterpolatedU( x1 * 16 ); uv.v1 = texture.getInterpolatedV( z1 * 16 ); uv.u2 = texture.getInterpolatedU( x2 * 16 ); uv.v2 = texture.getInterpolatedV( z2 * 16 ); break; case NORTH: uv.u1 = texture.getInterpolatedU( x1 * 16 ); uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); uv.u2 = texture.getInterpolatedU( x2 * 16 ); uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); break; case SOUTH: uv.u1 = texture.getInterpolatedU( x1 * 16 ); uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); uv.u2 = texture.getInterpolatedU( x2 * 16 ); uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); break; case WEST: uv.u1 = texture.getInterpolatedU( z1 * 16 ); uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 ); uv.u2 = texture.getInterpolatedU( z2 * 16 ); uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 ); break;
private void renderIcon(TextureAtlasSprite icon) { float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); }
/** Adds a quad to the rendering pipeline. Call startDrawingQuads beforehand. You need to call draw() yourself. */ static void putTiledTextureQuads(BufferBuilder renderer, int x, int y, int width, int height, float depth, TextureAtlasSprite sprite) { float u1 = sprite.getMinU(); float v1 = sprite.getMinV(); // tile vertically do { int renderHeight = Math.min(sprite.getIconHeight(), height); height -= renderHeight; float v2 = sprite.getInterpolatedV((16f * renderHeight) / (float) sprite.getIconHeight()); // we need to draw the quads per width too int x2 = x; int width2 = width; // tile horizontally do { int renderWidth = Math.min(sprite.getIconWidth(), width2); width2 -= renderWidth; float u2 = sprite.getInterpolatedU((16f * renderWidth) / (float) sprite.getIconWidth()); renderer.pos(x2, y, depth).tex(u1, v1).endVertex(); renderer.pos(x2, y + renderHeight, depth).tex(u1, v2).endVertex(); renderer.pos(x2 + renderWidth, y + renderHeight, depth).tex(u2, v2).endVertex(); renderer.pos(x2 + renderWidth, y, depth).tex(u2, v1).endVertex(); x2 += renderWidth; } while(width2 > 0); y += renderHeight; } while(height > 0); }
if (textureatlassprite.hasCustomLoader(resourceManager, resourcelocation)) { if (textureatlassprite.load(resourceManager, resourcelocation, l -> mapRegisteredSprites.get(l.toString()))) { continue; iresource = resourceManager.getResource(resourcelocation); boolean flag = iresource.getMetadata("animation") != null; textureatlassprite.loadSprite(pngsizeinfo, flag); } catch (RuntimeException runtimeexception) { FMLClientHandler.instance().trackBrokenTexture(resourcelocation, runtimeexception.getMessage()); this.missingImage.generateMipmaps(0); stitcher.addSprite(this.missingImage); bar = ProgressManager.push("Texture creation", 2); bar.step(textureatlassprite1.getIconName()); if (textureatlassprite1 == this.missingImage || this.generateMipmaps(resourceManager, textureatlassprite1)) { String s = textureatlassprite1.getIconName(); map.remove(s); this.mapUploadedSprites.put(s, textureatlassprite1); 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"); if (textureatlassprite1.hasAnimationMetadata()) { this.listAnimatedSprites.add(textureatlassprite1); textureatlassprite2.copyFrom(this.missingImage);
BoundingBox bb = new BoundingBox(pos).setMaxY(pos.getY() + (level / 15d)); float minU1 = tex1.getMinU(); float maxU1 = tex1.getInterpolatedU(8); float minV1 = tex1.getMinV(); float maxV1 = tex1.getInterpolatedV(8); for (Vertex v : bb.getCornersWithUvForFace(EnumFacing.DOWN, minU1, maxU1, minV1, maxV1)) { worldRendererIn.pos(v.x(), v.y(), v.z()).color(0.5F, 0.5F, 0.5F, 1.0F).tex(v.u(), v.v()).lightmap(240, 240).endVertex(); worldRendererIn.pos(v.x(), v.y(), v.z()).color(0.5F, 0.5F, 0.5F, 1.0F).tex(v.u(), v.v()).lightmap(240, 240).endVertex(); float minU = tex.getMinU(); float maxU = tex.getInterpolatedU(8); float minV = tex.getMinV(); float maxV = tex.getInterpolatedV(8); NNList.FACING_HORIZONTAL.apply(new Callback<EnumFacing>() { @Override
protected void drawCutIcon(BufferBuilder buffer, TextureAtlasSprite icon, int x, int y, int width, int height, int cut) { addVertexWithUV(buffer, x, y + height, zLevel, icon.getMinU(), icon.getInterpolatedV(height)); addVertexWithUV(buffer, x + width, y + height, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(height)); addVertexWithUV(buffer, x + width, y + cut, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(cut)); addVertexWithUV(buffer, x, y + cut, zLevel, icon.getMinU(), icon.getInterpolatedV(cut)); }
public LimitedTextureAtlasSprite(TextureAtlasSprite parent, Vector4f uv) { super(parent.getIconName()); copyFrom(parent); minU = super.getInterpolatedU(uv.x * 16); maxU = super.getInterpolatedU(uv.z * 16); minV = super.getInterpolatedV(uv.y * 16); maxV = super.getInterpolatedV(uv.w * 16); }
private static List<BakedQuad> transformQuads(List<BakedQuad> oldQuads, Set<String> textures) { List<BakedQuad> quads = new ArrayList<>(oldQuads); for (int i = 0; i < quads.size(); ++i) { BakedQuad quad = quads.get(i); if (textures.contains(quad.getSprite().getIconName())) { quads.set(i, transformQuad(quad, 0.007F)); } } return quads; }
public void addSprite(TextureAtlasSprite sprite) { Holder holder = new Holder(sprite, mipmapLevels); if (maxSpriteSize > 0) { holder.setNewDimension(maxSpriteSize); } Slot slot = allocateSlot(holder); if (slot == null) { throw new StitcherException(null, String.format("Unable to fit %s (size %dx%d)", sprite.getIconName(), sprite.getIconWidth(), sprite.getIconHeight())); } sprite.initSprite(BASE_WIDTH, BASE_HEIGHT, slot.getOriginX(), slot.getOriginY(), holder.isRotated()); }
@Override public double getInterpV(double v) { return sprite.getInterpolatedV(v * 16); } }
@Override public double getInterpU(double u) { return sprite.getInterpolatedU(u * 16); }
/** * @reason Replaces the updateAnimations method to only tick animated textures * that are in one of the loaded RenderChunks. This can lead to an FPS more than * three times higher on large modpacks with many textures. * <p> * Also breaks down the "root.tick.textures" profiler by texture name. */ @Overwrite public void updateAnimations() { // TODO: Recalculate list after chunk update instead! Minecraft.getMinecraft().profiler.startSection("determineVisibleTextures"); for (RenderGlobal.ContainerLocalRenderInformation renderInfo : Minecraft.getMinecraft().renderGlobal.renderInfos) { for (TextureAtlasSprite texture : ((IPatchedCompiledChunk) renderInfo.renderChunk.compiledChunk).getVisibleTextures()) { ((IPatchedTextureAtlasSprite) texture).markNeedsAnimationUpdate(); } } Minecraft.getMinecraft().profiler.endSection(); GlStateManager.bindTexture(getGlTextureId()); for (TextureAtlasSprite texture : listAnimatedSprites) { if (((IPatchedTextureAtlasSprite) texture).needsAnimationUpdate()) { Minecraft.getMinecraft().profiler.startSection(texture.getIconName()); texture.updateAnimation(); ((IPatchedTextureAtlasSprite) texture).unmarkNeedsAnimationUpdate(); // Can't do this from updateAnimation mixin, that method can be overriden Minecraft.getMinecraft().profiler.endSection(); } } } }
private static void renderGoldfish(EntityPlayer player) { GlStateManager.pushMatrix(); TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.goldfishIcon; float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); Helper.rotateIfSneaking(player); GlStateManager.rotate(180F, 0F, 0F, 1F); GlStateManager.rotate(90F, 0F, 1F, 0F); GlStateManager.scale(0.4F, 0.4F, 0.4F); GlStateManager.translate(-0.5F, 1.6F, 0F); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); GlStateManager.popMatrix(); }
if (textureatlassprite.hasCustomLoader(resourceManager, resourcelocation)) { if (textureatlassprite.load(resourceManager, resourcelocation, l -> mapRegisteredSprites.get(l.toString()))) { continue; iresource = resourceManager.getResource(resourcelocation); boolean flag = iresource.getMetadata("animation") != null; textureatlassprite.loadSprite(pngsizeinfo, flag); } catch (RuntimeException runtimeexception) { FMLClientHandler.instance().trackBrokenTexture(resourcelocation, runtimeexception.getMessage()); this.missingImage.generateMipmaps(0); stitcher.addSprite(this.missingImage); bar = ProgressManager.push("Texture creation", 2); bar.step(textureatlassprite1.getIconName()); if (textureatlassprite1 == this.missingImage || this.generateMipmaps(resourceManager, textureatlassprite1)) { String s = textureatlassprite1.getIconName(); map.remove(s); this.mapUploadedSprites.put(s, textureatlassprite1); 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"); if (textureatlassprite1.hasAnimationMetadata()) { this.listAnimatedSprites.add(textureatlassprite1); textureatlassprite2.copyFrom(this.missingImage);
private void drawCutIcon(TextureAtlasSprite icon, int x, int y, int width, int height, int cut) { Tessellator tess = Tessellator.getInstance(); BufferBuilder buffer = tess.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(x, y + height, zLevel).tex(icon.getMinU(), icon.getInterpolatedV(height)).endVertex(); buffer.pos(x + width, y + height, zLevel).tex(icon.getInterpolatedU(width), icon.getInterpolatedV(height)).endVertex(); buffer.pos(x + width, y + cut, zLevel).tex(icon.getInterpolatedU(width), icon.getInterpolatedV(cut)).endVertex(); buffer.pos(x, y + cut, zLevel).tex(icon.getMinU(), icon.getInterpolatedV(cut)).endVertex(); tess.draw(); } }