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.pahimar.ee3.client.renderer.RenderUtils.java

License:LGPL

public static void renderRotatingBlockIntoGUI(FontRenderer fontRenderer, RenderEngine renderEngine,
        ItemStack stack, int x, int y, float zLevel, float scale) {

    RenderBlocks renderBlocks = new RenderBlocks();

    Block block = Block.blocksList[stack.itemID];
    renderEngine.bindTexture(Textures.VANILLA_BLOCK_TEXTURE_SHEET);
    GL11.glPushMatrix();//  www .  j av  a  2s  . c o  m
    GL11.glTranslatef(x - 2, y + 3, -3.0F + zLevel);
    GL11.glScalef(10.0F, 10.0F, 10.0F);
    GL11.glTranslatef(1.0F, 0.5F, 1.0F);
    GL11.glScalef(1.0F * scale, 1.0F * scale, -1.0F);
    GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(0F + 1 * rotationAngle, 0.0F, 1.0F, 0.0F);
    rotationAngle = (rotationAngle + 1) % 360;

    int var10 = Item.itemsList[stack.itemID].getColorFromItemStack(stack, 0);
    float var16 = (var10 >> 16 & 255) / 255.0F;
    float var12 = (var10 >> 8 & 255) / 255.0F;
    float var13 = (var10 & 255) / 255.0F;

    GL11.glColor4f(var16, var12, var13, 1.0F);

    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    renderBlocks.useInventoryTint = true;
    renderBlocks.renderBlockAsItem(block, stack.getItemDamage(), 1.0F);
    renderBlocks.useInventoryTint = true;
    GL11.glPopMatrix();
}

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityAlchemicalChestRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {

    if (tileEntity instanceof TileAlchemicalChest) {

        TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) tileEntity;
        ForgeDirection direction = null;

        if (tileAlchemicalChest.getWorldObj() != null) {
            direction = ForgeDirection.getOrientation(tileAlchemicalChest.getBlockMetadata());
        }/*from   www .  ja  v  a2  s. com*/

        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST);
        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 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 = tileAlchemicalChest.prevLidAngle
                + (tileAlchemicalChest.lidAngle - tileAlchemicalChest.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.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityAlchemyTableRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {

    if (tileEntity instanceof TileAlchemyTable) {
        // TODO Use the TileAlchemyTable to determine what circle to project on the server of the table
        TileAlchemyTable tileAlchemyTable = (TileAlchemyTable) tileEntity;

        GL11.glPushMatrix();/*from  ww w  .  j a v  a  2  s  .  c  o m*/
        GL11.glDisable(GL11.GL_LIGHTING);

        // Scale, Translate, Rotate
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + 1.0F);

        // Bind texture
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMY_TABLE);

        // Render
        modelAlchemyTable.render();

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

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityAludelRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {

    if (tileEntity instanceof TileAludel) {

        TileAludel tileAludel = (TileAludel) tileEntity;

        GL11.glPushMatrix();/*from   ww  w. j  a  v  a 2  s  .co  m*/
        GL11.glDisable(GL11.GL_LIGHTING);

        // Scale, Translate, Rotate
        scaleTranslateRotate(x, y, z, tileAludel.getOrientation());

        // Bind texture
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALUDEL);

        // Render
        modelAludel.render();

        GL11.glPopMatrix();

        /**
         * Render the ghost item inside of the Aludel, slowly spinning
         */
        GL11.glPushMatrix();

        TileEntity tileGlassBell = tileAludel.worldObj.getBlockTileEntity(tileAludel.xCoord,
                tileAludel.yCoord + 1, tileAludel.zCoord);

        if (tileGlassBell instanceof TileGlassBell) {
            if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null) {

                float scaleFactor = getGhostItemScaleFactor(
                        tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
                float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);

                EntityItem ghostEntityItem = new EntityItem(tileAludel.worldObj);
                ghostEntityItem.hoverStart = 0.0F;
                ghostEntityItem.setEntityItemStack(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));

                GL11.glTranslatef((float) x + 0.5F, (float) y + 1.25F, (float) z + 0.5F);
                GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
                GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);

                customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
            }
        }

        GL11.glPopMatrix();

        GL11.glEnable(GL11.GL_LIGHTING);
    }
}

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityCalcinatorRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {

    if (tileEntity instanceof TileCalcinator) {
        TileCalcinator tileCalcinator = (TileCalcinator) tileEntity;

        GL11.glPushMatrix();//  ww  w.j a  va2 s.c om
        GL11.glDisable(GL11.GL_LIGHTING);

        // Scale, Translate, Rotate
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 0.5F, (float) y + 0.0F, (float) z + 1.2F);
        GL11.glRotatef(45F, 0F, 1F, 0F);
        GL11.glRotatef(-90F, 1F, 0F, 0F);

        // Bind texture
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR);

        // Render
        modelCalcinator.renderPart("Calcinator");

        if (tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_INVENTORY_INDEX) != null) {
            modelCalcinator.renderPart("Dust");
        }

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

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityEnergyCondenserRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {

    if (tileEntity instanceof TileEnergyCondenser) {

        TileEnergyCondenser tileEnergyCondenser = (TileEnergyCondenser) tileEntity;
        ForgeDirection direction = null;

        if (tileEnergyCondenser.getWorldObj() != null) {
            direction = ForgeDirection.getOrientation(tileEnergyCondenser.getBlockMetadata());
        }//from w w  w.  j  av a 2s  . c o m

        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ENERGY_CONDENSER);
        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 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 = tileEnergyCondenser.prevLidAngle
                + (tileEnergyCondenser.lidAngle - tileEnergyCondenser.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.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityGlassBellRenderer.java

License:LGPL

private void renderGlassBellByOrientation(double x, double y, double z, ForgeDirection forgeDirection) {

    switch (forgeDirection) {
    case DOWN: {/*from  w w  w . j a  v  a  2s  .c o  m*/
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 0.0F, (float) y + 2.0F, (float) z + 0.0F);
        GL11.glRotatef(90F, 1F, 0F, 0F);
        return;
    }
    case UP: {
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 0.0F, (float) y + -1.0F, (float) z + 1.0F);
        GL11.glRotatef(-90F, 1F, 0F, 0F);
        return;
    }
    case NORTH: {
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 1.0F, (float) y + 0.0F, (float) z + 2.0F);
        GL11.glRotatef(180F, 0F, 1F, 0F);
        return;
    }
    case SOUTH: {
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + -1.0F);
        return;
    }
    case EAST: {
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + -1.0F, (float) y + 1.0F, (float) z + 1.0F);
        GL11.glRotatef(-90F, 0F, 0F, 1F);
        GL11.glRotatef(-90F, 1F, 0F, 0F);
        return;
    }
    case WEST: {
        GL11.glScalef(1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x + 2.0F, (float) y + 0.0F, (float) z + 1.0F);
        GL11.glRotatef(90F, 0F, 0F, 1F);
        GL11.glRotatef(-90F, 1F, 0F, 0F);
        return;
    }
    case UNKNOWN: {
        return;
    }
    default: {
        return;
    }
    }
}

