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.keyle.dungeoncraft.editor.editors.world.render.block.DecorationCross.java

License:Open Source License

@Override
public void render(byte blockData, int x, int y, int z, ChunkSchematic chunk) {
    GL11.glPushMatrix();/*ww  w . j  a  v  a 2 s. co m*/
    GL11.glTranslatef(x, y, z);

    if (dimensions[blockData] == null) {
        blockData = 0;
    }

    Renderer.renderNonstandardVertical(dimensions[blockData], 0, 0, 0, 1, 1, 1);
    Renderer.renderNonstandardVertical(dimensions[blockData], 1, 0, 0, 0, 1, 1);

    GL11.glPopMatrix();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.block.DecorationGrid.java

License:Open Source License

@Override
public void render(byte blockData, int x, int y, int z, ChunkSchematic chunk) {
    GL11.glPushMatrix();/*from   w  w w .java 2s. co m*/
    GL11.glTranslatef(x, y, z);

    if (dimensions[blockData] == null) {
        blockData = 0;
    }

    Renderer.renderNonstandardVertical(dimensions[blockData], 0.25f, 0, 0, 0.25f, 1, 1);
    Renderer.renderNonstandardVertical(dimensions[blockData], 0.75f, 0, 0, 0.75f, 1, 1);
    Renderer.renderNonstandardVertical(dimensions[blockData], 0, 0, 0.25f, 1, 1, 0.25f);
    Renderer.renderNonstandardVertical(dimensions[blockData], 0, 0, 0.75f, 1, 1, 0.75f);

    GL11.glPopMatrix();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.block.Log.java

License:Open Source License

@Override
public void render(byte blockData, int x, int y, int z, ChunkSchematic chunk) {
    byte woodType = (byte) (blockData % 4);

    if (top[woodType] == null) {
        woodType = 0;/*from   www.  ja va2s.  c om*/
    }

    TextureDimensions top = this.top[woodType];
    TextureDimensions side = this.side[woodType];

    // ToDo rotation

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

    if (x > 0 && !chunk.getBlockType(x - 1, y, z).isSolid() || x == 0) {
        Renderer.renderNonstandardVertical(side, 0, 0, 0, 0, 1, 1);
    }
    if (x < chunk.getMaxWidth() && !chunk.getBlockType(x + 1, y, z).isSolid() || x == chunk.getMaxWidth()) {
        Renderer.renderNonstandardVertical(side, 1, 0, 0, 1, 1, 1);
    }
    if (y > 0 && !chunk.getBlockType(x, y - 1, z).isSolid() || y == 0) {
        Renderer.renderHorizontal(top, 0, 0, 1, 1, 0, false);
    }
    if (y < chunk.getMaxHeight() && !chunk.getBlockType(x, y + 1, z).isSolid() || y == chunk.getMaxHeight()) {
        Renderer.renderHorizontal(top, 0, 0, 1, 1, 1, false);
    }
    if (z > 0 && !chunk.getBlockType(x, y, z - 1).isSolid() || z == 0) {
        Renderer.renderNonstandardVertical(side, 0, 0, 0, 1, 1, 0);
    }
    if (z < chunk.getMaxLength() && !chunk.getBlockType(x, y, z + 1).isSolid() || z == chunk.getMaxLength()) {
        Renderer.renderNonstandardVertical(side, 0, 0, 1, 1, 1, 1);
    }

    GL11.glPopMatrix();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Renders a rectangular decoration./*from w w  w. ja  v  a2s .c om*/
 *
 * @param dimensions     Dimension of the Texture
 * @param x              Block X
 * @param y              Block Y
 * @param z              Block Z
 * @param rotate_degrees Degrees to rotate, use zero for no rotation
 * @param rotate_x       Use 1.0f to rotate in the X direction (passed to glRotatef)
 * @param rotate_z       Use 1.0f to rotate in the Z direction (passed to glRotatef)
 * @param x_off          X offset, so it's not just in the center
 * @param z_off          Z offset, so it's not just in the center
 */
public static void renderRectDecoration(TextureDimensions dimensions, float x, float y, float z,
        int rotate_degrees, float rotate_x, float rotate_z, float x_off, float z_off) {

    boolean do_rotate = false;
    float tx = 0, ty = 0, tz = 0;
    if (rotate_degrees != 0) {
        tx = x;
        ty = y;
        tz = z;
        x = x_off;
        y = 0;
        z = z_off;
        do_rotate = true;
    }

    float width = dimensions.getTexWidth() / TEX16;
    float width_h = width / 2f;
    float height = dimensions.getTexHeight() / TEX16;
    float top_tex_height;
    if (height > width) {
        top_tex_height = dimensions.getTexWidth() / 2f;
    } else {
        top_tex_height = dimensions.getTexHeight();
    }

    // Math is for suckers; let's let the video hardware take care of rotation
    // Relatedly, is this how I should be drawing *everything?*  Draw relative
    // to the origin for the actual verticies, and then translate?
    if (do_rotate) {
        GL11.glPushMatrix();
        GL11.glTranslatef(tx, ty, tz);
        GL11.glRotatef((float) rotate_degrees, rotate_x, 0f, rotate_z);
    }

    // First draw the borders
    renderNonstandardVertical(dimensions, x - width_h, y + height, z - width_h, x + width_h, y, z - width_h);
    renderNonstandardVertical(dimensions, x - width_h, y + height, z + width_h, x + width_h, y, z + width_h);
    renderNonstandardVertical(dimensions, x + width_h, y + height, z - width_h, x + width_h, y, z + width_h);
    renderNonstandardVertical(dimensions, x - width_h, y + height, z + width_h, x - width_h, y, z - width_h);

    // Now the top
    renderNonstandardHorizontal(dimensions.getTexLeft(), dimensions.getTexTop(), dimensions.getTexWidth(),
            top_tex_height, x - width_h, z - width_h, x + width_h, z + width_h, y + height);

    if (do_rotate) {
        GL11.glPopMatrix();
    }
}

From source file:de.mineformers.gui.api.util.RenderHelper.java

License:LGPL

public static void drawString(String text, int x, int y, int color, boolean drawShadow, int zLevel) {
    GL11.glDisable(GL11.GL_DEPTH_TEST);/*from w  w  w  .j  a va  2  s.c  om*/
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glTranslatef(0, 0, zLevel);
    getMC().fontRenderer.drawString(text, x, y, color, drawShadow);
    GL11.glTranslatef(0, 0, -zLevel);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:de.mineformers.powergrid.client.renderer.tileentity.TileCableRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick) {
    TileCable tile = (TileCable) tileentity;
    Tessellator tess = Tessellator.instance;

    this.bindTexture(TextureMap.locationBlocksTexture);
    EnumSet<ForgeDirection> cons = tile.getConnections();

    this.bindBlock();

    GL11.glPushMatrix();/*from   w w w  . jav  a2s  .  co  m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glTranslated(x, y, z);

    drawBase(tess, cons);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    if (cons.contains(ForgeDirection.UP)) {
        drawConnection(tess);
    }
    if (cons.contains(ForgeDirection.DOWN)) {
        GL11.glRotatef(180, 1, 0, 0);
        drawConnection(tess);
        GL11.glRotatef(-180, 1, 0, 0);
    }
    if (cons.contains(ForgeDirection.EAST)) {
        GL11.glRotatef(-90, 0, 0, 1);
        drawConnection(tess);
        GL11.glRotatef(90, 0, 0, 1);
    }
    if (cons.contains(ForgeDirection.WEST)) {
        GL11.glRotatef(90, 0, 0, 1);
        drawConnection(tess);
        GL11.glRotatef(-90, 0, 0, 1);
    }

    if (cons.contains(ForgeDirection.NORTH)) {
        GL11.glRotatef(-90, 1, 0, 0);
        drawConnection(tess);
        GL11.glRotatef(90, 1, 0, 0);
    }
    if (cons.contains(ForgeDirection.SOUTH)) {
        GL11.glRotatef(90, 1, 0, 0);
        drawConnection(tess);
        GL11.glRotatef(-90, 1, 0, 0);
    }

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

From source file:de.mineformers.powergrid.client.renderer.tileentity.TileCableRenderer.java

License:LGPL

private void drawBase(Tessellator tess, EnumSet<ForgeDirection> cons) {
    /* Y Axis *///from   ww w .j  ava  2 s.  c om
    drawBaseInverse(tess, cons);
    float offY = baseMod / 2F;
    if (!cons.contains(ForgeDirection.UP)) {
        this.drawBaseFluid(tess);
        this.bindBlock();
        tess.startDrawingQuads();
        tess.addVertexWithUV(0.25F, 0.75F, 0.75F, 0, offY + baseMod);
        tess.addVertexWithUV(0.75F, 0.75F, 0.75F, baseMod, offY + baseMod);
        tess.addVertexWithUV(0.75F, 0.75F, 0.25F, baseMod, offY + 0);
        tess.addVertexWithUV(0.25F, 0.75F, 0.25F, 0, offY + 0);
        tess.draw();
    }
    if (!cons.contains(ForgeDirection.DOWN)) {
        GL11.glRotatef(-180, 1, 0, 0);
        GL11.glTranslatef(0, 0, -1);
        GL11.glTranslatef(0, -1F, 0);
        this.drawBaseFluid(tess);
        GL11.glTranslatef(0, 1F, 0);
        GL11.glTranslatef(0, 0, 1);
        GL11.glRotatef(180, 1, 0, 0);
        this.bindBlock();
        tess.startDrawingQuads();
        tess.addVertexWithUV(0.25F, 0.25F, 0.25F, 0, offY + 0);
        tess.addVertexWithUV(0.75F, 0.25F, 0.25F, baseMod, offY + 0);
        tess.addVertexWithUV(0.75F, 0.25F, 0.75F, baseMod, offY + baseMod);
        tess.addVertexWithUV(0.25F, 0.25F, 0.75F, 0, offY + baseMod);
        tess.draw();
    }

    /* Z Axis */
    if (!cons.contains(ForgeDirection.NORTH)) {
        GL11.glRotatef(-90, 1, 0, 0);
        GL11.glTranslatef(0, -1, 0);
        this.drawBaseFluid(tess);
        GL11.glTranslatef(0, 1, 0);
        GL11.glRotatef(90, 1, 0, 0);
        this.bindBlock();
        tess.startDrawingQuads();
        tess.addVertexWithUV(0.25F, 0.75F, 0.25F, baseMod, offY + 0);
        tess.addVertexWithUV(0.75F, 0.75F, 0.25F, 0, offY + 0);
        tess.addVertexWithUV(0.75F, 0.25F, 0.25F, 0, offY + baseMod);
        tess.addVertexWithUV(0.25F, 0.25F, 0.25F, baseMod, offY + baseMod);
        tess.draw();
    }
    if (!cons.contains(ForgeDirection.SOUTH)) {
        GL11.glRotatef(90, 1, 0, 0);
        GL11.glTranslatef(0, 0, -1);
        this.drawBaseFluid(tess);
        GL11.glTranslatef(0, 0, 1);
        GL11.glRotatef(-90, 1, 0, 0);
        this.bindBlock();
        tess.startDrawingQuads();
        tess.addVertexWithUV(0.25F, 0.75F, 0.75F, 0, offY + 0);
        tess.addVertexWithUV(0.25F, 0.25F, 0.75F, 0, offY + baseMod);
        tess.addVertexWithUV(0.75F, 0.25F, 0.75F, baseMod, offY + baseMod);
        tess.addVertexWithUV(0.75F, 0.75F, 0.75F, baseMod, offY + 0);
        tess.draw();
    }

    /* X Axis */
    if (!cons.contains(ForgeDirection.EAST)) {
        GL11.glRotatef(-90, 0, 0, 1);
        GL11.glTranslatef(-1, 0, 0);
        this.drawBaseFluid(tess);
        GL11.glTranslatef(1, 0, 0);
        GL11.glRotatef(90, 0, 0, 1);
        this.bindBlock();
        tess.startDrawingQuads();
        tess.addVertexWithUV(0.75F, 0.75F, 0.75F, baseMod, offY);
        tess.addVertexWithUV(0.75F, 0.25F, 0.75F, baseMod, offY + baseMod);
        tess.addVertexWithUV(0.75F, 0.25F, 0.25F, 0, offY + baseMod);
        tess.addVertexWithUV(0.75F, 0.75F, 0.25F, 0, offY);
        tess.draw();
    }
    if (!cons.contains(ForgeDirection.WEST)) {
        GL11.glRotatef(90, 0, 0, 1);
        GL11.glTranslatef(0, -1, 0);
        this.drawBaseFluid(tess);
        GL11.glTranslatef(0, 1, 0);
        GL11.glRotatef(-90, 0, 0, 1);
        this.bindBlock();
        tess.startDrawingQuads();
        tess.addVertexWithUV(0.25F, 0.75F, 0.75F, baseMod, offY + 0);
        tess.addVertexWithUV(0.25F, 0.75F, 0.25F, 0, offY + 0);
        tess.addVertexWithUV(0.25F, 0.25F, 0.25F, 0, offY + baseMod);
        tess.addVertexWithUV(0.25F, 0.25F, 0.75F, baseMod, offY + baseMod);
        tess.draw();
    }
}

From source file:de.mineformers.robots.client.gui.util.render.ModelDrawingHelper.java

License:LGPL

public void render(int par0, int par1, int par2) {
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glPushMatrix();// ww  w.  ja  va2s .com
    GL11.glTranslatef((float) par0, (float) par1, 50.0F);
    GL11.glScalef((float) (-par2), (float) par2, (float) par2);
    GL11.glRotatef(180F, 0, 1, 0);
    /*current = System.currentTimeMillis();
    if(current - last >= 0) {
    last = current;
    rotation += 0.1F;
    }*/
    rotation += 0.3F;
    GL11.glRotatef(rotation, 0, 1, 0);

    RenderHelper.bindTexture(texture);
    model.justRender(false);
    if (tile.getStackInSlot(0) != null) {
        Tessellator tessellator = Tessellator.instance;
        GL11.glPushMatrix();

        GL11.glTranslatef(0, 0.35F, -0.1F);
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glScalef(0.5F, 0.5F, 1F);
        Icon icon = ModItems.module.getIcon(tile.getStackInSlot(0), 0);
        float f4 = icon.getMinU();
        float f5 = icon.getMaxU();
        float f6 = icon.getMinV();
        float f7 = icon.getMaxV();
        float f9 = 0.5F;
        float f10 = 0.25F;
        float f12 = 0.0625F;
        float f11 = 0.021875F;
        ItemStack itemstack = tile.getStackInSlot(0);
        int j = itemstack.stackSize;
        byte b0 = customRenderItem.getMiniItemCount(itemstack);

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

        for (int k = 0; k < b0; ++k) {
            // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
            GL11.glTranslatef(0f, 0f, f12 + f11);

            if (itemstack.getItemSpriteNumber() == 0) {
                RenderHelper.bindTexture(TextureMap.locationBlocksTexture);
            } else {
                RenderHelper.bindTexture(TextureMap.locationItemsTexture);
            }

            GL11.glColor4f(1, 1, 1, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, icon.getIconWidth(), icon.getIconHeight(),
                    f12);

            if (itemstack.hasEffect(0)) {
                GL11.glDepthFunc(GL11.GL_EQUAL);
                GL11.glDisable(GL11.GL_LIGHTING);
                RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT);
                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();
    }
    GL11.glPopMatrix();
    net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
}

From source file:de.mineformers.robots.client.model.ModelBuddyBot.java

License:LGPL

public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
    this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);

    if (this.isChild) {
        float f6 = 2.0F;
        GL11.glPushMatrix();/*w ww .java  2  s  . c  om*/
        if (isSitting)
            GL11.glTranslatef(0, 0.325F, 0);
        GL11.glPushMatrix();
        GL11.glScalef(1.75F / f6, 1.75F / f6, 1.75F / f6);
        GL11.glTranslatef(0.0F, 13.75F * par7, 0.0F);
        this.bipedHead.render(par7);
        this.bipedEye.render(par7);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);
        GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
        this.bipedBody.render(par7);
        this.bipedRightArm.render(par7);
        this.bipedLeftArm.render(par7);
        this.bipedRightLeg.render(par7);
        this.bipedLeftLeg.render(par7);
        this.bipedHeadwear.render(par7);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    } else {
        GL11.glPushMatrix();
        GL11.glScalef(2F, 2F, 2F);
        GL11.glTranslatef(0.0F, 16.0F * par7, 0.0F);
        this.bipedHead.render(par7);
        GL11.glPopMatrix();
        this.bipedBody.render(par7);
        this.bipedRightArm.render(par7);
        this.bipedLeftArm.render(par7);
        this.bipedRightLeg.render(par7);
        this.bipedLeftLeg.render(par7);
        this.bipedHeadwear.render(par7);
    }
}

From source file:de.mineformers.robots.client.model.ModelRobot.java

License:LGPL

public void justRender(boolean offset) {
    this.bipedBody.render(0.0625F);
    this.bipedRightArm.render(0.0625F);
    this.bipedLeftArm.render(0.0625F);
    this.bipedRightLeg.render(0.0625F);
    this.bipedLeftLeg.render(0.0625F);
    this.bipedHeadwear.render(0.0625F);
    if (offset)/*from  ww  w  .jav a 2 s  . c  om*/
        GL11.glTranslatef(0, 0, 0.1F);
    this.bipedHead.render(0.0625F);
}