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:eplus.renders.TileEnchantRenderer.java

License:LGPL

private void renderTable(TileEnchantTable tileentity, double x, double y, double z, float f) {

    GL11.glPushMatrix();//  w w w.  j  a v  a 2s . c om
    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F, (float) z + 0.5F);
    float f1 = (float) tileentity.tickCount + f;
    GL11.glTranslatef(0.0F, 0.1F + MathHelper.sin(f1 * 0.1F) * 0.01F, 0.0F);

    TableEntityItem entityItem = new TableEntityItem(tileentity.getWorldObj(), 0.0D, 0.0D, 0.0D,
            tileentity.itemInTable);
    entityItem.getEntityItem().stackSize = 1;
    entityItem.hoverStart = 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.glPushMatrix();
    GL11.glRotatef(-f3 * 180.0F / (float) Math.PI, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(90, 0.0f, 1.0f, 0.0f);

    RenderItem.renderInFrame = true;
    RenderManager.instance.renderEntityWithPosYaw(entityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
    RenderItem.renderInFrame = false;
    GL11.glPopMatrix();

    GL11.glPopMatrix();
}

From source file:extrabiomes.renderers.RenderKneeLog.java

License:Creative Commons License

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
    final Tessellator var4 = Tessellator.instance;

    if (renderer.useInventoryTint) {
        final int renderColor = block.getRenderColor(metadata);
        final float red = (renderColor >> 16 & 255) / 255.0F;
        final float green = (renderColor >> 8 & 255) / 255.0F;
        final float blue = (renderColor & 255) / 255.0F;
        GL11.glColor4f(red, green, blue, 1.0F);
    }/*ww w .  j a v  a 2s  .  com*/

    block.setBlockBoundsForItemRender();
    GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    var4.startDrawingQuads();
    var4.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
    var4.draw();

    var4.startDrawingQuads();
    var4.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, 0));
    var4.draw();

    var4.startDrawingQuads();
    var4.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, 0));
    var4.draw();

    var4.startDrawingQuads();
    var4.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, 0));
    var4.draw();

    var4.startDrawingQuads();
    var4.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, 0));
    var4.draw();

    var4.startDrawingQuads();
    var4.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, 0));
    var4.draw();

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}

From source file:extrabiomes.renderers.RenderNewQuarterLog.java

License:Creative Commons License

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
    try {//from   w  w w.  j  av a  2  s.  c o  m
        final Tessellator var4 = Tessellator.instance;

        if (renderer.useInventoryTint) {
            final int renderColor = block.getRenderColor(metadata);
            final float red = (renderColor >> 16 & 255) / 255.0F;
            final float green = (renderColor >> 8 & 255) / 255.0F;
            final float blue = (renderColor & 255) / 255.0F;
            GL11.glColor4f(red, green, blue, 1.0F);
        }

        block.setBlockBoundsForItemRender();
        GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        var4.startDrawingQuads();
        var4.setNormal(0.0F, -1.0F, 0.0F);
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
        var4.draw();

        var4.startDrawingQuads();
        var4.setNormal(0.0F, 1.0F, 0.0F);
        renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, 0));
        var4.draw();

        var4.startDrawingQuads();
        var4.setNormal(0.0F, 0.0F, -1.0F);
        renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, 0));
        var4.draw();

        var4.startDrawingQuads();
        var4.setNormal(0.0F, 0.0F, 1.0F);
        renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, 0));
        var4.draw();

        var4.startDrawingQuads();
        var4.setNormal(-1.0F, 0.0F, 0.0F);
        renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, 0));
        var4.draw();

        var4.startDrawingQuads();
        var4.setNormal(1.0F, 0.0F, 0.0F);
        renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, 0));
        var4.draw();

        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    } catch (Exception e) {
        LogHelper.severe("Block: " + block.toString());
        LogHelper.severe("metaData: " + metadata);
        LogHelper.severe("ModelID: " + modelID);
        LogHelper.severe("Renderer: " + renderer.toString());

        e.printStackTrace();

    }
}

