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.rvantwisk.cnctools.opengl.View2D.java

License:Open Source License

@Override
public void display_transform() {

    // _center_on_origin
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*  w w  w.ja va 2 s. c  o  m*/
    GL11.glOrtho(-camera.getX(), camera.getX(), -camera.getY(), camera.getY(), NEAR, FAR);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    // _center_on_origin

    GL11.glTranslatef(camera.getX(), camera.getY(), camera.getZ());
    GL11.glRotatef(camera.getAzimuth(), 0.0f, 0.0f, 1.0f);
    GL11.glScalef(camera.getZoom_factor(), camera.getZoom_factor(), camera.getZoom_factor());
}

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

License:Open Source License

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

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

License:Open Source License

@Override
public void display_transform() {
    GL11.glRotatef(-90f, 1.0f, 0.0f, 0.0f);
    GL11.glTranslatef(0.0f, camera.getY(), 0.0f);

    float f = camera.getZoom_factor();
    if (camera.isOrtho()) {
        f *= camera.getZOOM_ORTHO_ADJ();
    }//from   w  w  w.  j  a v a2  s  . co  m
    GL11.glScalef(f, f, f);

    GL11.glTranslatef(camera.getX(), 0.0f, camera.getZ());
    GL11.glRotatef(-camera.getElevation(), 1.0f, 0.0f, 0.0f);
    GL11.glRotatef(camera.getAzimuth(), 0.0f, 0.0f, 1.0f);

    GL11.glTranslatef(camera.getOffset_x(), camera.getOffset_y(), 0.0f);
}

From source file:com.samrj.devil.ui.Font.java

License:Open Source License

public void draw(String text, Vec2 pos, Vec2 align) {
    pos = new Vec2(pos.x, pos.y - cellHeight);
    align = new Vec2(align.x - 1.0f, -align.y - 1.0f).mult(0.5f);
    align.x *= getWidth(text);/*from w  w  w  .  j a  v  a2 s.co m*/
    align.y *= -height;
    pos.add(align);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glTranslatef(Math.round(pos.x), Math.round(pos.y), 0.0f);

    float x0 = 0f;
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    tex.bind();
    GL11.glBegin(GL11.GL_QUADS);
    for (int i = 0; i < text.length(); i++) {
        int charbits = text.charAt(i) - 32;
        int fontposx = charbits & 0xF;
        int fontposy = 15 - (charbits >> 4);
        float u0 = fontposx++ / 16f;
        float v0 = fontposy++ / 16f;
        float u1 = fontposx / 16f;
        float v1 = fontposy / 16f;

        float x1 = x0 + cellHeight;

        GL11.glTexCoord2f(u0, v0);
        GL11.glVertex2f(x0, 0f);
        GL11.glTexCoord2f(u0, v1);
        GL11.glVertex2f(x0, cellHeight);
        GL11.glTexCoord2f(u1, v1);
        GL11.glVertex2f(x1, cellHeight);
        GL11.glTexCoord2f(u1, v0);
        GL11.glVertex2f(x1, 0f);

        x0 += getWidth(text.charAt(i));
    }
    GL11.glEnd();
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glPopMatrix();
}

From source file:com.samrj.devil.ui.Paragraph.java

public void draw(Vec2 pos, Alignment a) {
    if (a == null)
        throw new IllegalArgumentException();

    GL11.glPushMatrix();/*from   w w w  .java 2 s  .  com*/
    GL11.glTranslatef(pos.x, pos.y, 0f);

    float y = 0f;
    for (int i = 0; i < lines.length; i++) {
        font.draw(lines[i], new Vec2(0f, y), a);
        y -= font.getHeight();
    }

    GL11.glPopMatrix();
}

From source file:com.savageboy74.savagetech.client.render.item.ItemRenderLootBox.java

License:Open Source License

private void renderLootBox(float x, float y, float z, int metaData) {
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.LOOT_BOX);

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

From source file:com.savageboy74.savagetech.client.render.tileentity.TileEntityRendererLootBox.java

License:Open Source License

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

        if (tileEntityLootBox.getWorldObj() != null) {
            direction = tileEntityLootBox.getOrientation();
        }/*from  w  w w . j  a  va2s .  com*/

        this.bindTexture(Textures.Model.LOOT_BOX);
        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 = tileEntityLootBox.prevLidAngle
                + (tileEntityLootBox.lidAngle - tileEntityLootBox.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.sci.machinery.render.RenderTube.java

License:LGPL

public void renderItem(TravellingItem item, double x, double y, double z) {
    if (item == null)
        return;/*from ww  w.  j  a v a  2 s  . c  o  m*/
    if (item.getStack() == null)
        return;
    float renderScale = 0.3f;
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.1f, (float) y - 0.175f, (float) z + 0.1f);
    GL11.glTranslatef(0, 0.25F, 0);
    GL11.glScalef(renderScale, renderScale, renderScale);
    dummyEntityItem.setEntityItemStack(item.getStack());
    item.setRotation(item.getRotation() + 0.5f % 360);
    customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, item.getRotation());
    GL11.glPopMatrix();
}

From source file:com.shinoow.abyssalcraft.api.render.Block3DRender.java

License:Apache License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (type == IItemRenderer.ItemRenderType.ENTITY)
        GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
    render.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F);
}

From source file:com.shinoow.abyssalcraft.client.handlers.AbyssalCraftClientEventHooks.java

License:Apache License

private void renderStarSpawnPlayer(EntityPlayer player, float partialTicks) {

    mc.renderEngine.bindTexture(new ResourceLocation("abyssalcraft:textures/model/tentacles.png"));

    for (int j = 0; j < 1; ++j) {
        GL11.glColor4f(1F, 1F, 1F, 1F);/*from  w w w . j ava 2 s .co  m*/
        float f10 = player.prevRotationYawHead
                + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks
                - (player.prevRenderYawOffset
                        + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks);
        float f2 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
        GL11.glPushMatrix();
        GL11.glFrontFace(GL11.GL_CW);
        GL11.glRotatef(f10, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0, -0.22F, 0);
        GL11.glScalef(1, 1, 1);
        model.renderTentacles(0.0625F);
        GL11.glFrontFace(GL11.GL_CCW);
        GL11.glPopMatrix();
    }
}