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:boilerplate.client.renderers.block.BlockTESRRenderer.java

License:Minecraft Mod Public

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
    GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    TileEntityRendererDispatcher.instance.renderTileEntityAt(this.tile, 0.0D, 0.0D, 0.0D, 0.0F);
    GL11.glEnable(32826);/* w ww.  j ava2s . c  om*/
}

From source file:boilerplate.client.renderers.block.RenderMinedBlock.java

License:Minecraft Mod Public

public void doRender(EntityMinedBlock entBlock, double posX, double posY, double posZ, float f,
        float renderTick) {
    World world = entBlock.getWorldObj();
    Block block = entBlock.getBlock();//from  w w w  . ja  v  a  2s  .  c o m

    MathHelper.floor_double(entBlock.posX);
    MathHelper.floor_double(entBlock.posY);
    MathHelper.floor_double(entBlock.posZ);

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glPushMatrix();
    GL11.glTranslatef((float) posX, (float) posY, (float) posZ);
    this.bindEntityTexture(entBlock);

    float scale = entBlock.scale;
    float rot = world.getWorldTime() * 17.6F;

    GL11.glScalef(scale, scale, scale);

    if (entBlock.doesRotate)
        GL11.glRotatef(rot, 0 - world.rand.nextFloat(), 0 - world.rand.nextFloat(), 0 - world.rand.nextFloat());

    this.blockRenderer.blockAccess = entBlock.worldObj;
    this.blockRenderer.useInventoryTint = true;

    this.blockRenderer.setRenderBoundsFromBlock(block);
    this.blockRenderer.renderBlockAsItem(block, entBlock.metadata, 1.0F);

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

From source file:boilerplate.client.renderers.RenderFloatingItem.java

License:Minecraft Mod Public

public static void render(double dx, double dy, double dz, float rotX, float rotY, float rotZ,
        ItemStack stack) {/*from   www . j  av a2  s. co  m*/
    EntityItem entItem = new EntityItem(ClientHelper.world(), 0D, 0D, 0D, stack);
    // Without the below line, the item will spazz out
    entItem.hoverStart = 0.0F;
    RenderItem.renderInFrame = true;
    GL11.glTranslatef((float) dx, (float) dy, (float) dz);
    GL11.glRotatef(rotX, 1, 0, 0);
    GL11.glRotatef(rotY, 0, 1, 0);
    GL11.glRotatef(rotZ, 0, 0, 1);
    GL11.glScalef(1.3F, 1.3F, 1.3F);
    RenderManager.instance.renderEntityWithPosYaw(entItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
    RenderItem.renderInFrame = false;
}

From source file:boilerplate.client.renderers.RenderFloatingItem.java

License:Minecraft Mod Public

public static void render(double dx, double dy, double dz, float rotX, float rotY, float rotZ, float scaleX,
        float scaleY, float scaleZ, ItemStack stack) {
    EntityItem entItem = new EntityItem(ClientHelper.world(), 0D, 0D, 0D, stack);
    // Without the below line, the item will spazz out
    entItem.hoverStart = 0.0F;/*  w ww .j ava2  s  .c o m*/
    RenderItem.renderInFrame = true;
    GL11.glTranslatef((float) dx, (float) dy, (float) dz);
    GL11.glRotatef(rotX, 1, 0, 0);
    GL11.glRotatef(rotY, 0, 1, 0);
    GL11.glRotatef(rotZ, 0, 0, 1);
    GL11.glScalef(scaleX, scaleY, scaleZ);
    RenderManager.instance.renderEntityWithPosYaw(entItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
    RenderItem.renderInFrame = false;
}

From source file:buildcraft.builders.render.RenderConstructionMarker.java

License:Minecraft Mod Public

public void doRenderItem(ItemStack stack, double x, double y, double z) {
    if (stack == null) {
        return;/*from w w w  .  j a  v a  2  s .com*/
    }

    float renderScale = 1.5f;
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glTranslatef(0, 0.25F, 0);
    GL11.glScalef(renderScale, renderScale, renderScale);
    dummyEntityItem.setEntityItemStack(stack);
    customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);

    GL11.glPopMatrix();
}

From source file:buildcraft.builders.RenderBuilder.java

License:Minecraft Mod Public

public void doRenderItem(BuildingItem i, float light) {
    if (i == null) {
        return;//from w w w . j  ava 2 s  .c om
    }

    i.displayUpdate();

    for (StackAtPosition s : i.getStacks()) {
        if (s.display) {
            float renderScale = 0.7f;
            GL11.glPushMatrix();
            GL11.glTranslatef((float) s.pos.x, (float) s.pos.y, (float) s.pos.z);
            GL11.glTranslatef(0, 0.25F, 0);
            GL11.glScalef(renderScale, renderScale, renderScale);
            dummyEntityItem.setEntityItemStack(s.stack);
            customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);

            GL11.glPopMatrix();
        }
    }
}

From source file:buildcraft.core.gui.GuiBuildCraft.java

License:Minecraft Mod Public

/**
 * Draws the screen and all the components in it.
 *//*from w  w  w  .  j  av  a 2s . co  m*/
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
    super.drawScreen(mouseX, mouseY, par3);
    int left = this.guiLeft;
    int top = this.guiTop;

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glTranslatef(left, top, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    RenderHelper.disableStandardItemLighting();

    InventoryPlayer playerInv = this.mc.thePlayer.inventory;

    if (playerInv.getItemStack() == null) {
        drawToolTips(container.getWidgets(), mouseX, mouseY);
        drawToolTips(buttonList, mouseX, mouseY);
        drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY);
    }

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

From source file:buildcraft.core.lib.engines.RenderEngine.java

License:Minecraft Mod Public

private void render(float progress, ForgeDirection orientation, ResourceLocation baseTexture,
        ResourceLocation chamberTexture, ResourceLocation trunkTexture, double x, double y, double z) {
    if (BuildCraftCore.render == RenderMode.NoDynamic) {
        return;/*from  w w  w.j a  v  a  2  s.  c  om*/
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor3f(1, 1, 1);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    float step;

    if (progress > 0.5) {
        step = 7.99F - (progress - 0.5F) * 2F * 7.99F;
    } else {
        step = progress * 2F * 7.99F;
    }

    float translatefact = step / 16;

    float[] angle = { 0, 0, 0 };
    float[] translate = { orientation.offsetX, orientation.offsetY, orientation.offsetZ };

    switch (orientation) {
    case EAST:
    case WEST:
    case DOWN:
        angle[2] = angleMap[orientation.ordinal()];
        break;
    case SOUTH:
    case NORTH:
    default:
        angle[0] = angleMap[orientation.ordinal()];
        break;
    }

    box.rotateAngleX = angle[0];
    box.rotateAngleY = angle[1];
    box.rotateAngleZ = angle[2];

    trunk.rotateAngleX = angle[0];
    trunk.rotateAngleY = angle[1];
    trunk.rotateAngleZ = angle[2];

    movingBox.rotateAngleX = angle[0];
    movingBox.rotateAngleY = angle[1];
    movingBox.rotateAngleZ = angle[2];

    chamber.rotateAngleX = angle[0];
    chamber.rotateAngleY = angle[1];
    chamber.rotateAngleZ = angle[2];

    float factor = (float) (1.0 / 16.0);

    bindTexture(baseTexture);

    box.render(factor);

    GL11.glTranslatef(translate[0] * translatefact, translate[1] * translatefact, translate[2] * translatefact);
    movingBox.render(factor);
    GL11.glTranslatef(-translate[0] * translatefact, -translate[1] * translatefact,
            -translate[2] * translatefact);

    bindTexture(chamberTexture);

    float chamberf = 2F / 16F;
    int chamberc = ((int) step + 4) / 2;

    for (int i = 0; i <= step + 2; i += 2) {
        chamber.render(factor);
        GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf);
    }

    GL11.glTranslatef(-translate[0] * chamberf * chamberc, -translate[1] * chamberf * chamberc,
            -translate[2] * chamberf * chamberc);

    bindTexture(trunkTexture);

    trunk.render(factor);

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraft.core.lib.gui.GuiBuildCraft.java

License:Minecraft Mod Public

/**
 * Draws the screen and all the components in it.
 *//*from w w w .ja v  a 2s.co m*/
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
    super.drawScreen(mouseX, mouseY, par3);
    int left = this.guiLeft;
    int top = this.guiTop;

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glTranslatef(left, top, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    RenderHelper.disableStandardItemLighting();

    InventoryPlayer playerInv = this.mc.thePlayer.inventory;

    if (playerInv.getItemStack() == null) {
        drawToolTips(container.getWidgets(), mouseX - left, mouseY - top, left, top);
        drawToolTips(buttonList, mouseX, mouseY, 0, 0);
        drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY, 0, 0);
    }

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

From source file:buildcraft.core.lib.render.RenderEntityBlock.java

License:Minecraft Mod Public

public void doRenderBlock(EntityBlock entity, double x, double y, double z) {
    if (entity.isDead) {
        return;//  w  w w  .  ja v a 2  s  .c o m
    }

    shadowSize = entity.shadowSize;
    RenderInfo util = new RenderInfo();
    util.textureArray = entity.texture;
    bindTexture(TextureMap.locationBlocksTexture);

    int iMax = (int) Math.ceil(entity.iSize) - 1;
    int jMax = (int) Math.ceil(entity.jSize) - 1;
    int kMax = (int) Math.ceil(entity.kSize) - 1;

    GL11.glTranslatef((float) x, (float) y, (float) z);

    for (int iBase = 0; iBase <= iMax; ++iBase) {
        for (int jBase = 0; jBase <= jMax; ++jBase) {
            for (int kBase = 0; kBase <= kMax; ++kBase) {
                util.renderSide[0] = jBase == 0;
                util.renderSide[1] = jBase == jMax;
                util.renderSide[2] = kBase == 0;
                util.renderSide[3] = kBase == kMax;
                util.renderSide[4] = iBase == 0;
                util.renderSide[5] = iBase == iMax;

                if (util.renderSide[0] || util.renderSide[1] || util.renderSide[2] || util.renderSide[3]
                        || util.renderSide[4] || util.renderSide[5]) {
                    util.minX = 0;
                    util.minY = 0;
                    util.minZ = 0;

                    double remainX = entity.iSize - iBase;
                    double remainY = entity.jSize - jBase;
                    double remainZ = entity.kSize - kBase;

                    util.maxX = remainX > 1.0 ? 1.0 : remainX;
                    util.maxY = remainY > 1.0 ? 1.0 : remainY;
                    util.maxZ = remainZ > 1.0 ? 1.0 : remainZ;

                    GL11.glPushMatrix();
                    GL11.glRotatef(entity.rotationX, 1, 0, 0);
                    GL11.glRotatef(entity.rotationY, 0, 1, 0);
                    GL11.glRotatef(entity.rotationZ, 0, 0, 1);
                    GL11.glTranslatef(iBase, jBase, kBase);

                    renderBlock(util);
                    GL11.glPopMatrix();
                }
            }
        }
    }

    GL11.glTranslatef((float) -x, (float) -y, (float) -z);
}