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:de.sanandrew.mods.varietychests.client.renderer.TileEntityCustomChestRenderer.java

License:Creative Commons License

public void renderChestAt(TileEntityCustomChest chest, double x, double y, double z, float partTicks,
        int pass) {
    int meta;//from w  w  w. ja va2  s .  c  o m

    if (!chest.hasWorldObj()) {
        meta = 0;
    } else {
        Block block = chest.getBlockType();
        meta = chest.getBlockMetadata();

        if (block instanceof BlockCustomChest && meta == 0) {
            try {
                ((BlockCustomChest) block).func_149954_e(chest.getWorldObj(), chest.xCoord, chest.yCoord,
                        chest.zCoord);
            } catch (ClassCastException e) {
                FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest", chest.xCoord,
                        chest.yCoord, chest.zCoord);
            }

            meta = chest.getBlockMetadata();
        }

        chest.checkForAdjacentChests();
    }

    if (chest.adjacentChestZNeg == null && chest.adjacentChestXNeg == null) {
        ModelChest modelchest;

        if (chest.adjacentChestXPos == null && chest.adjacentChestZPos == null) {
            modelchest = this.modelSingleChest;

            if (pass == 0) {
                this.bindTexture(chest.getChestType().textureSng);
            } else {
                if (chest.blockType == VarietyChests.customGlowingChest) {
                    this.bindTexture(Textures.CHEST_GLOWMAP_SNG);
                } else if (chest.blockType == VarietyChests.customTrapChest) {
                    this.bindTexture(Textures.CHEST_TRAPMAP_SNG);
                }
            }

        } else {
            modelchest = this.modelDoubleChest;

            if (pass == 0) {
                this.bindTexture(chest.getChestType().textureDbl);
            } else {
                if (chest.blockType == VarietyChests.customGlowingChest) {
                    this.bindTexture(Textures.CHEST_GLOWMAP_DBL);
                } else if (chest.blockType == VarietyChests.customTrapChest) {
                    this.bindTexture(Textures.CHEST_TRAPMAP_DBL);
                }
            }
        }

        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        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 short1 = 0;

        if (meta == 2) {
            short1 = 180;
        }

        if (meta == 3) {
            short1 = 0;
        }

        if (meta == 4) {
            short1 = 90;
        }

        if (meta == 5) {
            short1 = -90;
        }

        if (meta == 2 && chest.adjacentChestXPos != null) {
            GL11.glTranslatef(1.0F, 0.0F, 0.0F);
        }

        if (meta == 5 && chest.adjacentChestZPos != null) {
            GL11.glTranslatef(0.0F, 0.0F, -1.0F);
        }

        GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float f1 = chest.prevLidAngle + (chest.lidAngle - chest.prevLidAngle) * partTicks;
        float f2;

        if (chest.adjacentChestZNeg != null) {
            f2 = chest.adjacentChestZNeg.prevLidAngle
                    + (chest.adjacentChestZNeg.lidAngle - chest.adjacentChestZNeg.prevLidAngle) * partTicks;

            if (f2 > f1) {
                f1 = f2;
            }
        }

        if (chest.adjacentChestXNeg != null) {
            f2 = chest.adjacentChestXNeg.prevLidAngle
                    + (chest.adjacentChestXNeg.lidAngle - chest.adjacentChestXNeg.prevLidAngle) * partTicks;

            if (f2 > f1) {
                f1 = f2;
            }
        }

        f1 = 1.0F - f1;
        f1 = 1.0F - f1 * f1 * f1;
        modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
        if (pass == 1) {
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
            modelchest.renderAll();
            GL11.glDisable(GL11.GL_BLEND);
        } else {
            modelchest.renderAll();
        }
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:de.sanandrew.mods.varietychests.client.TileEntityCustomChestRenderer.java

License:Creative Commons License

public void renderTileEntityAt(TileEntityCustomChest chest, double x, double y, double z, float partTicks) {
    int meta;//from w  w  w  .  ja v a2  s  . c  o m

    if (!chest.hasWorldObj()) {
        meta = 0;
    } else {
        Block block = chest.getBlockType();
        meta = chest.getBlockMetadata();

        if (block instanceof BlockCustomChest && meta == 0) {
            try {
                ((BlockCustomChest) block).func_149954_e(chest.getWorldObj(), chest.xCoord, chest.yCoord,
                        chest.zCoord);
            } catch (ClassCastException e) {
                FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest", chest.xCoord,
                        chest.yCoord, chest.zCoord);
            }

            meta = chest.getBlockMetadata();
        }

        chest.checkForAdjacentChests();
    }

    if (chest.adjacentChestZNeg == null && chest.adjacentChestXNeg == null) {
        ModelChest modelchest;

        if (chest.adjacentChestXPos == null && chest.adjacentChestZPos == null) {
            modelchest = this.modelSingleChest;

            this.bindTexture(chest.getChestType().textureSng);
        } else {
            modelchest = this.modelDoubleChest;

            this.bindTexture(chest.getChestType().textureDbl);
        }

        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        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 short1 = 0;

        if (meta == 2) {
            short1 = 180;
        }

        if (meta == 3) {
            short1 = 0;
        }

        if (meta == 4) {
            short1 = 90;
        }

        if (meta == 5) {
            short1 = -90;
        }

        if (meta == 2 && chest.adjacentChestXPos != null) {
            GL11.glTranslatef(1.0F, 0.0F, 0.0F);
        }

        if (meta == 5 && chest.adjacentChestZPos != null) {
            GL11.glTranslatef(0.0F, 0.0F, -1.0F);
        }

        GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float f1 = chest.prevLidAngle + (chest.lidAngle - chest.prevLidAngle) * partTicks;
        float f2;

        if (chest.adjacentChestZNeg != null) {
            f2 = chest.adjacentChestZNeg.prevLidAngle
                    + (chest.adjacentChestZNeg.lidAngle - chest.adjacentChestZNeg.prevLidAngle) * partTicks;

            if (f2 > f1) {
                f1 = f2;
            }
        }

        if (chest.adjacentChestXNeg != null) {
            f2 = chest.adjacentChestXNeg.prevLidAngle
                    + (chest.adjacentChestXNeg.lidAngle - chest.adjacentChestXNeg.prevLidAngle) * partTicks;

            if (f2 > f1) {
                f1 = f2;
            }
        }

        f1 = 1.0F - f1;
        f1 = 1.0F - f1 * f1 * f1;
        modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
        modelchest.renderAll();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:edu.csun.ecs.cs.multitouchj.ui.control.FramedControl.java

License:Apache License

public void render() {
    // render with no texture
    Texture texture = getTexture();//  w  w  w.j a v  a  2s  .c om
    setTexture((Texture) null);

    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    super.render();
    GL11.glPopMatrix();

    setTexture(texture);

    // rendering texture
    if ((!isVisible()) || (texture == null)) {
        return;
    }

    Size controlSize = getSize();
    Size imageSize = texture.getImage().getSize();
    float margin = getMargin();
    if ((margin >= controlSize.getWidth()) || (margin >= controlSize.getHeight())) {
        margin = 0.0f;
    }

    Color color = getColor();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(((float) color.getRed() / 255.0f), ((float) color.getGreen() / 255.0f),
            ((float) color.getBlue() / 255.0f), getOpacity());

    Point position = getOpenGlPosition();
    float halfWidth = (controlSize.getWidth() / 2.0f);
    float halfHeight = (controlSize.getHeight() / 2.0f);
    GL11.glTranslatef(position.getX(), position.getY(), 0.0f);

    float rotation = OpenGlUtility.getOpenGlRotation(getRotation());
    GL11.glRotatef(rotation, 0.0f, 0.0f, 1.0f);

    // render texture
    GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
    GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue());

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(((-1 * halfWidth) + margin), ((-1 * halfHeight) + margin), 0.0f);

    GL11.glTexCoord2f(imageSize.getWidth(), 0.0f);
    GL11.glVertex3f((halfWidth - margin), ((-1 * halfHeight) + margin), 0.0f);

    GL11.glTexCoord2f(imageSize.getWidth(), imageSize.getHeight());
    GL11.glVertex3f((halfWidth - margin), (halfHeight - margin), 0.0f);

    GL11.glTexCoord2f(0.0f, imageSize.getHeight());
    GL11.glVertex3f(((-1 * halfWidth) + margin), (halfHeight - margin), 0.0f);
    GL11.glEnd();
}

From source file:edu.csun.ecs.cs.multitouchj.ui.control.TexturedControl.java

License:Apache License

public void render() {
    if (!isVisible()) {
        return;/*from   w  w w .  j av a2  s  . c o  m*/
    }

    Size controlSize = getSize();
    Size imageSize = null;
    if (texture != null) {
        imageSize = texture.getImage().getSize();
    }

    Color color = getColor();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(((float) color.getRed() / 255.0f), ((float) color.getGreen() / 255.0f),
            ((float) color.getBlue() / 255.0f), getOpacity());

    Point position = getOpenGlPosition();
    float halfWidth = (controlSize.getWidth() / 2.0f);
    float halfHeight = (controlSize.getHeight() / 2.0f);
    GL11.glTranslatef(position.getX(), position.getY(), 0.0f);

    float rotation = OpenGlUtility.getOpenGlRotation(getRotation());
    GL11.glRotatef(rotation, 0.0f, 0.0f, 1.0f);

    if (texture != null) {
        GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
        GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue());
    } else {
        GL11.glDisable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
    }

    // bl -> br -> tr -> tl
    GL11.glBegin(GL11.GL_QUADS);
    if (texture != null) {
        GL11.glTexCoord2f(0.0f, 0.0f);
    }
    GL11.glVertex3f((-1 * halfWidth), (-1 * halfHeight), 0.0f);

    if (texture != null) {
        GL11.glTexCoord2f(imageSize.getWidth(), 0.0f);
    }
    GL11.glVertex3f(halfWidth, (-1 * halfHeight), 0.0f);

    if (texture != null) {
        GL11.glTexCoord2f(imageSize.getWidth(), imageSize.getHeight());
    }
    GL11.glVertex3f(halfWidth, halfHeight, 0.0f);

    if (texture != null) {
        GL11.glTexCoord2f(0.0f, imageSize.getHeight());
    }
    GL11.glVertex3f((-1 * halfWidth), halfHeight, 0.0f);
    GL11.glEnd();
}

