Jump to content

ISimpleBlockRenderingHandler enable Ambient Occlusion and shadows


Recommended Posts

Posted

Hi, i made a custom modeled translucent block (glacia column) and now i need to know how to enable ambient occlusion so that i can make it generate shadows and make it shadowed on the bottom.

 

here is my rendering code

 

RenderGlaciaColumn:

 

package net.minecraft.src;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.ResourceLocation;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;

public class RenderGlaciaColumn extends RenderBlocks implements ISimpleBlockRenderingHandler
{

public Icon getIcon0;
public Icon getIcon1;
public Icon getIcon2;

    public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
getIcon0 = block.getIcon(0, 0);
getIcon1 = block.getIcon(0, 1);
getIcon2 = block.getIcon(0, 2);

double minU2 = (double)getIcon0.getMinU();
double minV2 = (double)getIcon0.getMinV();
double maxU2 = (double)getIcon0.getMaxU();
double maxV2 = (double)getIcon0.getMaxV();
double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();
Tessellator tessellator = Tessellator.instance;
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

//portantdown face 1

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    tessellator.addVertexWithUV(1.0, 0.0, 0.0, maxU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.25, 0.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 0.25, 0.0, minU2, maxV2);
    tessellator.draw();

//portantdown face inverse  1

tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.addVertexWithUV(1.0, 0.25, 1.0, minU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.25, 1.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 0.0, 1.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 0.0, 1.0, maxU2, maxV2);
tessellator.draw();

// portantdown face 2
tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 0.25, 1.0, minU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.25, 0.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 0.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.0, 1.0, maxU2, maxV2);
tessellator.draw();

// portantdown face inverse 2
tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.0, 1.0, maxU2, maxV2);
tessellator.addVertexWithUV(1.0, 0.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 0.25, 0.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 0.25, 1.0, minU2, maxV2);
tessellator.draw();

// portantup face 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.addVertexWithUV(1.0, 0.75, 0.0, minU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.75, 0.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 1.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 1.0, 0.0, maxU2, maxV2);
tessellator.draw();

// portantup face inverse 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.addVertexWithUV(1.0, 1.0, 1.0, maxU2, maxV2);
tessellator.addVertexWithUV(0.0, 1.0, 1.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.75, 1.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 0.75, 1.0, minU2, maxV2);
tessellator.draw();

// portantup face 2
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.75, 1.0, minU2, maxV2);
tessellator.addVertexWithUV(1.0, 0.75, 0.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 1.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 1.0, 1.0, maxU2, maxV2);
tessellator.draw();

// portantup face inverse 2
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 1.0, 1.0, maxU2, maxV2);
tessellator.addVertexWithUV(0.0, 1.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.75, 0.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 0.75, 1.0, minU2, maxV2);
tessellator.draw();

// portantup base up
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 1.0, 0.0, maxU1, maxV1);
tessellator.addVertexWithUV(0.0, 1.0, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(1.0, 1.0, 1.0, minU1, minV1);
tessellator.addVertexWithUV(1.0, 1.0, 0.0, minU1, maxV1);
tessellator.draw();

// portantup base down
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.75, 0.0, minU1, maxV1);
tessellator.addVertexWithUV(1.0, 0.75, 1.0, minU1, minV1);
tessellator.addVertexWithUV(0.0, 0.75, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(0.0, 0.75, 0.0, maxU1, maxV1);
tessellator.draw();

// portantdown base up
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 0.25, 0.0, maxU1, maxV1);
tessellator.addVertexWithUV(0.0, 0.25, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(1.0, 0.25, 1.0, minU1, minV1);
tessellator.addVertexWithUV(1.0, 0.25, 0.0, minU1, maxV1);
tessellator.draw();

// portantdown base down
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.0, 0.0, minU1, maxV1);
tessellator.addVertexWithUV(1.0, 0.0, 1.0, minU1, minV1);
tessellator.addVertexWithUV(0.0, 0.0, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(0.0, 0.0, 0.0, maxU1, maxV1);
tessellator.draw();

// pillar 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.addVertexWithUV(0.25, 0.99, 0.25, minU3, minV3);
tessellator.addVertexWithUV(0.75, 0.99, 0.25, minU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.25, maxU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.25, maxU3, minV3);
tessellator.draw();

// pillar inverse 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.addVertexWithUV(0.75, 0.99, 0.75, minU3, minV3);
tessellator.addVertexWithUV(0.25, 0.99, 0.75, minU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.75, maxU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.75, maxU3, minV3);
tessellator.draw();

// pillar 2
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.25, 0.99, 0.75, minU3, minV3);
tessellator.addVertexWithUV(0.25, 0.99, 0.25, minU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.25, maxU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.75, maxU3, minV3);
tessellator.draw();

// pillar inverse 2
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.75, 0.99, 0.25, minU3, minV3);
tessellator.addVertexWithUV(0.75, 0.99, 0.75, minU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.75, maxU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.25, maxU3, minV3);
tessellator.draw();

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}

