Example usage for org.lwjgl.opengl GL11 glTranslated

List of usage examples for org.lwjgl.opengl GL11 glTranslated

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glTranslated.

Prototype

public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y,
        @NativeType("GLdouble") double z);

Source Link

Document

Double version of #glTranslatef Translatef .

Usage

From source file:cn.weaponry.impl.classic.client.animation.ReloadAnimation.java

License:Open Source License

@Override
public void render(ItemInfo info, PartedModel model, boolean firstPerson) {
    long time = getTime(), dt = info.getDeltaTime();
    if (time < blendTime) {
        progress = time * blendSpeed / 1000.0;
    } else if (time > lifeTime - blendTime) {
        progress = (lifeTime - time) * blendSpeed / 1000.0;
    } else {//from ww  w  .  j  av a  2 s  .c o m
        progress = maxAngle;
    }

    GL11.glTranslated(0, -progress / maxAngle * 0.15, progress / maxAngle * 0.1);

    RenderUtils.glTranslate(pivotPt);
    RenderUtils.glRotate(progress, rotationAxis);
    RenderUtils.glTranslate(VecUtils.neg(pivotPt));
}

From source file:cn.weaponry.impl.classic.WeaponClassic.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)// w  ww  .j ava 2 s  .co  m
public void initDefaultAnims(RenderInfo render) {
    // An idle-swing effect
    render.addAnimation(new Animation() {
        @Override
        public void render(ItemInfo info, PartedModel model, boolean firstPerson) {
            long time = Minecraft.getSystemTime();
            double dx = 0.005 * Math.sin(time / 1000.0), dy = 0.01 * Math.sin(time / 700.0),
                    dz = 0.012 * Math.sin(time / 1400.0);
            //System.out.println("Translate");
            GL11.glTranslated(dx, dy, dz);
        }

        @Override
        public boolean shouldRenderInPass(int pass) {
            return pass == 0;
        }
    });

}

From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java

License:Open Source License

static void accFrustum(double left, double right, double bottom, double top, double near, double far,
        double pixdx, double pixdy, double eyedx, double eyedy, double focus) {
    double xwsize, ywsize;
    double dx, dy;
    int[] viewport = getViewport();

    xwsize = right - left;//  ww  w.j a  va 2 s  .c o m
    ywsize = top - bottom;
    dx = -(pixdx * xwsize / (double) viewport[2] + eyedx * near / focus);
    dy = -(pixdy * ywsize / (double) viewport[3] + eyedy * near / focus);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glFrustum(left + dx, right + dx, bottom + dy, top + dy, near, far);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslated(-eyedx, -eyedy, 0.0);
}

From source file:com.ardor3d.renderer.lwjgl.LwjglFont.java

License:Open Source License

/**
 * <code>print</code> renders the specified string to a given (x,y) location. The x, y location is in terms of
 * screen coordinates. There are currently two sets of fonts supported: NORMAL and ITALICS.
 * //  w  w w . ja  v a  2 s . c o  m
 * @param r
 * 
 * @param x
 *            the x screen location to start the string render.
 * @param y
 *            the y screen location to start the string render.
 * @param text
 *            the String to render.
 * @param set
 *            the mode of font: NORMAL or ITALICS.
 */
public void print(final Renderer r, final double x, final double y, final ReadOnlyVector3 scale,
        final StringBuffer text, int set) {
    final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord();
    if (set > 1) {
        set = 1;
    } else if (set < 0) {
        set = 0;
    }

    final boolean alreadyOrtho = r.isInOrthoMode();
    if (!alreadyOrtho) {
        r.setOrtho();
    } else {
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
    }
    GL11.glTranslated(x, y, 0);
    GL11.glScaled(scale.getX(), scale.getY(), scale.getZ());
    GL11.glListBase(base - 32 + (128 * set));

    // Put the string into a "pointer"
    if (text.length() > scratch.capacity()) {
        scratch = BufferUtils.createByteBuffer(text.length());
    } else {
        scratch.clear();
    }

    final int charLen = text.length();
    for (int z = 0; z < charLen; z++) {
        scratch.put((byte) text.charAt(z));
    }
    scratch.flip();
    GL11.glColor4f(fontColor.getRed(), fontColor.getGreen(), fontColor.getBlue(), fontColor.getAlpha());
    // call the list for each letter in the string.
    GL11.glCallLists(scratch);
    // set color back to white
    GL11.glColor4f(1, 1, 1, 1);

    if (!alreadyOrtho) {
        r.unsetOrtho();
    } else {
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
    }
}

From source file:com.blogspot.jabelarminecraft.magicbeans.renderers.RenderMysteriousStranger.java

License:Open Source License