From source file:electricMagicTools.tombenpotter.electricmagictools.client.renderer.RenderLaser.java

License:Open Source License

public void renderArrow(EntityLaser entityLaser, double par2, double par4, double par6, float par8,
        float par9) {

    this.bindEntityTexture(entityLaser);
    GL11.glPushMatrix();/*from   w  w w  . j  av  a2 s.  co m*/
    GL11.glTranslatef((float) par2, (float) par4, (float) par6);
    GL11.glRotatef(entityLaser.prevRotationYaw + (entityLaser.rotationYaw - entityLaser.prevRotationYaw) * par9
            - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(
            entityLaser.prevRotationPitch + (entityLaser.rotationPitch - entityLaser.prevRotationPitch) * par9,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.4F;
    float f3 = 0.7F;
    float f4 = (float) (0 + b0 * 10) / 32.0F;
    float f5 = (float) (5 + b0 * 10) / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = (float) (5 + b0 * 10) / 32.0F;
    float f9 = (float) (10 + b0 * 10) / 32.0F;
    float f10 = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(f10, f10, f10);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();
    GL11.glNormal3f(-f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5);
        tessellator.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:enderglove.client.renderers.item.ItemEnderGloveRenderer.java

License:Minecraft Mod Public

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    switch (type) {
    case EQUIPPED_FIRST_PERSON: {
        // Minecraft mc = Minecraft.getMinecraft();

        /*//from w  w w  . j  ava  2s. com
         * if (mc.thePlayer.inventory.hasItem(Items.ender_eye)) { GL11.glPushMatrix(); //int slot =
         * InventoryHelper.isInPlayerInventory(Minecraft.getMinecraft().thePlayer, Items.ender_eye); //ItemStack is =
         * Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(slot); //renderEnderEye(item, is); //
         * Minecraft.getMinecraft().renderEngine.bindTexture(gloveTex); // this.modelGlove.render((Entity)data[1], 0.0F, 0.0F, 0.0F, // 0.0F, 0.0F,
         * 0.0625F); int slot = InventoryHelper.isInPlayerInventory(Minecraft.getMinecraft().thePlayer, Items.ender_eye); ItemStack is =
         * Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(slot); renderEnderEye(item, is);
         * Minecraft.getMinecraft().renderEngine.bindTexture(gloveTex); this.modelGlove.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
         * GL11.glPopMatrix(); } else {
         */
        GL11.glPushMatrix();
        Minecraft.getMinecraft().renderEngine.bindTexture(this.gloveTex);
        // GL11.glTranslatef(1, 2, 1);
        // GL11.glScalef(3F, 3F, 3F);
        // GL11.glRotatef(45, 1, 0, 0);
        this.modelGlove.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.625F);
        GL11.glPopMatrix();
        // }
    }
    case EQUIPPED: {
        // Minecraft mc = Minecraft.getMinecraft();

        /*
         * if (mc.thePlayer.inventory.hasItem(Items.ender_eye)) { GL11.glPushMatrix(); int slot =
         * InventoryHelper.isInPlayerInventory(Minecraft.getMinecraft().thePlayer, Items.ender_eye); ItemStack is =
         * Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(slot); renderEnderEye(item, is);
         * Minecraft.getMinecraft().renderEngine.bindTexture(gloveTex); this.modelGlove.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
         * GL11.glPopMatrix(); } else {
         */
        GL11.glPushMatrix();
        Minecraft.getMinecraft().renderEngine.bindTexture(this.gloveTex);
        GL11.glTranslatef(1, 2, 1);
        // GL11.glScalef(-0.80F, -0.80F, -0.80F);
        GL11.glRotatef(-65, 1, 0, 0);
        GL11.glRotatef(-25, 0, 1, 0);
        GL11.glRotatef(-10, 0, 0, 1);
        this.modelGlove.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
        GL11.glPopMatrix();
        // }
    }
    default:
        break;
    }
}

From source file:eplus.renders.TableEntityItemRenderer.java

License:LGPL

/**
 * Renders the item/*from  w ww. ja  v a  2  s .  c o m*/
 */
public void doRenderItem(EntityItem par1EntityItem, double par2, double par4, double par6, float par8,
        float par9) {
    this.random.setSeed(187L);
    ItemStack itemstack = par1EntityItem.getEntityItem();

    if (itemstack.getItem() != null) {
        GL11.glPushMatrix();
        float f2 = shouldBob()
                ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F
                        + 0.1F
                : 0F;
        float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart)
                * (180F / (float) Math.PI);
        byte b0 = getMiniBlockCount(itemstack);

        GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        int i;
        float f4;
        float f5;
        float f6;

        Block block = null;
        if (itemstack.itemID < Block.blocksList.length) {
            block = Block.blocksList[itemstack.itemID];
        }

        if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random,
                renderManager.renderEngine, renderBlocks)) {
            ;
        } else if (itemstack.getItemSpriteNumber() == 0 && block != null
                && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType())) {
            GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);

            if (renderInFrame) {
                GL11.glScalef(1.25F, 1.25F, 1.25F);
                GL11.glTranslatef(0.0F, 0.05F, 0.0F);
                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
            }

            this.loadTexture("/terrain.png");
            float f7 = 0.25F;
            int j = block.getRenderType();

            if (j == 1 || j == 19 || j == 12 || j == 2) {
                f7 = 0.5F;
            }

            GL11.glScalef(f7, f7, f7);

            for (i = 0; i < b0; ++i) {
                GL11.glPushMatrix();

                if (i > 0) {
                    f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
                    f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
                    f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
                    GL11.glTranslatef(f5, f4, f6);
                }

                f5 = 1.0F;
                this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5);
                GL11.glPopMatrix();
            }
        } else {
            float f8;

            if (itemstack.getItem().requiresMultipleRenderPasses()) {
                if (renderInFrame) {
                    GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
                    GL11.glTranslatef(0.0F, -0.05F, 0.0F);
                } else {
                    GL11.glScalef(0.5F, 0.5F, 0.5F);
                }

                this.loadTexture("/gui/items.png");

                for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) {
                    this.random.setSeed(187L);
                    Icon icon = itemstack.getItem().getIcon(itemstack, k);
                    f8 = 1.0F;

                    if (this.renderWithColor) {
                        i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k);
                        f5 = (float) (i >> 16 & 255) / 255.0F;
                        f4 = (float) (i >> 8 & 255) / 255.0F;
                        f6 = (float) (i & 255) / 255.0F;
                        GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
                        this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8);
                    } else {
                        this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F);
                    }
                }
            } else {
                if (renderInFrame) {
                    GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
                    GL11.glTranslatef(0.0F, -0.05F, 0.0F);
                } else {
                    GL11.glScalef(0.5F, 0.5F, 0.5F);
                }

                Icon icon1 = itemstack.getIconIndex();

                if (itemstack.getItemSpriteNumber() == 0) {
                    this.loadTexture("/terrain.png");
                } else {
                    this.loadTexture("/gui/items.png");
                }

                if (this.renderWithColor) {
                    int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0);
                    f8 = (float) (l >> 16 & 255) / 255.0F;
                    float f9 = (float) (l >> 8 & 255) / 255.0F;
                    f5 = (float) (l & 255) / 255.0F;
                    f4 = 1.0F;
                    this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
                } else {
                    this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
                }
            }
        }

        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }
}

