Example usage for org.lwjgl.opengl GL11 glPushMatrix

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

Introduction

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

Prototype

public static native void glPushMatrix();

Source Link

Document

Pushes the current matrix stack down by one, duplicating the current matrix in both the top of the stack and the entry below it.

Usage

From source file:cn.weaponmod.api.client.render.RenderBulletWeapon.java

License:Open Source License

public void renderEquipped(ItemStack item, RenderBlocks render, EntityLivingBase entity) {
    Tessellator t = Tessellator.instance;

    int mode = 0;
    if (item.stackTagCompound != null)
        mode = item.getTagCompound().getInteger("mode");

    GL11.glPushMatrix();

    InformationBullet inf = (InformationBullet) weaponType.getInformation(item, entity.worldObj);
    if (inf == null) {
        RenderUtils.renderItemIn2d(item, width);
        return;/* ww  w  .ja v a 2 s  . c  o  m*/
    }

    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        boolean left = ItemControlHandler.getUsingTickLeft(player, false) == 0 ? true
                : ItemControlHandler.getUsingSide(player);
        boolean firstPerson = (entity == Minecraft.getMinecraft().thePlayer
                && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
                && Minecraft.getMinecraft().currentScreen == null;
        int mt = inf == null ? -1 : (left ? inf.muzzle_left : inf.muzzle_right);
        if (left ? inf.lastShooting_left : inf.lastShooting_right) {
            int dt = inf.getDeltaTick(left);
            float recoverTime = 0.5F * weaponType.upLiftRadius / weaponType.recoverRadius;
            if (dt < recoverTime) {
                float uplift = 2.0F * weaponType.upLiftRadius
                        * MathHelper.cos(mt * (float) Math.PI / recoverTime);
                GL11.glRotatef(uplift, 0.0F, 0.0F, 1.0F);
            }
        }

        if (mt > 0) {
            mt = 3 - mt;
            RenderBulletWeapon.renderMuzzleflashIn2d(t,
                    muzzleflash[mt < muzzleflash.length ? mt : muzzleflash.length - 1], tx, ty, tz);
        }

        if (firstPerson && inf.isReloading) {
            float rotation = weaponType.getRotationForReload(item);
            if (reloadAnimStyle == 0)
                GL11.glRotatef(upliftRatio * rotation * 75F, 0.0F, 1.0F, 0.0F);
            else if (reloadAnimStyle == 1) {
                GL11.glRotatef(upliftRatio * rotation * 17F, 0.0F, 0.0F, -1.0F);
                GL11.glRotatef(upliftRatio * rotation * 30F, 0.0F, -1.0F, 0.0F);
                GL11.glRotatef(upliftRatio * rotation * 14F, 1.0F, 0.0F, 0.0F);
            }
        }
    }
    RenderUtils.renderItemIn2d(item, width);
    GL11.glPopMatrix();
}

From source file:cn.weaponmod.api.client.render.RenderBulletWeapon.java

License:Open Source License

public static void renderMuzzleflashIn2d(Tessellator t, String texture, double tx, double ty, double tz) {

    Vec3 a1 = RenderUtils.newV3(1.2, -0.4, -0.5), a2 = RenderUtils.newV3(1.2, 0.4, -0.5),
            a3 = RenderUtils.newV3(1.2, 0.4, 0.3), a4 = RenderUtils.newV3(1.2, -0.4, 0.3);

    float u1 = 0.0F, v1 = 0.0F, u2 = 1.0F, v2 = 1.0F;

    t = Tessellator.instance;//from w  ww. j a  v a  2 s . co  m
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(texture);

    GL11.glRotatef(45, 0.0F, 0.0F, 1.0F);
    GL11.glTranslated(tx, ty + 0.1F, tz + 0.1F);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setColorRGBA_F(0.8F, .8F, .8F, 1.0F);
    t.setBrightness(15728880);
    addVertex(a1, u2, v2);
    addVertex(a2, u2, v1);
    addVertex(a3, u1, v1);
    addVertex(a4, u1, v2);
    t.draw();

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

}

From source file:cn.weaponmod.api.client.render.RenderDualWieldWeapon.java

License:Open Source License