From source file:com.pahimar.ee3.client.renderer.tileentity.TileEntityGlassBellRenderer.java

License:LGPL

private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z,
        ForgeDirection forgeDirection) {

    if (ghostItemStack != null) {
        if (ghostItemStack.getItem() instanceof ItemBlock) {
            switch (forgeDirection) {
            case DOWN: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.7F, (float) z + 0.5F);
                return;
            }/*from www. j  a va  2  s. co  m*/
            case UP: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F);
                return;
            }
            case NORTH: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F);
                return;
            }
            case SOUTH: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F);
                return;
            }
            case EAST: {
                GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F);
                return;
            }
            case WEST: {
                GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F);
                return;
            }
            case UNKNOWN: {
                return;
            }
            default: {
                return;
            }
            }
        } else {
            switch (forgeDirection) {
            case DOWN: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F);
                return;
            }
            case UP: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F);
                return;
            }
            case NORTH: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F);
                return;
            }
            case SOUTH: {
                GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F);
                return;
            }
            case EAST: {
                GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F);
                return;
            }
            case WEST: {
                GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F);
                return;
            }
            case UNKNOWN: {
                return;
            }
            default: {
                return;
            }
            }
        }
    }
}

From source file:com.pahimar.ee3.core.handlers.TransmutationTargetOverlayHandler.java

License:LGPL

private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack,
        float partialTicks) {

    float overlayScale = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE;
    float blockScale = overlayScale / 2;
    float overlayOpacity = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY;

    GL11.glPushMatrix();/*from  w ww  .  j  a  va2s .c om*/
    ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth,
            minecraft.displayHeight);
    GL11.glClear(256);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);

    GL11.glPushMatrix();
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_LIGHTING);

    int hudOverlayX = 0;
    int hudOverlayY = 0;
    int hudBlockX = 0;
    int hudBlockY = 0;

    switch (ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION) {
    case 0: {
        hudOverlayX = 0;
        hudBlockX = (int) (16 * overlayScale / 2 - 8);
        hudOverlayY = 0;
        hudBlockY = (int) (16 * overlayScale / 2 - 8);
        break;
    }
    case 1: {
        hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
        hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8);
        hudOverlayY = 0;
        hudBlockY = (int) (16 * overlayScale / 2 - 8);
        break;
    }
    case 2: {
        hudOverlayX = 0;
        hudBlockX = (int) (16 * overlayScale / 2 - 8);
        hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);
        hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8);
        break;
    }
    case 3: {
        hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
        hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8);
        hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);
        hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8);
        break;
    }
    default: {
        break;
    }
    }

    RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, hudOverlayX,
            hudOverlayY, overlayOpacity, overlayScale);

    if (TransmutationHelper.targetBlockStack != null
            && TransmutationHelper.targetBlockStack.getItem() instanceof ItemBlock) {
        RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, minecraft.renderEngine,
                TransmutationHelper.targetBlockStack, hudBlockX, hudBlockY, -90, blockScale);
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:com.professorvennie.machinerycraft.client.renderer.item.ItemRenderPlasticChest.java

License:Creative Commons License

private void renderChest(float x, float y, float z, int metaData) {
    FMLClientHandler.instance().getClient().renderEngine
            .bindTexture(new ResourceLocation(Reference.MOD_ID, "textures/model/plastic_chest.png"));

    GL11.glPushMatrix(); //start
    GL11.glTranslatef(x, y, z); //size
    GL11.glRotatef(180, 1, 0, 0);/*  ww  w.  j a va  2s.c  o m*/
    GL11.glRotatef(-90, 0, 1, 0);
    modelChest.renderAll();
    GL11.glPopMatrix(); //end
}