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.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override/* ww w . j a  v a2s  .c  om*/
public void renderHandEffect(EntityPlayer player, HandRenderType type, long dt) {
    if (type == HandRenderType.EQUIPPED)
        return;
    if (dt < DELAY)
        return;
    dt -= DELAY;

    double tz = dt * dt / 3e4;
    double TRANS_TIME = ANIM_LEN * 0.2;
    double alpha = (dt < TRANS_TIME ? dt / TRANS_TIME
            : (dt > ANIM_LEN - TRANS_TIME ? (ANIM_LEN - dt) / TRANS_TIME : 1));

    //Draw a screen-filling blackout
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(0, 255, 0, 255);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glDepthMask(false);
    GL11.glLoadIdentity();
    {
        GL11.glTranslated(0, 0, 0);
        GL11.glColor4d(0, 0, 0, 0.2 * alpha);
        HudUtils.setZLevel(1);
        HudUtils.drawModalRect(0, 0, 255, 255);
        HudUtils.setZLevel(-90);
    }
    GL11.glDepthMask(true);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW); //Restore the matrix

    //Draw the real effect

    GL11.glColor4d(1, 1, 1, alpha * 0.6);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(-.4, 0.85 + tz * 0.37, tz);
        GL11.glRotated(-20.4, 1, 0, 0);

        drawSingleSide(7);

        //         GL11.glPushMatrix(); {
        //            GL11.glTranslated(-2.3, 0, 0);
        //            drawSingleSide(7);
        //         } GL11.glPopMatrix();
    }
    GL11.glPopMatrix();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
}

From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java

License:Open Source License

private void drawSingleSide(int n) {
    //line.draw();
    for (int i = n; i >= 0; --i) {
        double z = (4 + 6 * i * i) / 12d;
        GL11.glPushMatrix();/*from www. ja  v  a 2 s .  c o m*/
        GL11.glTranslated(0, 0, -z);
        circle.draw();
        GL11.glPopMatrix();
    }
}

From source file:cn.academy.ability.electro.client.render.skill.SRSmallCharge.java

License:Open Source License