@Override
    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
    {
	Tessellator tessellator = Tessellator.instance;
	int lightValue = block.getMixedBrightnessForBlock(world, x, y, z);
	tessellator.setBrightness(lightValue);
	tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);

	getIcon0 = block.getIcon(0, 0);
	getIcon1 = block.getIcon(0, 1);
	getIcon2 = block.getIcon(0, 2);

	if (world.getBlockMetadata(x, y, z) == 3)
	{
	renderColumnFull(tessellator, (double)x, (double)y, (double) z);
	}
	else if (world.getBlockMetadata(x, y, z) == 2)
	{
	renderColumnDown(tessellator, (double)x, (double)y, (double) z, block, world);
	} 
	else if (world.getBlockMetadata(x, y, z) == 1)
	{
	renderColumnUp(tessellator, (double)x, (double)y, (double) z, block, world);
	}
	else
	{
	renderColumnCenter(tessellator, (double)x, (double)y, (double) z, block, world);
	} 
	return true;


	//aModel.ColumnDown.showModel = false;
	//aModel.ColumnUp.showModel = false;
	//aModel.ColumnFull.showModel = false;
	//aModel.PortantUp.showModel = true;
	//aModel.PortantDown.showModel = true;
	//aModel.ColumnCenter.showModel = true;

	//GL11.glBindTexture(GL11.GL_TEXTURE_2D, 2);
	//GL11.glPushMatrix();
	//GL11.glTranslatef((float)x + 0.5F, (float)y - 0.50F, (float)z + 0.5F);
	//GL11.glRotatef(0, 0F, 0F, 0F);
	//GL11.glPushMatrix();
	//aModel.renderModel(0.0625F);
	//GL11.glPopMatrix();
	//GL11.glPopMatrix();

	//tessellator.startDrawingQuads();
	//tessellator.setNormal(0.0F, -1.0F, 0.0F);
	//tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, minU1, maxV1);
	//tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, minU1, minV1);
	//tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU1, minV1);
	//tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU1, maxV1);
}

    public boolean shouldRender3DInInventory(){ return true; }

@Override
public int getRenderId()
{
	return mod_Glacia.rendercolumnID;
}

private void renderColumnFull(Tessellator tessellator, double x, double y, double z) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

// portantdown face 1
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 1
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face 2
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 2
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
  
  private void renderColumnUp(Tessellator tessellator, double x, double y, double z, Block block, IBlockAccess world) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

int lightValue = block.getMixedBrightnessForBlock(world, (int)x, (int)y, (int)z);

// portantup face 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
  
  private void renderColumnDown(Tessellator tessellator, double x, double y, double z, Block block, IBlockAccess world) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

int lightValue = block.getMixedBrightnessForBlock(world, (int)x, (int)y, (int)z);

// portantdown face 1
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 1
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face 2
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 2
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
  
  private void renderColumnCenter(Tessellator tessellator, double x, double y, double z, Block block, IBlockAccess world) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

int lightValue = block.getMixedBrightnessForBlock(world, (int)x, (int)y, (int)z);

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
}

 

 

here is a screen:

450y.png

Actually i don't know what to write in this signature soooo.... anyway

Posted

Hi

 

Cute reindeer there... is that in the new update?

 

What you're asking isn't as simple as you might think.

 

There's some background info on Minecraft ambient occlusion here:

http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html

 

The Ambient occlusion code in vanilla is in

.renderBlockWithAmbientOcclusion() and .renderStandardBlockWithAmbientOcclusion()

and they assume a cube or rectangular prism.  Your block is an unusual shape so the vanilla code won't handle it properly.

 

Disclaimer - if it's different in 1.7, I don't know about that yet.

 

If you see another vanilla block that does the same thing as what you want, perhaps the rendering code for that block might give you clues?

 

-TGG

 

 

 

Posted

Hi

 

Cute reindeer there... is that in the new update?

 

What you're asking isn't as simple as you might think.

 

There's some background info on Minecraft ambient occlusion here:

http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html

 

The Ambient occlusion code in vanilla is in

.renderBlockWithAmbientOcclusion() and .renderStandardBlockWithAmbientOcclusion()

and they assume a cube or rectangular prism.  Your block is an unusual shape so the vanilla code won't handle it properly.

 

Disclaimer - if it's different in 1.7, I don't know about that yet.

 

If you see another vanilla block that does the same thing as what you want, perhaps the rendering code for that block might give you clues?

 

-TGG

 

the other custom rendered block use for example

 

this.setRenderBounds(0.3125D, 0.0D, 0.0D, 0.6875D, 0.8125D, 1.0D);

this.renderStandardBlock(par1BlockWall, par2, par3, par4);

 

instead of tessellating, so it will render a standard block shaped as the block bounds

but in my code i use tessellator and different textures for each (almost each) faces, so it is more difficult... does anyone have an answer?

Actually i don't know what to write in this signature soooo.... anyway

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.