From source file:eplus.renders.TableEntityItemRenderer.java

License:LGPL

/**
 * Renders a dropped item//from ww w .  j a v  a 2 s . c o  m
 */
private void renderDroppedItem(EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5,
        float par6, float par7) {
    Tessellator tessellator = Tessellator.instance;

    if (par2Icon == null) {
        par2Icon = this.renderManager.renderEngine
                .getMissingIcon(par1EntityItem.getEntityItem().getItemSpriteNumber());
    }

    float f4 = par2Icon.getMinU();
    float f5 = par2Icon.getMaxU();
    float f6 = par2Icon.getMinV();
    float f7 = par2Icon.getMaxV();
    float f8 = 1.0F;
    float f9 = 0.5F;
    float f10 = 0.25F;
    float f11;

    GL11.glPushMatrix();

    if (renderInFrame) {
        GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
    } else {
        GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart)
                * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
    }

    float f12 = 0.0625F;
    f11 = 0.021875F;
    ItemStack itemstack = par1EntityItem.getEntityItem();
    int j = itemstack.stackSize;
    byte b0 = getMiniItemCount(itemstack);

    GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));

    for (int k = 0; k < b0; ++k) {
        GL11.glTranslatef(0.0F, 0.0F, f12 + f11);
        // Makes items offset when in 3D, like when in 2D, looks much
        // better. Considered a vanilla bug...
        if (k > 0 && shouldSpreadItems()) {
            float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            GL11.glTranslatef(x, y, f12 + f11);
        } else {
            GL11.glTranslatef(0f, 0f, f12 + f11);
        }

        if (itemstack.getItemSpriteNumber() == 0) {
            this.loadTexture("/terrain.png");
        } else {
            this.loadTexture("/gui/items.png");
        }

        GL11.glColor4f(par5, par6, par7, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getSheetWidth(),
                par2Icon.getSheetHeight(), f12);

        if (itemstack != null && itemstack.hasEffect()) {
            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            this.renderManager.renderEngine.bindTexture("%blur%/misc/glint.png");
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            float f13 = 0.76F;
            GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glPushMatrix();
            float f14 = 0.125F;
            GL11.glScalef(f14, f14, f14);
            float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
            GL11.glTranslatef(f15, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glScalef(f14, f14, f14);
            f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
            GL11.glTranslatef(-f15, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
            GL11.glPopMatrix();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    GL11.glPopMatrix();

}

From source file:eplus.renders.TableEntityItemRenderer.java

License:LGPL

/**
 * Renders the item's icon or block into the UI at the specified position.
 */// w w w.  j  av  a 2 s  .co m
public void renderItemIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine,
        ItemStack par3ItemStack, int par4, int par5) {
    int k = par3ItemStack.itemID;
    int l = par3ItemStack.getItemDamage();
    Icon icon = par3ItemStack.getIconIndex();
    float f;
    float f1;
    float f2;

    Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null);
    if (par3ItemStack.getItemSpriteNumber() == 0 && block != null
            && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType())) {
        par2RenderEngine.bindTexture("/terrain.png");
        GL11.glPushMatrix();
        GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel);
        GL11.glScalef(10.0F, 10.0F, 10.0F);
        GL11.glTranslatef(1.0F, 0.5F, 1.0F);
        GL11.glScalef(1.0F, 1.0F, -1.0F);
        GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        int i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0);
        f2 = (float) (i1 >> 16 & 255) / 255.0F;
        f = (float) (i1 >> 8 & 255) / 255.0F;
        f1 = (float) (i1 & 255) / 255.0F;

        if (this.renderWithColor) {
            GL11.glColor4f(f2, f, f1, 1.0F);
        }

        GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
        this.itemRenderBlocks.useInventoryTint = this.renderWithColor;
        this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F);
        this.itemRenderBlocks.useInventoryTint = true;
        GL11.glPopMatrix();
    } else {
        int j1;

        if (Item.itemsList[k].requiresMultipleRenderPasses()) {
            GL11.glDisable(GL11.GL_LIGHTING);
            par2RenderEngine
                    .bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? "/terrain.png" : "/gui/items.png");

            for (j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) {
                Icon icon1 = Item.itemsList[k].getIcon(par3ItemStack, j1);
                int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1);
                f = (float) (k1 >> 16 & 255) / 255.0F;
                f1 = (float) (k1 >> 8 & 255) / 255.0F;
                float f3 = (float) (k1 & 255) / 255.0F;

                if (this.renderWithColor) {
                    GL11.glColor4f(f, f1, f3, 1.0F);
                }

                this.renderIcon(par4, par5, icon1, 16, 16);
            }

            GL11.glEnable(GL11.GL_LIGHTING);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);

            if (par3ItemStack.getItemSpriteNumber() == 0) {
                par2RenderEngine.bindTexture("/terrain.png");
            } else {
                par2RenderEngine.bindTexture("/gui/items.png");
            }

            if (icon == null) {
                icon = par2RenderEngine.getMissingIcon(par3ItemStack.getItemSpriteNumber());
            }

            j1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0);
            float f4 = (float) (j1 >> 16 & 255) / 255.0F;
            f2 = (float) (j1 >> 8 & 255) / 255.0F;
            f = (float) (j1 & 255) / 255.0F;

            if (this.renderWithColor) {
                GL11.glColor4f(f4, f2, f, 1.0F);
            }

            this.renderIcon(par4, par5, icon, 16, 16);
            GL11.glEnable(GL11.GL_LIGHTING);
        }
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:eplus.renders.TileEnchantRenderer.java

