Jump to content

[Solved][1.6.4] TileEntitySpecialRenderer breaks with another entity in view


Zarathul

Recommended Posts

UPDATE: Turns out when another entity is in the scene the wrong texture map is set (items instead of blocks) . Adding "bindTexture(TextureMap.locationBlocksTexture)" in "renderTileEntityAt()" fixed the problem.

 

I implemented a TileEntitySpecialRenderer and everything is rendered exactly as it should be until any entitys other than my own enter the scene (e.g. any item, any creature and even the player itself in 3rd person view). I first thought I messed up with the Tessellator.draw() and Tessellator.startDrawingQuads() calls but if I do it any other way than in the posted code I get the usual exceptions ("tessellator already tessellating" etc). Hints on what's going on here would be very appreciated.

(The transparent blocks are the ones rendered by the TileEntitySpecialRenderer)

 

That's how it's always supposed to look like

a3gneq.jpg

 

That's how it looks with an addtional entity in the scene (the bucket on the ground).

34nmnvo.png

 

TileEntitySpecialRenderer

package simplefluidtanks;

import java.util.ArrayList;
import java.util.HashMap;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.launchwrapper.LogWrapper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidRegistry.FluidRegisterEvent;
import net.minecraftforge.fluids.FluidStack;

@SideOnly(Side.CLIENT)
public class TankBlockRenderer extends TileEntitySpecialRenderer
{
public TankBlockRenderer()
{
	super();
}

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
	if (tileEntity == null || !(tileEntity instanceof TankBlockEntity))
	{
		return;
	}

	Block block = tileEntity.getBlockType();

	if (block == null || !(block instanceof TankBlock))
	{
		return;
	}

	TankBlock tank = (TankBlock)block;
	TankBlockEntity entity = (TankBlockEntity)tileEntity;
	Icon[] icons = tank.getIcons();

	Tessellator tsr = Tessellator.instance;
	int brightness = block.getMixedBrightnessForBlock(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord);
	tsr.setBrightness(brightness);

	TessellationManager.setBaseCoords(x, y, z);

	if (tsr.isDrawing) tsr.draw();

	tsr.startDrawingQuads();

	if (!entity.isPartOfTank())
	{
		renderSolid(entity, icons[0]);
	}
	else
	{
		boolean[] connections = entity.getConnections();
		int fillPercentage = entity.getFillPercentage();
		double fluidHeight = 16.0 / 100 * fillPercentage;
		double verticalTextureOffset = 16.0 / 100 * (100 - fillPercentage);
		Icon fluidIcon = getFluidTexture(entity);

		renderPositiveXFace(entity, connections, icons, fluidIcon, fillPercentage, fluidHeight, verticalTextureOffset);
		renderNegativeXFace(entity, connections, icons, fluidIcon, fillPercentage, fluidHeight, verticalTextureOffset);
		renderPositiveZFace(entity, connections, icons, fluidIcon, fillPercentage, fluidHeight, verticalTextureOffset);
		renderNegativeZFace(entity, connections, icons, fluidIcon, fillPercentage, fluidHeight, verticalTextureOffset);
		renderPositiveYFace(entity, connections, icons, fluidIcon, fillPercentage, fluidHeight);
		renderNegativeYFace(entity, connections, icons, fluidIcon, fillPercentage);
	}

	tsr.draw();
}

private void renderSolid(TankBlockEntity entity, Icon icon)
{
	TessellationManager.renderCube(1, 0, 1, 14, 14, 14, icon, true, TessellationManager.pixel);
}

private void renderPositiveXFace(TankBlockEntity entity, boolean[] connections, Icon[] icons, Icon fluidIcon, int fillPercentage, double fluidHeight, double verticalTextureOffset)
{
	// only render this side if there isn't a tank block from the same tank in front of it 
	if (!connections[ConnectedTexturesHelper.XPOS])
	{
		if (fillPercentage > 0 && fluidIcon != null)
		{
			TessellationManager.renderPositiveXFace(16, 0, 0, fluidHeight, 16, 0, verticalTextureOffset, 0, 0, fluidIcon, TessellationManager.pixel);
		}

		TessellationManager.renderPositiveXFace(16, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.XPOS)]);
		// inner face
		TessellationManager.renderNegativeXFace(16, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.XNEG)]);
	}
}

