Example usage for org.lwjgl.opengl GL11 glTranslatef

List of usage examples for org.lwjgl.opengl GL11 glTranslatef

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glTranslatef.

Prototype

public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y,
        @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a translation matrix along the x-, y- and z- axes.

Usage

From source file:com.professorvennie.machinerycraft.client.renderer.tileentity.TileEntityRendererPlasticChest.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
    if (tileEntity instanceof TileEntityPlasticChest) {
        TileEntityPlasticChest tileEntityPlasticChest = (TileEntityPlasticChest) tileEntity;
        ForgeDirection direction = null;

        if (tileEntityPlasticChest.getWorldObj() != null) {
            direction = tileEntityPlasticChest.getOrientation();
            //System.out.println(tileEntityPlasticChest.getOrientation());
        }/*from  w w w. ja v  a  2  s .  c o  m*/
        this.bindTexture(texture);

        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        short angle = 0;

        if (direction != null) {
            if (direction == ForgeDirection.NORTH) {
                angle = 180;
            } else if (direction == ForgeDirection.SOUTH) {
                angle = 0;
            } else if (direction == ForgeDirection.WEST) {
                angle = 90;
            } else if (direction == ForgeDirection.EAST) {
                angle = -90;
            }
        }

        GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float adjustedLidAngle = tileEntityPlasticChest.prevLidAngle
                + (tileEntityPlasticChest.lidAngle - tileEntityPlasticChest.prevLidAngle) * tick;
        adjustedLidAngle = 1.0F - adjustedLidAngle;
        adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle;
        modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F);
        modelChest.renderAll();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:com.professorvennie.machinerycraft.machines.washer.TileEntityRendererWasher.java

License:Creative Commons License