License:LGPL

private void renderDefaultTable(TileEnchantTable tileentity, double d0, double d1, double d2, float f) {
    GL11.glPushMatrix();/*from   www  .  j a v a 2s  .c om*/
    GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 0.75F, (float) d2 + 0.5F);
    float f1 = (float) tileentity.tickCount + f;
    GL11.glTranslatef(0.0F, 0.1F + MathHelper.sin(f1 * 0.1F) * 0.01F, 0.0F);
    float f2;

    for (f2 = tileentity.bookRotation2
            - tileentity.bookRotationPrev; f2 >= (float) Math.PI; f2 -= ((float) Math.PI * 2F)) {
        ;
    }

    while (f2 < -(float) Math.PI) {
        f2 += ((float) Math.PI * 2F);
    }

    float f3 = tileentity.bookRotationPrev + f2 * f;
    GL11.glRotatef(-f3 * 180.0F / (float) Math.PI, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(80.0F, 0.0F, 0.0F, 1.0F);
    this.bindTextureByName("/item/book.png");
    float f4 = tileentity.pageFlipPrev + (tileentity.pageFlip - tileentity.pageFlipPrev) * f + 0.25F;
    float f5 = tileentity.pageFlipPrev + (tileentity.pageFlip - tileentity.pageFlipPrev) * f + 0.75F;
    f4 = (f4 - (float) MathHelper.truncateDoubleToInt((double) f4)) * 1.6F - 0.3F;
    f5 = (f5 - (float) MathHelper.truncateDoubleToInt((double) f5)) * 1.6F - 0.3F;

    if (f4 < 0.0F) {
        f4 = 0.0F;
    }

    if (f5 < 0.0F) {
        f5 = 0.0F;
    }

    if (f4 > 1.0F) {
        f4 = 1.0F;
    }

    if (f5 > 1.0F) {
        f5 = 1.0F;
    }

    float f6 = tileentity.bookSpreadPrev + (tileentity.bookSpread - tileentity.bookSpreadPrev) * f;
    GL11.glEnable(GL11.GL_CULL_FACE);
    this.enchantmentBook.render((Entity) null, f1, f4, f5, f6, 0.0F, 0.0625F);
    GL11.glPopMatrix();

}