private void renderNegativeXFace(TankBlockEntity entity, boolean[] connections, Icon[] icons, Icon fluidIcon, int fillPercentage, double fluidHeight, double verticalTextureOffset)
{
	// only render this side if there isn't a tank block from the same tank in front of it 
	if (!connections[ConnectedTexturesHelper.XNEG])
	{
		if (fillPercentage > 0 && fluidIcon != null)
		{
			TessellationManager.renderNegativeXFace(0, 0, 0, fluidHeight, 16, 0, verticalTextureOffset, 0, 0, fluidIcon, TessellationManager.pixel);
		}

		TessellationManager.renderNegativeXFace(0, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.XNEG)]);
		// inner face
		TessellationManager.renderPositiveXFace(0, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.XPOS)]);
	}
}

private void renderPositiveZFace(TankBlockEntity entity, boolean[] connections, Icon[] icons, Icon fluidIcon, int fillPercentage, double fluidHeight, double verticalTextureOffset)
{
	// only render this side if there isn't a tank block from the same tank in front of it 
	if (!connections[ConnectedTexturesHelper.ZPOS])
	{
		if (fillPercentage > 0 && fluidIcon != null)
		{
			TessellationManager.renderPositiveZFace(0, 0, 16, 16, fluidHeight, 0, verticalTextureOffset, 0, 0, fluidIcon, TessellationManager.pixel);
		}

		TessellationManager.renderPositiveZFace(0, 0, 16, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.ZPOS)]);
		// inner face
		TessellationManager.renderNegativeZFace(0, 0, 16, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.ZNEG)]);
	}
}

private void renderNegativeZFace(TankBlockEntity entity, boolean[] connections, Icon[] icons, Icon fluidIcon, int fillPercentage, double fluidHeight, double verticalTextureOffset)
{
	// only render this side if there isn't a tank block from the same tank in front of it 
	if (!connections[ConnectedTexturesHelper.ZNEG])
	{
		if (fillPercentage > 0 && fluidIcon != null)
		{
			TessellationManager.renderNegativeZFace(0, 0, 0, 16, fluidHeight, 0, verticalTextureOffset, 0, 0, fluidIcon, TessellationManager.pixel);
		}

		TessellationManager.renderNegativeZFace(0, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.ZNEG)]);
		// inner face
		TessellationManager.renderPositiveZFace(0, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.ZPOS)]);
	}
}

private void renderPositiveYFace(TankBlockEntity entity, boolean[] connections, Icon[] icons, Icon fluidIcon, int fillPercentage, double fluidHeight)
{
	if (fillPercentage > 0 && fluidIcon != null)
	{
		TessellationManager.renderPositiveYFace(0, fluidHeight, 0, 16, 16, fluidIcon);
	}

	// only render this side if there isn't a tank block from the same tank in front of it 
	if (!connections[ConnectedTexturesHelper.YPOS])
	{
		TessellationManager.renderPositiveYFace(0, 16, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.YPOS)]);
		// inner face
		TessellationManager.renderNegativeYFace(0, 16, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.YNEG)]);
	}
}

private void renderNegativeYFace(TankBlockEntity entity, boolean[] connections, Icon[] icons, Icon fluidIcon, int fillPercentage)
{
	// only render this side if there isn't a tank block from the same tank in front of it 
	if (fillPercentage > 0 && fluidIcon != null && !connections[ConnectedTexturesHelper.YNEG])
	{
		TessellationManager.renderNegativeYFace(0, 0, 0, 16, 16, fluidIcon);
	}

	if (!connections[ConnectedTexturesHelper.YNEG])
	{
		TessellationManager.renderNegativeYFace(0, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.YNEG)]);
		// inner face
		TessellationManager.renderPositiveYFace(0, 0, 0, 16, 16, icons[entity.getTexture(ConnectedTexturesHelper.YPOS)]);
	}
}

private Icon getFluidTexture(TankBlockEntity entity)
{
	ValveBlockEntity valve = entity.getValve();

	if (valve != null)
	{
		FluidStack fluidStack = valve.getFluid();

		if (fluidStack != null)
		{
			return fluidStack.getFluid().getIcon();
		}
	}

	return null;
}
}

 

TessellationManager (helper class)

package simplefluidtanks;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidRegistry;