public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float var8) {
    int x1 = tileentity.xCoord;
    int y1 = tileentity.yCoord;
    int z1 = tileentity.zCoord;

    int metadata = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
            tileentity.zCoord);//from   w ww  .  j  a  va2 s .  c  o m

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glTranslatef((float) x, (float) y, (float) z);
    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texterwasher);
    tessellator.startDrawingQuads();

    if (metadata == 5) {
        this.bindTexture(glass);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 1);

        tessellator.addVertexWithUV(1, 1, 0, 1, 0);
        tessellator.addVertexWithUV(1, 0, 0, 1, 1);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
    }
    if (metadata == 7) {
        this.bindTexture(glass);

        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);

    }
    if (metadata == 6) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 1);

        tessellator.addVertexWithUV(1, 1, 0, 1, 0);
        tessellator.addVertexWithUV(1, 0, 0, 1, 1);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 1, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 0, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 0);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
    }
    if (metadata == 3) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 1);

        tessellator.addVertexWithUV(1, 1, 0, 1, 0);
        tessellator.addVertexWithUV(1, 0, 0, 1, 1);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
    }
    if (metadata == 2) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 0, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 0);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);

        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 1, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
    }
    if (metadata == 4) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 0, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 0);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 1);

        tessellator.addVertexWithUV(1, 1, 0, 1, 0);
        tessellator.addVertexWithUV(1, 0, 0, 1, 1);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 1, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
    }
    if (metadata == 1) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 1);

        tessellator.addVertexWithUV(1, 1, 0, 1, 0);
        tessellator.addVertexWithUV(1, 0, 0, 1, 1);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 1, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 0, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 0);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
    }
    if (metadata == 0) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 0);

        tessellator.addVertexWithUV(0, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 1, 1, 0);
        tessellator.addVertexWithUV(0, 1, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 1);

        tessellator.addVertexWithUV(1, 1, 0, 1, 0);
        tessellator.addVertexWithUV(1, 0, 0, 1, 1);
        tessellator.addVertexWithUV(0, 0, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);

        tessellator.addVertexWithUV(1, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 0, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 0, 0, 0);
        tessellator.addVertexWithUV(1, 0, 0, 0, 1);

        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 1, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
    }
    if (metadata == 8) {
        this.bindTexture(texterwasher);
        tessellator.addVertexWithUV(0, 1, 1, 1, 0);
        tessellator.addVertexWithUV(1, 1, 1, 1, 1);
        tessellator.addVertexWithUV(1, 1, 0, 0, 1);
        tessellator.addVertexWithUV(0, 1, 0, 0, 0);
    }
    tessellator.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.professorvennie.machinerycraft.machines.windmill.TileEnitityRendererwindmillGround.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    GL11.glPushMatrix();/* w  ww. j a  v  a2  s. c  o  m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texterwindmillground);
    tessellator.startDrawingQuads();
    {
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 0) {
            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));
        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 1) {
            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (32),
                    1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0, 1F / textureWidth * (32),
                    1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, pixel * 14, 0.5, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (32));

            tessellator.addVertexWithUV(0.5, 0, pixel * 8, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, pixel * 14, pixel * 8, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, pixel * 8, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, 0, pixel * 8, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(pixel * 8, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(pixel * 8, pixel * 14, 0, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(pixel * 8, pixel * 14, 0.5, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(pixel * 8, 0, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0.5, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, 0, 0.5, 1F / textureWidth * (8 + 16), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * (8 + 16), 1F / textureHeight * (8 + 16));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 2) {
            tessellator.addVertexWithUV(0.5, pixel * 14, 1, 1F / textureWidth * (32),
                    1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0, 1F / textureWidth * (32), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (8));
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (8 + 16));

            tessellator.addVertexWithUV(pixel * 8, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(pixel * 8, pixel * 14, 0, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(pixel * 8, pixel * 14, 1, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(pixel * 8, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0.5, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0.5, 0, 1, 1F / textureWidth * (32), 1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * (8 + 16), 1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * (8 + 16), 1F / textureHeight * (8));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 3) {
            tessellator.addVertexWithUV(0.5, pixel * 14, 1, 1F / textureWidth * (32), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 0.5, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (8));

            tessellator.addVertexWithUV(pixel * 8, 0, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(pixel * 8, pixel * 14, 0.5, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(pixel * 8, pixel * 14, 1, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(pixel * 8, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0, 0, pixel * 8, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, pixel * 14, pixel * 8, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, pixel * 8, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, 0, pixel * 8, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, 0, 1, 1F / textureWidth * (32), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * (8 + 16), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0, 0, 0.5, 1F / textureWidth * (8 + 16), 1F / textureHeight * (0));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 4) {
            tessellator.addVertexWithUV(1, pixel * 14, 0.5, 1F / textureWidth * (24),
                    1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (24),
                    1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * (8),
                    1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, pixel * 14, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, pixel * 8, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, pixel * 14, pixel * 8, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, pixel * 8, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, 0, pixel * 8, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (24), 1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(1, 0, 0.5, 1F / textureWidth * (24), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, 0, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * (8), 1F / textureHeight * (8 + 16));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 5) {
            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (8 + 16),
                    1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (8 + 16), 1F / textureHeight * 8);
            tessellator.addVertexWithUV(0, pixel * 14, 0, 1F / textureWidth * 8, 1F / textureHeight * 8);
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * 8, 1F / textureHeight * (8 + 16));

            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (8 + 16), 1F / textureHeight * 8);
            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (8 + 16), 1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * 8, 1F / textureHeight * (8 + 16));
            tessellator.addVertexWithUV(0, 0, 0, 1F / textureWidth * 8, 1F / textureHeight * 8);

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 6) {
            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (24), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(1, pixel * 14, 0.5, 1F / textureWidth * (24), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0, pixel * 14, 1, 1F / textureWidth * (8), 1F / textureHeight * (8));

            tessellator.addVertexWithUV(0, 0, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0, pixel * 14, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, pixel * 14, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, 0, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 0.5, 1F / textureWidth * (24), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (24), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0, 0, 1, 1F / textureWidth * (8), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0, 0, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (0));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 7) {
            tessellator.addVertexWithUV(1, pixel * 14, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (8), 1F / textureHeight * (24));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0, 1F / textureWidth * (0), 1F / textureHeight * (24));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (0),
                    1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, pixel * 8, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(1, pixel * 14, pixel * 8, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, pixel * 8, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, 0, pixel * 8, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0.5, pixel * 14, 0, 1F / textureWidth * (32),
                    1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (0),
                    1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (8), 1F / textureHeight * (24));
            tessellator.addVertexWithUV(1, 0, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, 0, 0, 1F / textureWidth * (0), 1F / textureHeight * (24));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 8) {
            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (8), 1F / textureHeight * (24));
            tessellator.addVertexWithUV(1, pixel * 14, 0, 1F / textureWidth * (8), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0, 1F / textureWidth * (0), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0.5, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (24));

            tessellator.addVertexWithUV(0.5, pixel * 14, 0, 1F / textureWidth * (32),
                    1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, 0, 0, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 0, 1F / textureWidth * (8), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (8), 1F / textureHeight * (24));
            tessellator.addVertexWithUV(0.5, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (24));
            tessellator.addVertexWithUV(0.5, 0, 0, 1F / textureWidth * (0), 1F / textureHeight * (8));

        }
        if (tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord) == 9) {
            tessellator.addVertexWithUV(1, pixel * 14, 1, 1F / textureWidth * (8), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(1, pixel * 14, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (0),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (8));

            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (32),
                    1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, pixel * 14, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, 0, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(0.5, pixel * 14, 0.5, 1F / textureWidth * (32),
                    1F / textureHeight * (32));
            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (32), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(0.5, pixel * 14, 1, 1F / textureWidth * (0), 1F / textureHeight * (32));

            tessellator.addVertexWithUV(1, 0, 0.5, 1F / textureWidth * (8), 1F / textureHeight * (0));
            tessellator.addVertexWithUV(1, 0, 1, 1F / textureWidth * (8), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0.5, 0, 1, 1F / textureWidth * (0), 1F / textureHeight * (8));
            tessellator.addVertexWithUV(0.5, 0, 0.5, 1F / textureWidth * (0), 1F / textureHeight * (0));

        }
    }
    tessellator.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.professorvennie.machinerycraft.machines.windmill.TileEntityRendererwindmill.java

License:Creative Commons License

public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    int x1 = tileentity.xCoord;
    int y1 = tileentity.yCoord;
    int z1 = tileentity.zCoord;
    while (tileentity.getWorldObj().getBlockMetadata(x1, y1, z1) < 7
            && tileentity.getWorldObj().getBlock(x1, y1, z1).equals(ModBlocks.windmill)) {
        y1++;/*  w ww .j av  a 2s.  c o m*/
    }

    int direction = tileentity.getWorldObj().getBlockMetadata(x1, y1, z1) - 8;
    int metadata = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
            tileentity.zCoord);

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    GL11.glTranslatef(0.5F, 0, 0.5F);
    GL11.glRotatef(direction * 90, 0, 1, 0);
    GL11.glTranslatef(-0.5F, 0, -0.5F);

    if (metadata == 1) {
        TileEntity cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord - 1, tileentity.yCoord,
                tileentity.zCoord);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.EAST);

        cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord + 1, tileentity.yCoord,
                tileentity.zCoord);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.WEST);

        cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord + 1);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.SOUTH);

        cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord - 1);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.NORTH);
    }

    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texterwindmill);
    tessellator.startDrawingQuads();
    {

        if (metadata > 0 && metadata < 7) {
            tessellator.addVertexWithUV((8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 0, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));

            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));

            tessellator.addVertexWithUV((8) / 2 * pixel, 0, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));

            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));
        }
        if (metadata > 7) {
        }
    }
    tessellator.draw();

    if (metadata > 7)
        drawRoatar(tileentity);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.professorvennie.machinerycraft.machines.windmill.TileEntityRendererwindmill.java