@Override
public void draw() {
    GL11.glDisable(GL11.GL_CULL_FACE);//  w  w w  . java  2s. c  o m
    GL11.glDepthMask(false);
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4d(1, 1, 1, 0.7);

    GL11.glTranslated(0, 0.9, 0.2);
    GL11.glRotated(120, 1, 0, 0);
    GL11.glScaled(0.5, 0.5, 0.5);
    //RenderUtils.drawCube(1, 1, 2);
    for (ArcObject arc : arcs) {
        arc.draw();
    }

    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.academy.ability.teleport.client.render.entity.MarkRender.java

License:Open Source License

@Override
public void doRender(Entity ent, double x, double y, double z, float var8, float var9) {
    EntityTPMarking mark = (EntityTPMarking) ent;
    int texID = (int) ((mark.ticksExisted / 2.5) % tex.length);

    GL11.glEnable(GL11.GL_BLEND);/*from w w w.ja v  a2 s . c o  m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, z);

        GL11.glRotated(-mark.rotationYaw, 0, 1, 0);
        GL11.glScaled(-1, -1, 1);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
        Tessellator.instance.setBrightness(15728880);
        RenderUtils.loadTexture(tex[texID]);
        model.draw();
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.academy.core.client.ACRenderingHelper.java

License:GNU General Public License

private static void dirQuad(double x0, double y0, double x1, double y1, float width) {
    float hw = width / 2;
    Tessellator t = Tessellator.instance;
    double dy = y1 - y0, dx = x1 - x0, len = Math.sqrt(dy * dy + dx * dx);
    double theta = MathUtils.toDegrees(Math.atan2(dy, dx));

    GL11.glPushMatrix();/*ww  w.j av a  2 s.c  om*/
    GL11.glTranslated(x0, y0, 0);
    GL11.glRotated(theta, 0, 0, 1);
    t.startDrawingQuads();
    t.addVertexWithUV(0, -hw, 0, 0, 0);
    t.addVertexWithUV(0, hw, 0, 0, 1);
    t.addVertexWithUV(len, hw, 0, 1, 1);
    t.addVertexWithUV(len, -hw, 0, 1, 0);
    t.draw();
    GL11.glPopMatrix();
}

From source file:cn.academy.core.client.component.Glow.java

License:GNU General Public License

public Glow() {
    super("Glow");

    listen(FrameEvent.class, (w, event) -> {
        if (!writeDepth)
            GL11.glDepthMask(false);/*  ww  w.j  a  v a  2 s. com*/
        GL11.glPushMatrix();
        GL11.glTranslated(0, 0, zLevel);
        ACRenderingHelper.drawGlow(0, 0, w.transform.width, w.transform.height, glowSize, color);
        GL11.glPopMatrix();
        GL11.glDepthMask(true);
    });
}

From source file:cn.academy.core.client.gui.GuiMainScreen.java

License:Open Source License

@Override
public void draw(ScaledResolution sr) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    AbilityData data = AbilityDataMain.getData(player);
    double w = sr.getScaledWidth_double(), h = sr.getScaledHeight_double();
    double size = 80.0, x = w - 80, y = h - 65;
    boolean active = EventHandlerClient.isSkillEnabled();
    long time = Minecraft.getSystemTime();

    GL11.glEnable(GL11.GL_BLEND);//from   w w w.ja  v a2  s.  com
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {
        GL11.glPushMatrix();
        { //Logo rendering
            double scale = .25;
            double mAlpha = active ? 0.8 : 0.4;
            HudUtils.setTextureResolution(256, 256);

            GL11.glTranslated(w - 80, h - 70, 0);
            GL11.glScaled(scale, scale, 1);

            GL11.glColor4d(1, 1, 1, mAlpha);
            logoBack.draw();

            GL11.glColor4d(1, 1, 1, (mAlpha * 1.25) * (0.7 + Math.sin(time / 900D) * 0.3));
            logoRays.draw();

            GL11.glColor4d(1, 1, 1, mAlpha);
            logoBack.draw();
            logoFrame.draw();

            RenderUtils.loadTexture(data.getCategory().getLogo());
            HudUtils.drawRect(63, 63, 129, 129);

            logoGeom.getTransform().setRoll(time / 1000D);
            logoGeom.draw();
        }
        GL11.glPopMatrix();
        RenderUtils.bindIdentity();

        //CPBar rendering
        if (active) {
            lastActiveTime = time;
        } else {
            lastInactiveTime = time;
        }
        double mAlpha = active ? Math.min((time - lastInactiveTime) / 300D, 1.0)
                : Math.max((300 + lastActiveTime - time) / 300D, 0.0);

        if (mAlpha > 0) {
            //Cooldown
            drawCooldownBars(data, mAlpha, w, h);

            GL11.glColor4d(1, 1, 1, mAlpha * 0.6);
            RenderUtils.loadTexture(ACClientProps.TEX_HUD_BAR);
            HudUtils.setTextureResolution(512, 200);
            double scale = .4;
            GL11.glTranslated(w - 193, 17, 0);
            GL11.glScaled(scale, scale, 0);
            //Back
            HudUtils.drawRect(0, 0, 0, 73, 455, 127, 455, 127);

            //CPBar
            double prog = data.getCurrentCP() / data.getMaxCP();
            int[] cs = data.getCategory().getColorStyle();
            RenderUtils.bindColor(cs[0], cs[1], cs[2], (int) (mAlpha * 255));
            HudUtils.drawRect(439 - 436 * prog, 3, 439 - 436 * prog, 4, 436 * prog, 28, 436 * prog, 28);

            //CPBar glow
            double alpha = Math.max(0, (prog - 0.6) / 0.4);
            GL11.glColor4d(1, 1, 1, alpha * mAlpha);
            HudUtils.drawRect(3, 3, 3, 42, 436, 28, 436, 28);

            //Chip
            HudUtils.drawRect(269, 46, 478, 40, 26, 26, 26, 26);
            alpha = 0.5 + 0.5 * Math.sin(Minecraft.getSystemTime() / 500D);
            RenderUtils.bindColor(cs[0], cs[1], cs[2], (int) (alpha * mAlpha * 255)); //Chip glow light
            HudUtils.drawRect(266, 45, 474, 5, 32, 32, 32, 32);

            //Level
            GL11.glColor4d(1, 1, 1, mAlpha * .6);
            ACClientProps.FONT_YAHEI_32.drawAdjusted(data.getLevel().getDisplayName(), 184, 58, 20, 69);

            //Numeric CP
            String str = String.format("%.0f/%.0f", data.getCurrentCP(), data.getMaxCP());
            font.drawAdjusted(str, 316, 87, 22, Align.CENTER, 167);
        }
    }
    GL11.glPopMatrix();
    RenderUtils.bindIdentity();
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:cn.academy.core.client.gui.GuiMainScreen.java

License:Open Source License

private void drawCooldownBars(AbilityData data, double mAlpha, double w, double h) {
    final double len = 100;
    final double fSize = 7, step = 17;

    double y0 = 0;
    Iterator<Map.Entry<Integer, Pair<Integer, Long>>> iter = aliveCooldowns.entrySet().iterator();

    long time = Minecraft.getSystemTime();

    GL11.glPushMatrix();//ww w. j ava 2s  .c  om

    GL11.glTranslated(w - 120, h - 90, 0);

    while (iter.hasNext()) {
        Map.Entry<Integer, Pair<Integer, Long>> ent = iter.next();
        Pair<Integer, Long> dt = ent.getValue();

        SkillBase sb = data.getSkill(ent.getKey());
        if (sb != null) {
            GL11.glColor4d(1, 1, 1, mAlpha);
            String name = sb.getDisplayName();
            double prog = 1 - Math.min(1, (double) (time - dt.second) / dt.first);
            ACUtils.drawText(name, len, y0, fSize, Align.RIGHT);
            GL11.glColor4d(.3, .3, .3, mAlpha);
            HudUtils.drawModalRect(0, y0 + 10, len, 2.3);
            double l = len * prog;
            GL11.glColor4d(.8, .8, .8, mAlpha);
            HudUtils.drawModalRect(len - l, y0 + 10, l, 2.3);
            y0 -= step;
        }

        if (time - dt.second > dt.first) {
            iter.remove();
        }
    }

    GL11.glPopMatrix();
}

From source file:cn.academy.core.client.gui.GuiPresetSelect.java

License:Open Source License

@Override
public void draw(ScaledResolution sr) {
    int h = sr.getScaledHeight(), w = sr.getScaledWidth();
    GL11.glEnable(GL11.GL_BLEND);//from w w  w  .  jav  a2 s . co m
    GL11.glPushMatrix();
    {
        float x0 = w / 2F, y0 = h / 2F, scale = 0.32F;
        GL11.glTranslated(0, -5, 0);
        GL11.glTranslatef(x0, y0, 0);
        GL11.glScalef(scale, scale, 1);

        HudUtils.setTextureResolution(768, 512);
        RenderUtils.loadTexture(ACClientProps.TEX_GUI_PRESET);
        long dt = Minecraft.getSystemTime() - lastOpenTime;
        drawSelectionMenu(w, h, dt);
        drawPresetInfo(w, h, dt);
        drawTag(w, h, dt);
    }
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:cn.academy.core.client.gui.GuiPresetSelect.java

License:Open Source License

private void drawTag(int w, int h, long dt) {
    double dx = 0;
    double mAlpha;
    mAlpha = Math.min(1.0, dt / 300d);
    final double delta = 30;
    if (dt < 200) {
        dx = delta;/*ww  w  .  j  av  a  2s  .c  o  m*/
    } else if (dt < 400) {
        dx = -(delta / 200) * (dt - 200) + delta;
    } else {
        dt = 0;
    }
    GL11.glPushMatrix();
    GL11.glTranslated(dx, 0, 0);
    GL11.glColor4d(1, 1, 1, mAlpha);
    rect(1, -28, 399, 87, 162, 28);
    GL11.glColor4d(.2, .2, .2, mAlpha * .8);
    drawText(ACLangs.presetSelect(), 15, -25, 17);
    GL11.glPopMatrix();
}