@Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator tes = Tessellator.instance; IIcon icon = renderer.hasOverrideBlockTexture() ? renderer.overrideBlockTexture : block.getIcon(0, 0); tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tes.setColorOpaque_F(1, 1, 1); tes.addTranslation(x, y, z + 1); for (GroupObject go : model.groupObjects) { for (Face f : go.faces) { Vertex n = f.faceNormal; tes.setNormal(n.x, n.y, n.z); for (int i = 0; i < f.vertices.length; i++) { Vertex vert = f.vertices[i]; TextureCoordinate t = f.textureCoordinates[i]; if (!renderer.hasOverrideBlockTexture()) { tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16)); } else { tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU((t.u * 64) % 16), icon.getInterpolatedV((t.v * 64) % 16)); } } } } tes.addTranslation(-x, -y, -z - 1); return true; }
private static ForgeDirection getNormalFor(Vertex n) { if (n.x != 0) { return n.x > 0 ? ForgeDirection.EAST : ForgeDirection.WEST; } else if (n.y != 0) { return n.y > 0 ? ForgeDirection.UP : ForgeDirection.DOWN; } else { return n.z > 0 ? ForgeDirection.SOUTH : ForgeDirection.NORTH; } }
private void renderFire(TileClayOven te, BlockClayOven oven, CWTFCRenderer myRenderer, int meta) { float slope = 0.1F; for(int i = 0; i < 4; i++) { if(te.getStackInSlot(i) != null) slope += 0.05f; } if(te.getFireState()) myRenderer.icon = oven.getOvenIcon("OvenFireOn"); else myRenderer.icon = oven.getOvenIcon("OvenFireOff"); if(meta == 0) { myRenderer.renderQuadZNeg(new Vertex(0.9F, slope, 0.5F), new Vertex(0.1F, slope, 0.5F), new Vertex(0.9F, 0.1F, 0.9F), new Vertex(0.1F, 0.1F, 0.9F)); } else if(meta == 1) { myRenderer.renderQuadXPos(new Vertex(0.5F, 0.1F, 0.1F), new Vertex(0.5F, 0.1F, 0.9F), new Vertex(0.1F, slope, 0.1F), new Vertex(0.1F, slope, 0.9F)); } else if(meta == 2) { myRenderer.renderQuadZPos(new Vertex(0.9F, 0.1F, 0.5F), new Vertex(0.1F, 0.1F, 0.5F), new Vertex(0.9F, slope, 0.1F), new Vertex(0.1F, slope, 0.1F)); } else if(meta == 3) { myRenderer.renderQuadXNeg(new Vertex(0.5F, 0.1F, 0.9F), new Vertex(0.5F, 0.1F, 0.1F), new Vertex(0.9F, slope, 0.9F), new Vertex(0.9F, slope, 0.1F)); } }
public void renderQuadYNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { renderFaceYNeg(new Vertex(x + bottomRight.x, y + bottomRight.y, z + bottomRight.z), new Vertex(x + bottomLeft.x, y + bottomLeft.y, z + bottomLeft.z), new Vertex(x + topRight.x, y + topRight.y, z + topRight.z), new Vertex(x + topLeft.x, y + topLeft.y, z + topLeft.z), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderSquareYNeg(double xmin, double xmax, double ymin, double zmin, double zmax, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { float xMin = x + (float)xmin; float xMax = x + (float)xmax; float yMin = y + (float)ymin; float zMin = z + (float)zmin; float zMax = z + (float)zmax; renderFaceYNeg(new Vertex(xMin, yMin, zMin), new Vertex(xMax, yMin, zMin), new Vertex(xMin, yMin, zMax), new Vertex(xMax, yMin, zMax), umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadYPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { renderFaceYPos(new Vertex(x + bottomRight.x, y + bottomRight.y, z + bottomRight.z), new Vertex(x + bottomLeft.x, y + bottomLeft.y, z + bottomLeft.z), new Vertex(x + topRight.x, y + topRight.y, z + topRight.z), new Vertex(x + topLeft.x, y + topLeft.y, z + topLeft.z), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderSquareYPos(double xmin, double xmax, double ymax, double zmin, double zmax, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { double xMin = x + xmin; double xMax = x + xmax; double yMax = y + ymax; double zMin = z + zmin; double zMax = z + zmax; renderFaceYPos(new Vertex((float)xMin, (float)yMax, (float)zMin), new Vertex((float)xMax, (float)yMax, (float)zMin), new Vertex((float)xMin, (float)yMax, (float)zMax), new Vertex((float)xMax, (float)yMax, (float)zMax), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderQuadZNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { renderFaceZNeg(new Vertex(x + bottomRight.x, y + bottomRight.y, z + bottomRight.z), new Vertex(x + bottomLeft.x, y + bottomLeft.y, z + bottomLeft.z), new Vertex(x + topRight.x, y + topRight.y, z + topRight.z), new Vertex(x + topLeft.x, y + topLeft.y, z + topLeft.z), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderSquareZNeg(double xmin, double xmax, double ymin, double ymax, double zmin, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { double xMin = x + xmin; double xMax = x + xmax; double yMin = y + ymin; double yMax = y + ymax; double zMin = z + zmin; renderFaceZNeg(new Vertex((float)xMin, (float)yMin, (float)zMin), new Vertex((float)xMax, (float)yMin, (float)zMin), new Vertex((float)xMin, (float)yMax, (float)zMin), new Vertex((float)xMax, (float)yMax, (float)zMin), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderQuadZPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { renderFaceZPos(new Vertex(x + bottomRight.x, y + bottomRight.y, z + bottomRight.z), new Vertex(x + bottomLeft.x, y + bottomLeft.y, z + bottomLeft.z), new Vertex(x + topRight.x, y + topRight.y, z + topRight.z), new Vertex(x + topLeft.x, y + topLeft.y, z + topLeft.z), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderSquareZPos(double xmin, double xmax, double ymin, double ymax, double zmax, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { double xMin = x + xmin; double xMax = x + xmax; double yMin = y + ymin; double yMax = y + ymax; double zMax = z + zmax; renderFaceZPos(new Vertex((float)xMax, (float)yMin, (float)zMax), new Vertex((float)xMin, (float)yMin, (float)zMax), new Vertex((float)xMax, (float)yMax, (float)zMax), new Vertex((float)xMin, (float)yMax, (float)zMax), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderQuadXNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { renderFaceXNeg(new Vertex(x + bottomRight.x, y + bottomRight.y, z + bottomRight.z), new Vertex(x + bottomLeft.x, y + bottomLeft.y, z + bottomLeft.z), new Vertex(x + topRight.x, y + topRight.y, z + topRight.z), new Vertex(x + topLeft.x, y + topLeft.y, z + topLeft.z), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderSquareXNeg(double xmin, double ymin, double ymax, double zmin, double zmax, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { double xMin = x + xmin; double yMin = y + ymin; double yMax = y + ymax; double zMin = z + zmin; double zMax = z + zmax; renderFaceXNeg(new Vertex((float)xMin, (float)yMin, (float)zMax), new Vertex((float)xMin, (float)yMin, (float)zMin), new Vertex((float)xMin, (float)yMax, (float)zMax), new Vertex((float)xMin, (float)yMax, (float)zMin), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderQuadXPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { renderFaceXPos(new Vertex(x + bottomRight.x, y + bottomRight.y, z + bottomRight.z), new Vertex(x + bottomLeft.x, y + bottomLeft.y, z + bottomLeft.z), new Vertex(x + topRight.x, y + topRight.y, z + topRight.z), new Vertex(x + topLeft.x, y + topLeft.y, z + topLeft.z), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
public void renderSquareXPos(double xmax, double ymin, double ymax, double zmin, double zmax, float umin, float uimin, float umax, float uimax, float vmin, float vimin, float vmax, float vimax) { double xMax = x + xmax; double yMin = y + ymin; double yMax = y + ymax; double zMin = z + zmin; double zMax = z + zmax; renderFaceXPos(new Vertex((float)xMax, (float)yMin, (float)zMin), new Vertex((float)xMax, (float)yMin, (float)zMax), new Vertex((float)xMax, (float)yMax, (float)zMin), new Vertex((float)xMax, (float)yMax, (float)zMax), umin, uimin, umax, uimax, vmin, vimin, vmax, vimax); }
private void renderSalad(TileBowl te, float level, BlockBowl bowl, CWTFCRenderer myRenderer) { IIcon salad = bowl.getBowlIcon("VeggySalad"); float xCoord = te.getBowlCoord(0); float zCoord = te.getBowlCoord(1); if(te.getSaladType() == 2) salad = bowl.getBowlIcon("PotatoSalad"); else if(te.getSaladType() == 1) salad = bowl.getBowlIcon("FruitSalad"); float xStart = xCoord - 0.1F; float zStart = zCoord - 0.1F; float minX = 0.02F + xCoord - 0.1F; float maxX = 0.2F - 0.02F + xCoord - 0.1F; float minY = level; float maxY = level + 0.05F; float minZ = 0.02F + zCoord - 0.1F; float maxZ = 0.2F - 0.02F + zCoord - 0.1F; myRenderer.icon = salad; myRenderer.renderSquareYPos(minX, maxX, maxY, minZ, maxZ, 0F, 0.5F, 0F, 0.5F); myRenderer.renderQuadXNeg(new Vertex(xStart, minY, maxZ), new Vertex(xStart, minY, minZ), new Vertex(minX, maxY, zStart + 0.2F), new Vertex(minX, maxY, zStart), 0F, 0.5F, 0F, 0.25F); myRenderer.renderQuadZPos(new Vertex(maxX, minY, zStart + 0.2F), new Vertex(minX, minY, zStart + 0.2F), new Vertex(xStart + 0.2F, maxY, maxZ), new Vertex(xStart, maxY, maxZ), 0F, 0.5F, 0.25F, 0.5F); myRenderer.renderQuadXPos(new Vertex(xStart + 0.2F, minY, minZ), new Vertex(xStart + 0.2F, minY, maxZ), new Vertex(maxX, maxY, zStart), new Vertex(maxX, maxY, zStart + 0.2F), 0F, 0.5F, 0.5F, 0.75F); myRenderer.renderQuadZNeg(new Vertex(xStart, minY, minZ), new Vertex(xStart + 0.2F, minY, minZ), new Vertex(minX, maxY, zStart), new Vertex(maxX, maxY, zStart), 0F, 0.5F, 0.75F, 1F); }
public static void renderWithIcon(GroupObject go, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z, VertexTransform vt, boolean isbrh) { for (Face f : go.faces) { Vertex n = f.faceNormal; tes.setNormal(n.x, n.y, n.z); ForgeDirection normal = getNormalFor(n); ForgeDirection right = normal.getRotation(ForgeDirection.DOWN); if (normal == right) { right = ForgeDirection.EAST; } ForgeDirection down = normal.getRotation(right.getOpposite()); if (isbrh && world != null && world.getBlock(x, y, z).getLightOpacity() > 0) { int bx = x + normal.offsetX; int by = y + normal.offsetY; int bz = z + normal.offsetZ; tes.setBrightness(world.getBlock(bx, by, bz).getMixedBrightnessForBlock(world, bx, by, bz)); } for (int i = 0; i < f.vertices.length; i++) { Vertex vert = f.vertices[i]; Vector3d v = new Vector3d(vert); Vector3d tv = new Vector3d(v); tv.add(0.5, 0, 0.5); if (vt != null) { vt.apply(v); // TODO BLECH if (vt instanceof VertexRotationFacing) { normal = ((VertexRotationFacing) vt).rotate(normal); } if (vt instanceof VertexTransformComposite) { for (VertexTransform xform : ((VertexTransformComposite) vt).xforms) { if (xform instanceof VertexRotationFacing) { normal = ((VertexRotationFacing) xform).rotate(normal); } } } } if (isbrh) { int c = (int) (0xFF * RenderUtil.getColorMultiplierForFace(normal)); tes.setColorOpaque(c, c, c); } if (override != null) { double interpX = Math.abs(tv.x * right.offsetX + tv.y * right.offsetY + tv.z * right.offsetZ); double interpY = Math.abs(tv.x * down.offsetX + tv.y * down.offsetY + tv.z * down.offsetZ); // Handles verts outside block bounds. Modulo fails at 1.0. while (interpX > 1) { interpX--; } while (interpY > 1) { interpY--; } if (normal == ForgeDirection.SOUTH || normal == ForgeDirection.WEST) { interpX = 1 - interpX; } if (normal != ForgeDirection.UP && normal != ForgeDirection.DOWN) { interpY = 1 - interpY; } tes.addVertexWithUV(v.x, v.y, v.z, override.getInterpolatedU(interpX * 16), override.getInterpolatedV(interpY * 16)); } else { TextureCoordinate t = f.textureCoordinates[i]; tes.addVertexWithUV(v.x, v.y, v.z, getInterpolatedU(icon, t.u), getInterpolatedV(icon, t.v)); } } } }
public Vector3d(Vertex vert) { this(vert.x, vert.y, vert.z); }
private static void renderFluid(double xmin, double xmax, double ymax, double zmin, double zmax, int x, int y, int z, Block block, RenderBlocks renderer, IIcon icon, int color) { double xMin = x + xmin; double xMax = x + xmax; double yMax = y + ymax; double zMin = z + zmin; double zMax = z + zmax; Vertex bottomRight = new Vertex((float)xMin, (float)yMax, (float)zMin); Vertex bottomLeft = new Vertex((float)xMax, (float)yMax, (float)zMin); Vertex topRight = new Vertex((float)xMin, (float)yMax, (float)zMax); Vertex topLeft = new Vertex((float)xMax, (float)yMax, (float)zMax); Tessellator tessellator = Tessellator.instance; if (renderer.hasOverrideBlockTexture()) { icon = renderer.overrideBlockTexture; } double uMin = (double)icon.getInterpolatedU(0); double uMax = (double)icon.getInterpolatedU(16); double vMin = (double)icon.getInterpolatedV(0); double vMax = (double)icon.getInterpolatedV(16); double uiMax = uMax; double uiMin = uMin; double viMin = vMin; double viMax = vMax; float red = (float)(color >> 16 & 255) / 255.0F; float green = (float)(color >> 8 & 255) / 255.0F; float blue = (float)(color & 255) / 255.0F; if (EntityRenderer.anaglyphEnable) { float f3 = (red * 30.0F + green * 59.0F + blue * 11.0F) / 100.0F; float f4 = (red * 30.0F + green * 70.0F) / 100.0F; float f5 = (red * 30.0F + blue * 70.0F) / 100.0F; red = f3; green = f4; blue = f5; } tessellator.setColorOpaque_F(red, green, blue); tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z)); tessellator.addVertexWithUV(topLeft.x, topLeft.y, topLeft.z, uMax, vMax); tessellator.addVertexWithUV(bottomLeft.x, bottomLeft.y, bottomLeft.z, uiMax, viMin); tessellator.addVertexWithUV(bottomRight.x, bottomRight.y, bottomRight.z, uMin, vMin); tessellator.addVertexWithUV(topRight.x, topRight.y, topRight.z, uiMin, viMax); renderer.clearOverrideBlockTexture(); }
public void renderQuadYNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float umax, float vmin, float vmax) { renderQuadYNeg(bottomRight, bottomLeft, topRight, topLeft, umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadYNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft) { renderQuadYNeg(bottomRight, bottomLeft, topRight, topLeft, 0, 1, 0, 1); }
public void renderQuadYPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float umax, float vmin, float vmax) { renderQuadYPos(bottomRight, bottomLeft, topRight, topLeft, umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadYPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft) { renderQuadYPos(bottomRight, bottomLeft, topRight, topLeft, 0, 1, 0, 1); }
public void renderQuadZNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float umax, float vmin, float vmax) { renderQuadZNeg(bottomRight, bottomLeft, topRight, topLeft, umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadZNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft) { renderQuadZNeg(bottomRight, bottomLeft, topRight, topLeft, 0, 1, 0, 1); }
public void renderQuadZPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float umax, float vmin, float vmax) { renderQuadZPos(bottomRight, bottomLeft, topRight, topLeft, umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadZPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft) { renderQuadZPos(bottomRight, bottomLeft, topRight, topLeft, 0, 1, 0, 1); }
public void renderQuadXNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float umax, float vmin, float vmax) { renderQuadXNeg(bottomRight, bottomLeft, topRight, topLeft, umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadXNeg(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft) { renderQuadXNeg(bottomRight, bottomLeft, topRight, topLeft, 0, 1, 0, 1); }
public void renderQuadXPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft, float umin, float umax, float vmin, float vmax) { renderQuadXPos(bottomRight, bottomLeft, topRight, topLeft, umin, umin, umax, umax, vmin, vmin, vmax, vmax); }
public void renderQuadXPos(Vertex bottomRight, Vertex bottomLeft, Vertex topRight, Vertex topLeft) { renderQuadXPos(bottomRight, bottomLeft, topRight, topLeft, 0, 1, 0, 1); }