From source file:fable.imageviewer.views.SceneGrip.java

License:Open Source License

/**
 * Warning called constantly in display loop - change with care.
 *///from   w w w .  j a v a 2  s .com
public void adjust() {
    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException ex) {
        FableUtils.excMsg(ReliefView.class, "Error in adjust using GLContext.useContext", ex);
    }
    // gl = context.getGL ();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    /* set the orthogonal projection to the size of the window */
    GL11.glOrtho(0, canvasWidth, canvasHeight, 0, -1.0e5f, 1.0e5f);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(canvasWidth / 2 + this.xoff, canvasHeight / 2 + this.yoff, 0);
    GL11.glScalef(zoff, zoff, zoff);
    /*
     * zoff has no effect on the orthogonal projection therefore zoom by
     * passing zoff to scale
     */
    GL11.glRotatef(this.xrot, 1f, 0.0f, 0.0f);
    GL11.glRotatef(this.yrot, 0.0f, 1f, 0.0f);
    GL11.glTranslatef(-prov.getImageWidth() / 2, -prov.getImageHeight() / 2, 0);
}

From source file:fexcraft.tmt.slim.ModelRendererTurbo.java

/**
 * Renders the shape./*  w ww .  j  ava 2s.  co m*/
 * @param scale the scale of the shape. Usually is 0.0625.
 */