@Override
public void passSpecialRender(EntityLivingBase parEntity, double parX, double parY, double parZ) {
    super.passSpecialRender(parEntity, parX, parY, parZ);
    if (parEntity.ticksExisted < 20 * 2) {
        GL11.glPushMatrix();//from  w  w w  . jav a 2s  .co  m
        GL11.glTranslated(parX, parY + parEntity.height / 2, parZ);
        GL11.glScalef(3.0F, 3.0F, 3.0F);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDepthMask(false);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, (40.0F - parEntity.ticksExisted) / 40.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glCallList(ClientProxy.sphereIdOutside);
        GL11.glCallList(ClientProxy.sphereIdInside);
        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.client.render.RenderEngine.java

License:Open Source License

@SuppressWarnings("cast")
@Override/* w  ww  .j  a v a  2 s  . c  o m*/
public void renderTileEntityAt(TileEntity engine, double x, double y, double z, float f) {

    if (engine instanceof TileEngine) {

        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_LIGHTING);
        TileEngine tile = (TileEngine) engine.getWorldObj().getTileEntity(engine.xCoord, engine.yCoord,
                engine.zCoord);

        ForgeDirection direction = tile.getOrientation();

        GL11.glTranslated(x, y, z);
        GL11.glScaled(.0315, .0315, .0315);

        if (direction == ForgeDirection.UP) {
            GL11.glTranslated(16, 28, 16);
            GL11.glRotatef(180, 1, 0, 0);
        }
        if (direction == ForgeDirection.DOWN) {
            GL11.glTranslated(16, 4, 16);
            GL11.glRotatef(0, 0, 0, 0);
        }
        if (direction == ForgeDirection.EAST) {
            GL11.glTranslated(28, 16, 16);
            GL11.glRotatef(90, 0, 0, 1);
        }
        if (direction == ForgeDirection.WEST) {
            GL11.glTranslated(4, 16, 16);
            GL11.glRotatef(90, 0, 0, -1);
        }
        if (direction == ForgeDirection.NORTH) {
            GL11.glTranslated(16, 16, 4);
            GL11.glRotatef(90, 1, 0, 0);
        }
        if (direction == ForgeDirection.SOUTH) {
            GL11.glTranslated(16, 16, 28);
            GL11.glRotatef(90, -1, 0, 0);
        }
        if (tile.isActive) {
            bindTexture(textureLocationOn);
        } else {
            bindTexture(textureLocationOff);
        }
        engineModel.renderAllExcept("gear", "glider");

        if (tile.isActive) {
            f += tile.pumpTick;
            if (tile.pumpSpeed > 0) {
                f /= tile.pumpSpeed;
            }
        } else {
            f = 0;
        }
        f = (float) ((float) 6 * (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)));
        GL11.glTranslatef(0, f, 0);

        engineModel.renderPart("glider");

        GL11.glTranslatef(0, -f, 0);

        if (tile.isActive) {
            if (tile.getWorldObj().isRemote) {
                rotateAmount++;

                GL11.glRotated(tile.gearTick * 19, 0, 1.5707963267948966D * (double) f, 0);
            }
        }
        engineModel.renderPart("gear");

        GL11.glEnable(GL11.GL_LIGHTING);

        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.client.render.RenderHelper.java

License:Open Source License

public static void renderRedstoneTorch(double x, double y, double z, double height, boolean state,
        boolean digital) {

    GL11.glPushMatrix();// ww w.  j  av a 2 s  .c  o  m
    {
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);

        if (digital) {
            rb.overrideBlockTexture = state ? IconSupplier.bluestoneTorchOn : IconSupplier.bluestoneTorchOff;
        } else {
            rb.overrideBlockTexture = state ? Blocks.redstone_torch.getIcon(0, 0)
                    : Blocks.unlit_redstone_torch.getIcon(0, 0);
        }

        GL11.glEnable(GL11.GL_CLIP_PLANE0);
        GL11.glClipPlane(GL11.GL_CLIP_PLANE0,
                uk.co.qmunity.lib.client.render.RenderUtils.planeEquation(0, 1, 0));

        GL11.glTranslated(x, y + height - 1, z);

        Tessellator t = Tessellator.instance;

        t.setColorOpaque_F(1.0F, 1.0F, 1.0F);
        t.startDrawingQuads();
        {
            rb.setRenderBounds(7 / 16D, 0, 0, 9 / 16D, 1, 1);
            t.setNormal(-1, 1, 0);
            rb.renderFaceXNeg(Blocks.stone, 0, 0, 0, null);
            t.setNormal(1, 1, 0);
            rb.renderFaceXPos(Blocks.stone, 0, 0, 0, null);

            rb.setRenderBounds(0, 0, 7 / 16D, 1, 1, 9 / 16D);
            t.setNormal(0, 1, -1);
            rb.renderFaceZNeg(Blocks.stone, 0, 0, 0, null);
            t.setNormal(0, 1, 1);
            rb.renderFaceZPos(Blocks.stone, 0, 0, 0, null);

            rb.setRenderBounds(7 / 16D, 0, 6 / 16D, 9 / 16D, 10 / 16D, 8 / 16D);
            t.setNormal(0, 1, 0);
            rb.renderFaceYPos(Blocks.stone, 0, 0, 1 / 16D, null);
        }
        t.draw();

        GL11.glDisable(GL11.GL_CLIP_PLANE0);

        rb.overrideBlockTexture = null;
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderHelper.java

License:Open Source License

public static void renderButton(double x, double y, double z, String res, String resSide) {

    GL11.glPushMatrix();/*from   w  w w .j ava 2s.c  o  m*/
    {
        GL11.glTranslated(x, y, z);

        GL11.glPushMatrix();
        {
            GL11.glTranslated(6 / 16D, 2 / 16D, 8 / 16D);
            Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(resSide));
            for (int i = 0; i < 4; i++) {
                GL11.glTranslated(2 / 16D, 0, 2 / 16D);
                GL11.glRotated(90, 0, 1, 0);
                GL11.glTranslated(-2 / 16D, 0, -2 / 16D);
                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glNormal3d(1, 0, 0);
                    addVertexWithTexture(0, 0, 0, 0, 0);
                    addVertexWithTexture(0, 1 / 16D, 0, 0, 1);
                    addVertexWithTexture(4 / 16D, 1 / 16D, 0, 1, 1);
                    addVertexWithTexture(4 / 16D, 0, 0, 1, 0);
                }
                GL11.glEnd();
            }
        }
        GL11.glPopMatrix();

        GL11.glTranslated(0, 1 / 16D, 0 / 16D);

        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(res));
        Tessellator t = Tessellator.instance;

        y = 2 / 16D;

        t.startDrawingQuads();
        t.setNormal(0, 1, 0);
        {
            t.addVertexWithUV(0, y, 0, 1, 1);
            t.addVertexWithUV(0, y, 1, 1, 0);
            t.addVertexWithUV(1, y, 1, 0, 0);
            t.addVertexWithUV(1, y, 0, 0, 1);
        }
        t.draw();
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderHelper.java

License:Open Source License

/**
 * @author amadornes//  www .j  av  a  2  s  .  c  om
 * @param x
 * @param y
 * @param z
 * @param angle
 */
public static void renderPointer(double x, double y, double z, double angle) {

    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, z);

        GL11.glTranslated(0.5, 0.5, 0.5);
        GL11.glRotated(180 + 360 * -angle, 0, 1, 0);
        GL11.glTranslated(-0.5, -0.5, -0.5);

        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation("minecraft:textures/blocks/stone.png"));

        GL11.glBegin(GL11.GL_QUADS);
        {
            GL11.glNormal3d(0, -1, 0);
            // Bottom
            addVertexWithTexture(0.5, 0, 2D / 16D, 0.5, 1D / 16D);
            addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5);
            addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
            addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5);
            GL11.glNormal3d(0, 1, 0);
            // Top
            addVertexWithTexture(0.5, 1D / 16D, 2D / 16D, 0.5, 1D / 16D);
            addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5);
            addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
            addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5);
            GL11.glNormal3d(1, 0, 0);
            // Side 1
            addVertexWithTexture(0.5, 1D / 16D, 2D / 16D, 0.5, 1D / 16D);
            addVertexWithTexture(0.5, 0, 2D / 16D, 0.5, 1D / 16D);
            addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5);
            addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5);
            // Side 2
            addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5);
            addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5);
            addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
            addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
            GL11.glNormal3d(-1, 0, 0);
            // Side 3
            addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
            addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
            addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5);
            addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5);
            // Side 4
            addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5);
            addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5);
            addVertexWithTexture(0.5, 0, 2D / 16D, 0.5, 1D / 16D);
            addVertexWithTexture(0.5, 1D / 16D, 2D / 16D, 0.5, 1D / 16D);
        }
        GL11.glEnd();

    }
    GL11.glPopMatrix();

}

From source file:com.bluepowermod.client.render.RenderItemEngine.java

License:Open Source License

private void renderEngine(float x, float y, float z, float rotateAmount, float rotatex, float rotatey,
        float rotatez) {

    GL11.glPushMatrix();//  www  . java  2  s. c o m
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glScalef(.034F, .034F, .034F);
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(rotateAmount, rotatex, rotatey, rotatez);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureLocation);

    model.renderAll();

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