public final class TessellationManager
{
public static final double pixel = 1d / 16d;

private static final Tessellator tr = Tessellator.instance;
private static double xBaseCoord;
private static double yBaseCoord;
private static double zBaseCoord;

private TessellationManager()
{
}

public static void setBaseCoords(double ... coords)
{
	if (coords != null && coords.length >= 3)
	{
		xBaseCoord = coords[0];
		yBaseCoord = coords[1];
		zBaseCoord = coords[2];
	}
}

public static void renderCube(double xOffset, double yOffset, double zOffset, double width, double height, double depth, Icon icon)
{
	renderCube(xOffset, yOffset, zOffset, width, height, depth, icon, false, pixel);
}

public static void renderCube(double xOffset, double yOffset, double zOffset, double width, double height, double depth, Icon icon, boolean renderInside, double scale)
{
	renderPositiveXFace(xOffset + width, yOffset, zOffset, height, depth, icon, scale);
	renderNegativeXFace(xOffset, yOffset, zOffset, height, depth, icon, scale);
	renderPositiveYFace(xOffset, yOffset + height, zOffset, width, depth, icon, scale);
	renderNegativeYFace(xOffset, yOffset, zOffset, width, depth, icon, scale);
	renderPositiveZFace(xOffset, yOffset, zOffset + depth, width, height, icon, scale);
	renderNegativeZFace(xOffset, yOffset, zOffset, width, height, icon, scale);

	if (renderInside)
	{
		// positive x back side
		renderNegativeXFace(xOffset + width, yOffset, zOffset, height, depth, icon, scale);
		// negative x back side
		renderPositiveXFace(xOffset, yOffset, zOffset, height, depth, icon, scale);
		// positive y back side
		renderNegativeYFace(xOffset, yOffset + height, zOffset, width, depth, icon, scale);
		// negative y back side
		renderPositiveYFace(xOffset, yOffset, zOffset, width, depth, icon, scale);
		// positive z back side
		renderNegativeZFace(xOffset, yOffset, zOffset + depth, width, height, icon, scale);
		// negative back side
		renderPositiveZFace(xOffset, yOffset, zOffset, width, height, icon, scale);
	}
}

public static void renderPositiveXFace(double xOffset, double yOffset, double zOffset, double height, double depth, Icon icon)
{
	renderPositiveXFace(xOffset, yOffset, zOffset, height, depth, 0, 0, 0, 0, icon, pixel);
}

public static void renderPositiveXFace(double xOffset, double yOffset, double zOffset, double height, double depth, Icon icon, double scale)
{
	renderPositiveXFace(xOffset, yOffset, zOffset, height, depth, 0, 0, 0, 0, icon, scale);
}

public static void renderPositiveXFace(double xOffset, double yOffset, double zOffset, double height, double depth, double uOffset, double vOffset, double uMaxOffset, double vMaxOffset, Icon icon, double scale)
{
	tr.setNormal(1f, 0f, 0f);

	double x = xBaseCoord + xOffset * scale;

	// bottom right
	double zBr = zBaseCoord + zOffset * scale;
	double yBr = yBaseCoord + yOffset * scale;

	// top right
	double zTr = zBaseCoord + zOffset * scale;
	double yTr = yBaseCoord + (yOffset + height) * scale;

	// top left
	double zTl = zBaseCoord + (zOffset + depth) * scale;
	double yTl = yBaseCoord + (yOffset + height) * scale;

	// bottom left
	double zBl = zBaseCoord + (zOffset + depth) * scale;
	double yBl = yBaseCoord + yOffset * scale;

	double minU = (uOffset > 0 && uOffset < 16) ? icon.getMinU() + (icon.getInterpolatedU(uOffset) - icon.getMinU()) : icon.getMinU();
	double maxU = (uMaxOffset > 0 && uMaxOffset < 16) ? icon.getMaxU() - (icon.getMaxU() - icon.getInterpolatedU(uMaxOffset)) : icon.getMaxU();
	double minV = (vOffset > 0 && vOffset < 16) ? icon.getMinV() + (icon.getInterpolatedV(vOffset) - icon.getMinV()) : icon.getMinV();
	double maxV = (vMaxOffset > 0 && vMaxOffset < 16) ? icon.getMaxV() - (icon.getMaxV() - icon.getInterpolatedV(vMaxOffset)) : icon.getMaxV();

	// bottom right
	tr.addVertexWithUV(x, yBr, zBr, maxU, maxV);
	// top right
	tr.addVertexWithUV(x, yTr, zTr, maxU, minV);
	// top left
	tr.addVertexWithUV(x, yTl, zTl, minU, minV);
	// bottom left
	tr.addVertexWithUV(x, yBl, zBl, minU, maxV);
}

public static void renderNegativeXFace(double xOffset, double yOffset, double zOffset, double height, double depth, Icon icon)
{
	renderNegativeXFace(xOffset, yOffset, zOffset, height, depth, 0, 0, 0, 0, icon, pixel);
}

public static void renderNegativeXFace(double xOffset, double yOffset, double zOffset, double height, double depth, Icon icon, double scale)
{
	renderNegativeXFace(xOffset, yOffset, zOffset, height, depth, 0, 0, 0, 0, icon, scale);
}

public static void renderNegativeXFace(double xOffset, double yOffset, double zOffset, double height, double depth, double uOffset, double vOffset, double uMaxOffset, double vMaxOffset, Icon icon, double scale)
{
	tr.setNormal(-1f, 0f, 0f);

	double x = xBaseCoord + xOffset * scale;

	// bottom left
	double zBl = zBaseCoord + zOffset * scale;
	double yBl = yBaseCoord + yOffset * scale;

	// bottom right
	double zBr = zBaseCoord + (zOffset + depth) * scale;
	double yBr = yBaseCoord + yOffset * scale;

	// top right
	double zTr = zBaseCoord + (zOffset + depth) * scale;
	double yTr = yBaseCoord + (yOffset + height) * scale;

	// top left
	double zTl = zBaseCoord + zOffset * scale;
	double yTl = yBaseCoord + (yOffset + height) * scale;

	double minU = (uOffset > 0 && uOffset < 16) ? icon.getMinU() + (icon.getInterpolatedU(uOffset) - icon.getMinU()) : icon.getMinU();
	double maxU = (uMaxOffset > 0 && uMaxOffset < 16) ? icon.getMaxU() - (icon.getMaxU() - icon.getInterpolatedU(uMaxOffset)) : icon.getMaxU();
	double minV = (vOffset > 0 && vOffset < 16) ? icon.getMinV() + (icon.getInterpolatedV(vOffset) - icon.getMinV()) : icon.getMinV();
	double maxV = (vMaxOffset > 0 && vMaxOffset < 16) ? icon.getMaxV() - (icon.getMaxV() - icon.getInterpolatedV(vMaxOffset)) : icon.getMaxV();

	// bottom left
	tr.addVertexWithUV(x, yBl, zBl, minU, maxV);
	// bottom right
	tr.addVertexWithUV(x, yBr, zBr, maxU, maxV);
	// top right
	tr.addVertexWithUV(x, yTr, zTr, maxU, minV);
	// top left
	tr.addVertexWithUV(x, yTl, zTl, minU, minV);
}

public static void renderPositiveYFace(double xOffset, double yOffset, double zOffset, double width, double depth, Icon icon)
{
	renderPositiveYFace(xOffset, yOffset, zOffset, width, depth, 0, 0, 0, 0, icon, pixel);
}

public static void renderPositiveYFace(double xOffset, double yOffset, double zOffset, double width, double depth, Icon icon, double scale)
{
	renderPositiveYFace(xOffset, yOffset, zOffset, width, depth, 0, 0, 0, 0, icon, scale);
}

public static void renderPositiveYFace(double xOffset, double yOffset, double zOffset, double width, double depth, double uOffset, double vOffset, double uMaxOffset, double vMaxOffset, Icon icon, double scale)
{
	tr.setNormal(0f, 1f, 0f);

	double y = yBaseCoord + yOffset * scale;

	// bottom right
	double xBr = xBaseCoord + xOffset * scale;
	double zBr = zBaseCoord + zOffset * scale;

	// top right
	double xTr = xBaseCoord + xOffset * scale;
	double zTr = zBaseCoord + (zOffset + depth) * scale;

	// top left
	double xTl = xBaseCoord + (xOffset + width) * scale;
	double zTl = zBaseCoord + (zOffset + depth) * scale;

	// bottom left
	double xBl = xBaseCoord + (xOffset + width) * scale;
	double zBl = zBaseCoord + zOffset * scale;

	double minU = (uOffset > 0 && uOffset < 16) ? icon.getMinU() + (icon.getInterpolatedU(uOffset) - icon.getMinU()) : icon.getMinU();
	double maxU = (uMaxOffset > 0 && uMaxOffset < 16) ? icon.getMaxU() - (icon.getMaxU() - icon.getInterpolatedU(uMaxOffset)) : icon.getMaxU();
	double minV = (vOffset > 0 && vOffset < 16) ? icon.getMinV() + (icon.getInterpolatedV(vOffset) - icon.getMinV()) : icon.getMinV();
	double maxV = (vMaxOffset > 0 && vMaxOffset < 16) ? icon.getMaxV() - (icon.getMaxV() - icon.getInterpolatedV(vMaxOffset)) : icon.getMaxV();

	// bottom right
	tr.addVertexWithUV(xBr, y, zBr, maxU, maxV);
	// top right
	tr.addVertexWithUV(xTr, y, zTr, maxU, minV);
	// top left
	tr.addVertexWithUV(xTl, y, zTl, minU, minV);
	// bottom left
	tr.addVertexWithUV(xBl, y, zBl, minU, maxV);
}

public static void renderNegativeYFace(double xOffset, double yOffset, double zOffset, double width, double depth, Icon icon)
{
	renderNegativeYFace(xOffset, yOffset, zOffset, width, depth, 0, 0, 0, 0, icon, pixel);
}

public static void renderNegativeYFace(double xOffset, double yOffset, double zOffset, double width, double depth, Icon icon, double scale)
{
	renderNegativeYFace(xOffset, yOffset, zOffset, width, depth, 0, 0, 0, 0, icon, scale);
}

public static void renderNegativeYFace(double xOffset, double yOffset, double zOffset, double width, double depth, double uOffset, double vOffset, double uMaxOffset, double vMaxOffset, Icon icon, double scale)
{
	tr.setNormal(0f, -1f, 0f);

	double y = yBaseCoord + yOffset * scale;

	// top right
	double xTr = xBaseCoord + xOffset * scale;
	double zTr = zBaseCoord + zOffset * scale;

	// top left
	double xTl = xBaseCoord + (xOffset + width) * scale;
	double zTl = zBaseCoord + zOffset * scale;

	// bottom left
	double xBl = xBaseCoord + (xOffset + width) * scale;
	double zBl = zBaseCoord + (zOffset + depth) * scale;

	// bottom right
	double xBr = xBaseCoord + xOffset * scale;
	double zBr = zBaseCoord + (zOffset + depth) * scale;

	double minU = (uOffset > 0 && uOffset < 16) ? icon.getMinU() + (icon.getInterpolatedU(uOffset) - icon.getMinU()) : icon.getMinU();
	double maxU = (uMaxOffset > 0 && uMaxOffset < 16) ? icon.getMaxU() - (icon.getMaxU() - icon.getInterpolatedU(uMaxOffset)) : icon.getMaxU();
	double minV = (vOffset > 0 && vOffset < 16) ? icon.getMinV() + (icon.getInterpolatedV(vOffset) - icon.getMinV()) : icon.getMinV();
	double maxV = (vMaxOffset > 0 && vMaxOffset < 16) ? icon.getMaxV() - (icon.getMaxV() - icon.getInterpolatedV(vMaxOffset)) : icon.getMaxV();

	// top right
	tr.addVertexWithUV(xTr, y, zTr, maxU, minV);
	// top left
	tr.addVertexWithUV(xTl, y, zTl, minU, minV);
	// bottom left
	tr.addVertexWithUV(xBl, y, zBl, minU, maxV);
	// bottom right
	tr.addVertexWithUV(xBr, y, zBr, maxU, maxV);
}

public static void renderPositiveZFace(double xOffset, double yOffset, double zOffset, double width, double height, Icon icon)
{
	renderPositiveZFace(xOffset, yOffset, zOffset, width, height, 0, 0, 0, 0, icon, pixel);
}

public static void renderPositiveZFace(double xOffset, double yOffset, double zOffset, double width, double height, Icon icon, double scale)
{
	renderPositiveZFace(xOffset, yOffset, zOffset, width, height, 0, 0, 0, 0, icon, scale);
}

public static void renderPositiveZFace(double xOffset, double yOffset, double zOffset, double width, double height, double uOffset, double vOffset, double uMaxOffset, double vMaxOffset, Icon icon, double scale)
{
	tr.setNormal(0f, 0f, 1f);

	double z = zBaseCoord + zOffset * scale;

	// bottom left
	double xBl = xBaseCoord + xOffset * scale;
	double yBl = yBaseCoord + yOffset * scale;

	// bottom right
	double xBr = xBaseCoord + (xOffset + width) * scale;
	double yBr = yBaseCoord + yOffset * scale;

	// top right
	double xTr = xBaseCoord + (xOffset + width) * scale;
	double yTr = yBaseCoord + (yOffset + height) * scale;

	// top left
	double xTl = xBaseCoord + xOffset * scale;
	double yTl = yBaseCoord + (yOffset + height) * scale;

	double minU = (uOffset > 0 && uOffset < 16) ? icon.getMinU() + (icon.getInterpolatedU(uOffset) - icon.getMinU()) : icon.getMinU();
	double maxU = (uMaxOffset > 0 && uMaxOffset < 16) ? icon.getMaxU() - (icon.getMaxU() - icon.getInterpolatedU(uMaxOffset)) : icon.getMaxU();
	double minV = (vOffset > 0 && vOffset < 16) ? icon.getMinV() + (icon.getInterpolatedV(vOffset) - icon.getMinV()) : icon.getMinV();
	double maxV = (vMaxOffset > 0 && vMaxOffset < 16) ? icon.getMaxV() - (icon.getMaxV() - icon.getInterpolatedV(vMaxOffset)) : icon.getMaxV();

	// bottom left
	tr.addVertexWithUV(xBl, yBl, z, minU, maxV);
	// bottom right
	tr.addVertexWithUV(xBr, yBr, z, maxU, maxV);
	// top right
	tr.addVertexWithUV(xTr, yTr, z, maxU, minV);
	// top left
	tr.addVertexWithUV(xTl, yTl, z, minU, minV);
}

public static void renderNegativeZFace(double xOffset, double yOffset, double zOffset, double width, double height, Icon icon)
{
	renderNegativeZFace(xOffset, yOffset, zOffset, width, height, 0, 0, 0, 0, icon, pixel);
}

public static void renderNegativeZFace(double xOffset, double yOffset, double zOffset, double width, double height, Icon icon, double scale)
{
	renderNegativeZFace(xOffset, yOffset, zOffset, width, height, 0, 0, 0, 0, icon, scale);
}

public static void renderNegativeZFace(double xOffset, double yOffset, double zOffset, double width, double height, double uOffset, double vOffset, double uMaxOffset, double vMaxOffset, Icon icon, double scale)
{
	tr.setNormal(0f, 0f, -1f);

	double z = zBaseCoord + zOffset * scale;

	// bottom right
	double xBr = xBaseCoord + xOffset * scale;
	double yBr = yBaseCoord + yOffset * scale;

	// top right
	double xTr = xBaseCoord + xOffset * scale;
	double yTr = yBaseCoord + (yOffset + height) * scale;

	// top left
	double xTl = xBaseCoord + (xOffset + width) * scale;
	double yTl = yBaseCoord + (yOffset + height) * scale;

	// bottom left
	double xBl = xBaseCoord + (xOffset + width) * scale;
	double yBl = yBaseCoord + yOffset * scale;

	double minU = (uOffset > 0 && uOffset < 16) ? icon.getMinU() + (icon.getInterpolatedU(uOffset) - icon.getMinU()) : icon.getMinU();
	double maxU = (uMaxOffset > 0 && uMaxOffset < 16) ? icon.getMaxU() - (icon.getMaxU() - icon.getInterpolatedU(uMaxOffset)) : icon.getMaxU();
	double minV = (vOffset > 0 && vOffset < 16) ? icon.getMinV() + (icon.getInterpolatedV(vOffset) - icon.getMinV()) : icon.getMinV();
	double maxV = (vMaxOffset > 0 && vMaxOffset < 16) ? icon.getMaxV() - (icon.getMaxV() - icon.getInterpolatedV(vMaxOffset)) : icon.getMaxV();

	// bottom right
	tr.addVertexWithUV(xBr, yBr, z, maxU, maxV);
	// top right
	tr.addVertexWithUV(xTr, yTr, z, maxU, minV);
	// top left
	tr.addVertexWithUV(xTl, yTl, z, minU, minV);
	// bottom left
	tr.addVertexWithUV(xBl, yBl, z, minU, maxV);
}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.