public void render(float scale, boolean flipAxis) {
    if (field_1402_i || !showModel) {
        return;
    }
    if (displayList != null && (!compiled || forcedRecompile)) {
        compileDisplayList(scale);
    }
    if (rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F) {
        GL11.glPushMatrix();
        GL11.glTranslatef(rotationPointX * scale, rotationPointY * scale, rotationPointZ * scale);
        if (flipAxis) {
            if (rotateAngleZ != 0.0F) {
                GL11.glRotatef(rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
            }
            if (rotateAngleY != 0.0F) {
                GL11.glRotatef(rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
            }
        } else {
            if (rotateAngleY != 0.0F) {
                GL11.glRotatef(rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
            }
            if (rotateAngleZ != 0.0F) {
                GL11.glRotatef(rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
            }
        }
        if (rotateAngleX != 0.0F) {
            GL11.glRotatef(rotateAngleX * 57.29578F, 1.0F, 0.0F, 0.0F);
        }
        callDisplayList(scale);
        GL11.glPopMatrix();
    } else if (rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F) {
        GL11.glTranslatef(rotationPointX * scale, rotationPointY * scale, rotationPointZ * scale);
        callDisplayList(scale);
        GL11.glTranslatef(-rotationPointX * scale, -rotationPointY * scale, -rotationPointZ * scale);
    } else {
        callDisplayList(scale);
    }
}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void translateToAlign(float p1x, float p1y, float p1z, float p2x, float p2y, float p2z) {

    //Translate joint to the middle of the two points
    GL11.glTranslatef((p1x + p2x) * 0.5f, (p1y + p2y) * 0.5f, (p1z + p2z) * 0.5f);

    //Fix rotations so the drawn object will match the two points
    float zxAngle = (float) (Math.atan((p1x - p2x) / (p1z - p2z)) / Math.PI);
    float yzxAngle = (float) (Math
            .atan(Math.sqrt(Math.pow((p1x - p2x), 2) + Math.pow((p1z - p2z), 2)) / (p1y - p2y)) / Math.PI);

    if (p1z > p2z) {
        GL11.glRotatef(zxAngle * 180, 0, 1, 0);
    } else {/* w w w  .  j  a  v  a 2  s . co  m*/
        GL11.glRotatef(zxAngle * 180 + 180, 0, 1, 0);
    }

    if (p1y > p2y) {
        GL11.glRotatef(180 * yzxAngle, 1, 0, 0);
    } else {
        GL11.glRotatef(180 * yzxAngle + 180, 1, 0, 0);
    }

}

From source file:fi.conf.ae.gl.text.GLBitmapFontBlitter.java

License:LGPL

public static void drawString(String string, String textureIdentifier, float charWidth, float charHeight,
        Alignment align) {/*from www.  j  a v a 2  s  .  c  o m*/

    float hOverlap = 0.01f;
    float vOverlap = 0.0f;

    float xfix = 0;

    if (align.equals(Alignment.CENTERED)) {
        xfix = string.length() * charWidth * 0.5f;
    } else if (align.equals(Alignment.RIGHT)) {
        xfix = string.length() * charWidth - hOverlap;
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0, -0.5f * charHeight, 0);

    GLTextureManager.getInstance().bindTexture(textureIdentifier);

    GL11.glBegin(GL11.GL_QUADS);

    for (int i = 0; i < string.length(); i++) {

        char c = string.charAt(i);

        float x1 = (c % 16f) / 16f;
        float x2 = x1 + 1f / 16f;
        float y1 = (c / 16) / 16f;
        float y2 = y1 + 1f / 16f;

        GL11.glTexCoord2d(x1 + hOverlap, y1 + vOverlap);
        GL11.glVertex3d(i * charWidth - xfix, 0, 0);
        GL11.glTexCoord2d(x1 + hOverlap, y2 - vOverlap);
        GL11.glVertex3d(i * charWidth - xfix, charHeight, 0);
        GL11.glTexCoord2d(x2 - hOverlap, y2 - vOverlap);
        GL11.glVertex3d(i * charWidth + charWidth - xfix, charHeight, 0);
        GL11.glTexCoord2d(x2 - hOverlap, y1 + vOverlap);
        GL11.glVertex3d(i * charWidth + charWidth - xfix, 0, 0);

    }

    GL11.glEnd();
    GL11.glPopMatrix();

}

From source file:fi.conf.prograts.ar.gl.GLBitmapFontBlitter.java

License:LGPL

public static void drawString(String string, String textureIdentifier, float charWidth, float charHeight,
        Alignment align) {/*from   w w w  .  java2s .  com*/

    float fix = 0;
    float overlap = 0.01f;

    if (align.equals(Alignment.CENTERED)) {
        fix = string.length() * charWidth * 0.5f;
    } else if (align.equals(Alignment.RIGHT)) {
        fix = string.length() * charWidth - overlap;
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0, -0.5f * charHeight, 0);
    //      System.out.println(textureID);
    GLTextureManager.getInstance().bindTexture(textureIdentifier);

    GL11.glBegin(GL11.GL_QUADS);

    for (int i = 0; i < string.length(); i++) {

        char c = string.charAt(i);

        float x1 = (c % 16f) / 16f;
        float x2 = x1 + 1f / 16f;
        float y1 = (c / 16) / 16f;
        float y2 = y1 + 1f / 16f;

        GL11.glTexCoord2d(x1 + overlap, y1);
        GL11.glVertex3d(i * charWidth - fix, 0, 0);
        GL11.glTexCoord2d(x1 + overlap, y2);
        GL11.glVertex3d(i * charWidth - fix, charHeight, 0);
        GL11.glTexCoord2d(x2 - overlap, y2);
        GL11.glVertex3d(i * charWidth + charWidth - fix, charHeight, 0);
        GL11.glTexCoord2d(x2 - overlap, y1);
        GL11.glVertex3d(i * charWidth + charWidth - fix, 0, 0);

    }

    GL11.glEnd();
    GL11.glPopMatrix();

}

From source file:flash.display.Stage.java

License:Open Source License

@Override
protected final void JITB$render() {
    ///*from  w  w  w . j a v  a2 s. com*/
    // Clear the screen when the stage is re-rendered.
    //

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    //
    // Translate corresponding to stage align.
    //

    GL11.glTranslatef(0.0f, 0.0f, 0.0f);

    //
    // Now render all children of the stage.
    //

    JITB$renderChildren();
}