License:Creative Commons License

private void drawRoatar(TileEntity tileentity) {
    TileEntityWindmill windmill = (TileEntityWindmill) tileentity.getWorldObj().getTileEntity(tileentity.xCoord,
            tileentity.yCoord, tileentity.zCoord);
    GL11.glTranslatef(0, 0.5F, 0.5F);
    GL11.glRotatef(windmill.rotaion, 1, 0, 0);
    GL11.glTranslatef(0, -0.5F, -0.5F);//  www. j  a  va  2 s  .  c  o  m

    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texterwindmill);
    tessellator.startDrawingQuads();
    {
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 2.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 2.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 2.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 2.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, -1.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, -1.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, -1.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, -1.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
    }
    tessellator.draw();
}

From source file:com.projectzed.mod.renderer.FluidTankItemRenderer.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    tess.startDrawingQuads();/*from   ww  w .  j  a  v a 2 s.  c  o  m*/

    // adjust rendering space to match what caller expects
    boolean mustTranslate = false;
    switch (type) {
    case EQUIPPED:
    case EQUIPPED_FIRST_PERSON: {
        break; // caller expects us to render over [0,0,0] to [1,1,1], no translation necessary
    }
    case ENTITY:
    case INVENTORY: {
        // translate our coordinates so that [0,0,0] to [1,1,1] translates to the [-0.5, -0.5, -0.5] to [0.5, 0.5, 0.5] expected by the caller.
        GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
        mustTranslate = true; // must undo the translation when we're finished rendering

        break;
    }
    default:
        break; // never here
    }

    // xpos face blue
    IIcon icon = item.getItem().getIconFromDamage(5);
    tess.setNormal(0.0f, 1.0f, 0.0f);
    tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 1.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 0.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(1f - calc, 0.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(1f - calc, 1.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // xneg face purple
    icon = item.getItem().getIconFromDamage(4);
    tess.addVertexWithUV(calc, 0.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(calc, 1.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 1.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // zneg face white
    icon = item.getItem().getIconFromDamage(2);
    tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // zpos face green
    icon = item.getItem().getIconFromDamage(3);
    tess.addVertexWithUV(1.0f - calc, 0.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(1.0f - calc, 1.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 1.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 0.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // ypos face red
    icon = item.getItem().getIconFromDamage(1);
    tess.addVertexWithUV(1.0f - calc, 1.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(1.0f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 1.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // yneg face yellow
    icon = item.getItem().getIconFromDamage(0);
    tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(1.0f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(1.0f - calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(1.0f - calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(1.0f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    tess.draw();

    if (mustTranslate)
        GL11.glTranslatef(0.5f, 0.5f, 0.5f);
}

From source file:com.projectzed.mod.renderer.ThickenedGlassItemRenderer.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    tess.startDrawingQuads();// w w w.  j a  v  a 2 s.co  m

    // adjust rendering space to match what caller expects
    boolean mustTranslate = false;
    switch (type) {
    case EQUIPPED:
        renderInside = true;
        break;
    case EQUIPPED_FIRST_PERSON: {
        renderInside = true;
        break; // caller expects us to render over [0,0,0] to [1,1,1], no translation necessary
    }
    case ENTITY:
        renderInside = true;
        break;
    case INVENTORY: {
        // translate our coordinates so that [0,0,0] to [1,1,1] translates to the [-0.5, -0.5, -0.5] to [0.5, 0.5, 0.5] expected by the caller.
        GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
        mustTranslate = true; // must undo the translation when we're finished rendering
        renderInside = false;

        break;
    }
    default:
        renderInside = true;
        break; // never here
    }

    // xpos face blue
    IIcon icon = item.getItem().getIconFromDamage(5);

    tess.setNormal(0.0f, 1.0f, 0.0f);
    tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 1.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 0.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(1f - calc, 0.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(1f - calc, 1.0, 1f - calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // xneg face purple
    icon = item.getItem().getIconFromDamage(4);
    tess.addVertexWithUV(calc, 0.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(calc, 1.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 1.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, 1f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // zneg face white
    icon = item.getItem().getIconFromDamage(2);
    tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(1f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(1f - calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // zpos face green
    icon = item.getItem().getIconFromDamage(3);
    tess.addVertexWithUV(1.0f - calc, 0.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(1.0f - calc, 1.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 1.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 0.0, 1.0 - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // ypos face red
    icon = item.getItem().getIconFromDamage(1);
    tess.addVertexWithUV(1.0f - calc, 1.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(1.0f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(calc, 1.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(calc, 1.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 1.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(1.0f - calc, 1.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    // yneg face yellow
    icon = item.getItem().getIconFromDamage(0);
    tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
    tess.addVertexWithUV(1.0f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
    tess.addVertexWithUV(1.0f - calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());

    if (renderInside) {
        tess.addVertexWithUV(1.0f - calc, 0.0, 1.0f - calc, (double) icon.getMinU(), (double) icon.getMaxV());
        tess.addVertexWithUV(1.0f - calc, 0.0, calc, (double) icon.getMinU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, calc, (double) icon.getMaxU(), (double) icon.getMinV());
        tess.addVertexWithUV(calc, 0.0, 1.0f - calc, (double) icon.getMaxU(), (double) icon.getMaxV());
    }

    tess.draw();

    if (mustTranslate)
        GL11.glTranslatef(0.5f, 0.5f, 0.5f);
}

From source file:com.runescape.client.revised.editor.modelviewer.Model3D.java

License:Open Source License

public void render(final float x, final float y, final float z, final float rx, final float ry, final float rz,
        final float sx, final float sy, final float sz) {
    GL11.glLoadIdentity();//from w ww.ja  va 2s.c o  m
    GL11.glTranslatef(x, y, z);
    GL11.glRotatef(rx, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(ry, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(rz, 0.0F, 0.0F, 1.0F);
    GL11.glScalef(sx, sy, sz);
    final short[] tri_x = this.triangle_viewspace_x;
    final short[] tri_y = this.triangle_viewspace_y;
    final short[] tri_z = this.triangle_viewspace_z;
    // final short[] tex_map_x = this.texture_map_x;
    // final short[] tex_map_y = this.texture_map_y;
    // final short[] tex_map_z = this.texture_map_z;
    final short[] textures = this.textures;
    final int[] vertices_x = this.vertices_x;
    final int[] vertices_y = this.vertices_y;
    final int[] vertices_z = this.vertices_z;
    final short[] colors = this.colors;
    final float model_scale = 4.0F;
    final float texture_scale = 1.0F;
    if (this.pointers != null) {
        //glEnable(GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    }
    Texture texture = null;
    for (int triangle = 0; triangle != this.triangle_count; ++triangle) {
        if ((this.alpha != null) && (this.alpha[triangle] == -1)) {
            continue;
        }
        final int point_a = tri_x[triangle];
        final int point_b = tri_y[triangle];
        final int point_c = tri_z[triangle];
        final int color = Model.hsl2rgb[colors[triangle] & 0xffff];
        int triangle_type;
        if (this.face_fill_attributes == null) {
            triangle_type = 0;
        } else {
            triangle_type = this.face_fill_attributes[triangle] & 3;
        }
        if ((textures != null) && (textures[triangle] != -1)) {
            final int id = textures[triangle] & 0xffff;
            if (ModelConstants.ENABLE_MODEL_TEXTURES && ((texture == null) && (id != -1))) {
                texture = TextureCache.get(id);
            }
            if (texture != null) {
                texture.bind();
            }
        }
        final boolean textured = ModelConstants.ENABLE_MODEL_TEXTURES && (texture != null);
        GL11.glBegin(GL11.GL_TRIANGLES);
        GL11.glColor4ub((byte) (color >>> 16), (byte) (color >>> 8), (byte) color,
                (byte) (this.alpha == null ? 0xff : ~this.alpha[triangle]));
        switch (triangle_type) {
        case 0://shaded triangle
        case 1://flat triangle
            if (textured) {
                GL11.glTexCoord2f(0.0F, 0.0F);
            }
            GL11.glVertex3f(vertices_x[point_a] / model_scale, vertices_y[point_a] / model_scale,
                    vertices_z[point_a] / model_scale);
            if (textured) {
                GL11.glTexCoord2f(0.0F, texture_scale / model_scale);
            }
            GL11.glVertex3f(vertices_x[point_b] / model_scale, vertices_y[point_b] / model_scale,
                    vertices_z[point_b] / model_scale);
            if (textured) {
                GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale);
            }
            GL11.glVertex3f(vertices_x[point_c] / model_scale, vertices_y[point_c] / model_scale,
                    vertices_z[point_c] / model_scale);
            break;
        case 2://textured?
        case 3://textured?
            final int ptr = this.face_fill_attributes[triangle] >> 2;
            final int tex_point_a = this.texture_map_x[ptr];
            final int tex_point_b = this.texture_map_y[ptr];
            final int tex_point_c = this.texture_map_z[ptr];
            GL11.glTexCoord2f(0.0F, 0.0F);
            GL11.glVertex3f(vertices_x[tex_point_a] / model_scale, vertices_y[tex_point_a] / model_scale,
                    vertices_z[tex_point_a] / model_scale);
            GL11.glTexCoord2f(0.0F, texture_scale / model_scale);
            GL11.glVertex3f(vertices_x[tex_point_b] / model_scale, vertices_y[tex_point_b] / model_scale,
                    vertices_z[tex_point_b] / model_scale);
            GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale);
            GL11.glVertex3f(vertices_x[tex_point_c] / model_scale, vertices_y[tex_point_c] / model_scale,
                    vertices_z[tex_point_c] / model_scale);
            break;
        }
        GL11.glEnd();
    }
    if (texture != null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    }
}

From source file:com.rvantwisk.cnctools.controls.opengl.OpenGLRenderer.java

License:Open Source License

protected void drawAxis(float length) {
    GL11.glPushMatrix();//from  w  ww .  j  ava 2  s . c  om
    this.viewModel.ui_transform(length + length / 2.0f);

    float[][] axis = { { length, 0.0f, 0.0f }, { 0.0f, -length, 0.0f }, { 0.0f, 0.0f, length } };
    float[][] colors = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.5f, 1.0f } };
    String[] names = { "X", "Y", "Z" };

    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < 3; i++) {
        GL11.glColor3f(colors[i][0], colors[i][1], colors[i][2]);
        GL11.glVertex3f(0.0f, 0.0f, 0.0f);
        GL11.glVertex3f(axis[i][0], axis[i][1], axis[i][2]);
    }
    GL11.glEnd();

    // TODO optmize text rendering, lack of glutBitmapCharacter forces me to do it differently.
    for (int i = 0; i < 3; i++) {
        GL11.glPushMatrix();
        GL11.glColor3f(colors[i][0], colors[i][1], colors[i][2]);

        // http://breadmilkbeercigarettes.com/bmbc/shelves/users/bbb/src/java/SpinningTextureCube.php
        GL11.glTranslatef(Math.round(axis[i][0]), Math.round(axis[i][1]), Math.round(axis[i][2]));
        GL11.glRotatef(camera.getElevation() + 90f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(-camera.getAzimuth(), 0.0f, 1.0f, 0.0f);
        SimpleText.drawString(names[i], 0.0f, 0.0f, 0.0f);

        //            GL11.glRasterPos3f(Math.round(axis[i][0]), Math.round(axis[i][1]), Math.round(axis[i][2]));
        //            SimpleText.drawString(names[i], 0, 0);

        GL11.glPopMatrix();

    }

    GL11.glPopMatrix();
}

From source file:com.rvantwisk.cnctools.opengl.View2D.java

License:Open Source License

@Override
public void ui_transform(float length) {
    GL11.glTranslatef(length, length, 0.0f);
    GL11.glRotatef(camera.getAzimuth(), 0.0f, 0.0f, 1.0f);
}