@Override
public void renderEquipped(ItemStack item, RenderBlocks render, EntityLivingBase entity, ItemRenderType type) {

    GL11.glPushMatrix();

    super.doRenderEquipped(item, render, entity, false, type);

    boolean firstPerson = (entity == Minecraft.getMinecraft().thePlayer
            && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
            && Minecraft.getMinecraft().currentScreen == null;

    GL11.glTranslatef(0.0F, 0.0F, firstPerson ? -1.7F : 0.8F);
    GL11.glScalef(1.0F, 1.0F, -1.0F);/*ww w.j  a  v a  2s.c  o m*/

    GL11.glDisable(GL11.GL_CULL_FACE);
    super.doRenderEquipped(item, render, entity, true, type);
    GL11.glEnable(GL11.GL_CULL_FACE);

    GL11.glPopMatrix();

}

From source file:cn.weaponmod.api.client.render.RenderDualWieldWeapon.java

License:Open Source License

@Override
public void renderInventory() {
    GL11.glPushMatrix();
    GL11.glTranslatef(-1.5F, -3F, -6.0F);
    super.renderInventory();

    GL11.glTranslatef(3.0F, 3.0F, 6.0F);
    GL11.glRotatef(20, 0.0F, 1.0F, 0.0F);
    super.renderInventory();
    GL11.glPopMatrix();//  ww  w  . j  a v  a2s  .c  o m
}

From source file:cn.weaponmod.api.client.render.RendererBulletWeapon.java

License:Open Source License

public static void renderMuzzleflashIn2d(Tessellator t, ResourceLocation texture, double tx, double ty,
        double tz, float size) {
    Vec3 a1 = RenderUtils.newV3(1.2, -0.4, -0.5), a2 = RenderUtils.newV3(1.2, 0.4, -0.5),
            a3 = RenderUtils.newV3(1.2, 0.4, 0.3), a4 = RenderUtils.newV3(1.2, -0.4, 0.3);

    float u1 = 0.0F, v1 = 0.0F, u2 = 1.0F, v2 = 1.0F;

    t = Tessellator.instance;/*w  ww .  j a  v  a  2s. c o  m*/
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(texture);

    GL11.glRotatef(45, 0.0F, 0.0F, 1.0F);
    GL11.glTranslated(tx, ty + 0.1F, tz + 0.1F);
    GL11.glScalef(size, size, size);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setBrightness(15728880);
    addVertex(a1, u2, v2);
    addVertex(a2, u2, v1);
    addVertex(a3, u1, v1);
    addVertex(a4, u1, v2);
    t.draw();

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

From source file:cn.weaponmod.api.client.render.RendererBulletWeapon.java

License:Open Source License

@Override
protected void renderWeapon(ItemStack stack, EntityPlayer pl, ItemRenderType type) {
    Tessellator t = Tessellator.instance;

    GL11.glPushMatrix();
    RenderUtils.renderItemIn2d(stack, width);
    GL11.glPopMatrix();/*from  w  ww .  j  a v a 2  s.c o  m*/
}

From source file:cn.weaponry.api.client.render.PartedModel.java

License:Open Source License

public void renderAll(String exception) {
    GL11.glPushMatrix();
    {/*from w w w .j  av  a2  s. c  o m*/
        transformAll.doTransform();
        for (String s : transformData.keySet()) {
            if (!s.equals(exception))
                renderPart(s);
            //System.out.println("render part " + s);
        }
    }
    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.PartedModel.java

License:Open Source License

/**
 * Render the part at the origin, then peform the following transform sequence:
 * move to pivot->scale->rotate->transform->move back from pivot
 * @throws NullPointerException if no such model part
 * @param name The part name/*from   w w  w  .java  2 s .  c o  m*/
 */
public void renderPart(String name) {
    CompTransform t = transformData.get(name);
    GL11.glPushMatrix();

    t.doTransform();
    renderAtCenter(name);

    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.RendererWeapon.java

License:Open Source License

private void handleHeldRender(RenderInfo info, boolean firstPerson) {
    GL11.glPushMatrix();
    model.pushTransformState();/* w  ww.  ja v a  2  s .c o m*/
    {

        if (firstPerson) {
            doFirstPersonTansform();
            fpTransform.doTransform();
        } else {
            doThirdPersonTransform();
            tpTransform.doTransform();
        }
        stdTransform.doTransform();
        doFixedTransform();

        info.renderAll(model, firstPerson, 0);

        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        info.renderAll(model, firstPerson, 1);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();

        GL11.glDisable(GL11.GL_CULL_FACE);

        RenderUtils.loadTexture(texture);
        model.renderAll();
        GL11.glEnable(GL11.GL_CULL_FACE);
    }
    model.popTransformState();
    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.RendererWeapon.java

License:Open Source License

private void handleSimpleRender(ItemStack stack) {
    GL11.glPushMatrix();
    {/*from   w  ww . j a va 2s.  co  m*/
        stdTransform.doTransform();
        doFixedTransform();
        RenderUtils.loadTexture(texture);
        model.renderAll();
    }
    GL11.glPopMatrix();
}