private void renderGaugeOnFace( GaugeBounds gb, Icon icon, List<Vertex> vertices, double x, double y, double z) { Tessellator tes = Tessellator.instance; Vector2f u = gb.getMinMaxU(icon); List<Vertex> corners = gb.bb.getCornersWithUvForFace(gb.face, u.x, u.y, icon.getMinV(), icon.getMaxV()); for (Vertex coord : corners) { coord.xyz.add(ForgeDirectionOffsets.offsetScaled(gb.face, 0.001f)); Vector3d xyz = new Vector3d(coord.xyz); xyz.x += x; xyz.y += y; xyz.z += z; Vertex v = getClosestVertex(vertices, xyz); if (v != null) { if (v.color != null) { tes.setColorRGBA_F(v.color.x, v.color.y, v.color.z, v.color.w); } if (v.brightness > 0) { tes.setBrightness(v.brightness); } } if (coord.uv != null) { tes.addVertexWithUV(coord.x(), coord.y(), coord.z(), coord.u(), coord.v()); } else { tes.addVertexWithUV(coord.x(), coord.y(), coord.z(), 0, 0); } } }
private void renderFillBarOnFace( GaugeBounds gb, Icon icon, float filledRatio, List<Vertex> vertices, double x, double y, double z) { int totalPixels; if (gb.vInfo.verticalHeight == 1) { totalPixels = VPos.SINGLE_BLOCK.numFillPixels; } else { totalPixels = VPos.BOTTOM.numFillPixels + VPos.TOP.numFillPixels + (VPos.MIDDLE.numFillPixels * (gb.vInfo.verticalHeight - 2)); } int targetPixelCount = Math.max(0, Math.round(totalPixels * filledRatio)); int pixelsBellowFace; if (gb.vInfo.index < 2) { // either none or a bottom section pixelsBellowFace = gb.vInfo.index * VPos.BOTTOM.numFillPixels; } else { // has middle section pixelsBellowFace = VPos.BOTTOM.numFillPixels + (VPos.MIDDLE.numFillPixels * (gb.vInfo.index - 1)); } if (pixelsBellowFace >= targetPixelCount) { return; } VPos yPos = gb.vInfo.pos; int numPixelsLeft = targetPixelCount - pixelsBellowFace; int fillPixels = Math.min(numPixelsLeft, yPos.numFillPixels); double maxY = (yPos.fillOffset * PIXEL_SIZE) + (fillPixels * PIXEL_SIZE); float vWidth = icon.getMaxV() - icon.getMinV(); float maxV = icon.getMinV() + ((float) maxY * vWidth); Tessellator tes = Tessellator.instance; Vector2f u = gb.getMinMaxU(icon); List<crazypants.vecmath.Vertex> corners = gb.bb.getCornersWithUvForFace(gb.face, u.x, u.y, icon.getMinV(), maxV); for (Vertex coord : corners) { coord.xyz.add(ForgeDirectionOffsets.offsetScaled(gb.face, 0.002f)); Vector3d xyz = new Vector3d(coord.xyz); xyz.x += x; xyz.y += y; xyz.z += z; Vertex v = getClosestVertex(vertices, xyz); if (v != null) { if (v.color != null) { tes.setColorRGBA_F(v.color.x, v.color.y, v.color.z, v.color.w); } if (v.brightness > 0) { tes.setBrightness(v.brightness); } } if (coord.uv != null) { tes.addVertexWithUV( coord.x(), Math.min(coord.y(), maxY), coord.z(), coord.u(), coord.v()); } else { tes.addVertexWithUV(coord.x(), Math.min(coord.y(), maxY), coord.z(), 0, 0); } } }