Example usage for org.lwjgl.opengl GL11 glScalef

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

Introduction

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

Prototype

public static native void glScalef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y,
        @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a general scaling matrix along the x-, y- and z- axes.

Usage

From source file:mattparks.mods.starcraft.titan.client.SCTitanSkyProvider.java

License:LGPL

@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from  www  .j  av  a  2 s  . c om
    Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks);
    float f1 = (float) vec3.xCoord;
    float f2 = (float) vec3.yCoord;
    float f3 = (float) vec3.zCoord;
    float f6;

    if (mc.gameSettings.anaglyph) {
        float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f4;
        f2 = f5;
        f3 = f6;
    }

    GL11.glColor3f(f1, f2, f3);
    Tessellator tessellator1 = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glColor3f(f1, f2, f3);
    GL11.glCallList(this.glSkyList);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    //        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    RenderHelper.disableStandardItemLighting();
    float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks),
            partialTicks);
    float f7;
    float f8;
    float f9;
    float f10;

    float f18 = world.getStarBrightness(partialTicks);

    if (f18 > 0.0F) {
        GL11.glColor4f(f18, f18, f18, f18);
        GL11.glCallList(this.starList);
    }

    afloat = new float[4];
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glPushMatrix();
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    afloat[0] = 255 / 255.0F;
    afloat[1] = 194 / 255.0F;
    afloat[2] = 180 / 255.0F;
    afloat[3] = 0.3F;
    f6 = afloat[0];
    f7 = afloat[1];
    f8 = afloat[2];
    float f11;
    float var12;

    if (mc.gameSettings.anaglyph) {
        f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
        f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
        f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
        f6 = f9;
        f7 = f10;
        f8 = f11;
    }

    final Tessellator var23 = Tessellator.instance;
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * 2);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    byte b0 = 16;
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render sun aura
    f10 = 20.0F;
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex((double) f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) f10 * 1.5F);
    tessellator1.addVertex((double) -f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);

    tessellator1.draw();
    tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3]);
    tessellator1.addVertex(0.0D, 100.0D, 0.0D);
    tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);

    // Render larger sun aura
    f10 = 40.0F;
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) -f10 * 1.5F);
    tessellator1.addVertex((double) f10, 200.0D, (double) -f10);
    tessellator1.addVertex((double) f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) 0, 200.0D, (double) f10 * 1.5F);
    tessellator1.addVertex((double) -f10, 200.0D, (double) f10);
    tessellator1.addVertex((double) -f10 * 1.5F, 200.0D, (double) 0);
    tessellator1.addVertex((double) -f10, 200.0D, (double) -f10);

    tessellator1.draw();
    GL11.glPopMatrix();
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    //        OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glPushMatrix();
    f7 = 0.0F;
    f8 = 0.0F;
    f9 = 0.0F;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef(f7, f8, f9);
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
    // Render sun
    f10 = 14.0F;
    mc.renderEngine.bindTexture(sunTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV((double) (-f10), 450.0D, (double) (-f10), 0.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 450.0D, (double) (-f10), 1.0D, 0.0D);
    tessellator1.addVertexWithUV((double) f10, 450.0D, (double) f10, 1.0D, 1.0D);
    tessellator1.addVertexWithUV((double) (-f10), 450.0D, (double) f10, 0.0D, 1.0D);
    tessellator1.draw();

    // saturn:
    var12 = 10.0F;
    final float saturnRotation = (float) (world.getSpawnPoint().posZ - mc.thePlayer.posZ) * 0.01F;
    GL11.glRotatef(-180.0F, 0.0F, 1.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 5F);
    GL11.glRotatef(world.getCelestialAngle(partialTicks) * 100.0F, 1.0F, 0.0F, 0.0F);
    var12 = 30.0F;
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SCTitanSkyProvider.saturnTexture);
    var23.startDrawingQuads();
    var23.addVertexWithUV(-var12, 75.0D, -var12, 0.0D, 0.0D);
    var23.addVertexWithUV(var12, 75.0D, -var12, 1.0D, 0.0D);
    var23.addVertexWithUV(var12, 75.0D, var12, 1.0D, 1.0D);
    var23.addVertexWithUV(-var12, 75.0D, var12, 0.0D, 1.0D);
    var23.draw();

    // Render earth
    f10 = 0.5F;
    GL11.glScalef(0.6F, 0.6F, 0.6F);
    GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(SCTitanSkyProvider.overworldTexture);
    tessellator1.startDrawingQuads();
    tessellator1.addVertexWithUV(-f10, -100.0D, f10, 0, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, f10, 1, 1);
    tessellator1.addVertexWithUV(f10, -100.0D, -f10, 1, 0);
    tessellator1.addVertexWithUV(-f10, -100.0D, -f10, 0, 0);
    tessellator1.draw();

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(0.0F, 0.0F, 0.0F);
    double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();

    if (d0 < 0.0D) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 12.0F, 0.0F);
        GL11.glCallList(this.glSkyList2);
        GL11.glPopMatrix();
        f8 = 1.0F;
        f9 = -((float) (d0 + 65.0D));
        f10 = -f8;
        tessellator1.startDrawingQuads();
        tessellator1.setColorRGBA_I(0, 255);
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) f8);
        tessellator1.addVertex((double) f8, (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f9, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) (-f8));
        tessellator1.addVertex((double) (-f8), (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) f8);
        tessellator1.addVertex((double) f8, (double) f10, (double) (-f8));
        tessellator1.draw();
    }

    if (world.provider.isSkyColored()) {
        GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
    } else {
        GL11.glColor3f(f1, f2, f3);
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GL11.glCallList(this.glSkyList2);
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(true);
}

From source file:mca.client.gui.GuiHardcoreGameOver.java

License:Open Source License

@Override
public void drawScreen(int x, int y, float offset) {
    drawGradientRect(0, 0, width, height, 0x60500000, 0xa0803030);

    //Scale and draw the screen title.
    GL11.glPushMatrix();// w ww  .j a  v a2 s.  c  o m
    GL11.glScalef(2.0F, 2.0F, 2.0F);

    if (mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) {
        drawCenteredString(fontRendererObj, StatCollector.translateToLocal("deathScreen.title.hardcore"),
                width / 2 / 2, 30, 0xffffff);
    }

    else {
        drawCenteredString(fontRendererObj, StatCollector.translateToLocal("deathScreen.title"), width / 2 / 2,
                30, 0xffffff);
    }

    GL11.glPopMatrix();

    //Add hardcore mode info and score.
    if (mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) {
        drawCenteredString(fontRendererObj, StatCollector.translateToLocal("deathScreen.hardcoreInfo"),
                width / 2, 80, 0xffffff);
        drawCenteredString(fontRendererObj,
                MCA.getInstance().getLanguageLoader().getString("gui.info.hardcoresecret.prompt"), width / 2,
                144, 0xffffff);
    }

    drawCenteredString(fontRendererObj,
            (new StringBuilder()).append(StatCollector.translateToLocal("deathScreen.score")).append(": \247e")
                    .append(mc.thePlayer.getScore()).toString(),
            width / 2, 100, 0xffffff);

    if (delayTicks != 0) {
        delayTicks--;
    }

    else {
        GuiButton testButton = (GuiButton) this.buttonList.get(0);

        if (!testButton.enabled) {
            for (int i = 0; i < this.buttonList.size(); i++) {
                GuiButton button = (GuiButton) this.buttonList.get(i);
                button.enabled = true;

                if (shiftIndexLeftButton != null) {
                    if (adultChildren.isEmpty()) {
                        shiftIndexLeftButton.enabled = false;
                        shiftIndexRightButton.enabled = false;
                        selectedChildButton.enabled = false;
                        respawnAsChildButton.enabled = false;
                    }
                }
            }
        }
    }

    super.drawScreen(x, y, offset);
}

From source file:mca.client.gui.GuiInteraction.java

License:Open Source License

@Override
public void drawScreen(int i, int j, float f) {
    int marriageIconU = villager.getIsMarried() ? 0 : villager.getIsEngaged() ? 64 : 16;
    int parentsIconU = 32;
    int giftIconU = 48;

    GL11.glPushMatrix();/* ww  w.  j a  va2  s  . c o  m*/
    {
        GL11.glColor3f(255.0F, 255.0F, 255.0F);
        GL11.glScalef(2.0F, 2.0F, 2.0F);

        RenderHelper.drawTexturedRectangle(new ResourceLocation("mca:textures/gui.png"), 5, 30, marriageIconU,
                0, 16, 16);

        if (doDrawParentsIcon()) {
            RenderHelper.drawTexturedRectangle(new ResourceLocation("mca:textures/gui.png"), 5, 45,
                    parentsIconU, 0, 16, 16);
        }

        if (doDrawGiftIcon()) {
            RenderHelper.drawTexturedRectangle(new ResourceLocation("mca:textures/gui.png"), 5, 60, giftIconU,
                    0, 16, 16);
        }
    }
    GL11.glPopMatrix();

    if (playerData.isSuperUser.getBoolean()) {
        RenderHelper.drawTextPopup(Color.WHITE + "You are a superuser.", 10, height - 16);
    }

    if (displayMarriageInfo) {
        String phraseId = villager.getSpouseName().equals(player.getCommandSenderName())
                && villager.getIsEngaged()
                        ? "gui.info.family.engagedtoplayer"
                        : villager.getSpouseName().equals(player.getCommandSenderName())
                                ? "gui.info.family.marriedtoplayer"
                                : villager.getIsMarried() ? "gui.info.family.married"
                                        : villager.getIsEngaged() ? "gui.info.family.engaged"
                                                : "gui.info.family.notmarried";

        //Always include the villager's spouse name in case %a1% will be provided.
        RenderHelper.drawTextPopup(MCA.getLanguageManager().getString(phraseId, villager.getSpouseName()), 49,
                73);
    }

    if (displayParentsInfo) {
        List<String> displayList = new ArrayList<String>();

        String fatherString = "gui.info.family.father";
        String motherString = "gui.info.family.mother";

        if (villager.getFatherName().equals(player.getCommandSenderName())) {
            fatherString += ".you";
        }

        else if (villager.getMotherName().equals(player.getCommandSenderName())) {
            motherString += ".you";
        }

        displayList.add(MCA.getLanguageManager().getString(fatherString, villager.getFatherName()));
        displayList.add(MCA.getLanguageManager().getString(motherString, villager.getMotherName()));

        RenderHelper.drawTextPopup(displayList, 49, 97);
    }

    if (displayGiftInfo) {
        List<String> displayList = new ArrayList<String>();
        displayList.add(MCA.getLanguageManager().getString("gui.info.gift.line1"));
        displayList.add(MCA.getLanguageManager().getString("gui.info.gift.line2"));

        RenderHelper.drawTextPopup(displayList, 49, 129);
    }

    String moodString = MCA.getLanguageManager().getString("gui.info.mood",
            villager.getAI(AIMood.class).getMood(villager.getPersonality()).getFriendlyName());
    String personalityString = MCA.getLanguageManager().getString("gui.info.personality",
            villager.getPersonality().getFriendlyName());

    RenderHelper.drawTextPopup(moodString, 18, 29);
    RenderHelper.drawTextPopup(personalityString, 18, 46);

    if (villager.getProfessionGroup() == EnumProfessionGroup.Child) {
        if (villager.getIsChild()) {
            //Relative to the growth scale, divide by 0.02.
            int age = (int) (villager.getIsMale() ? 0.39F
                    : 0.37F / MCA.getConfig().childGrowUpTime * villager.getAge() / 0.02F);

            if (age < 4) {
                age = 4;
            }

            RenderHelper.drawTextPopup("Age: " + age, 18, 11);
        }

        else {
            RenderHelper.drawTextPopup("Age: Adult", 18, 11);
        }
    }

    if (displaySuccessChance) {
        for (Object obj : buttonList) {
            try {
                GuiButton button = (GuiButton) obj;
                EnumInteraction interaction = EnumInteraction.fromId(button.id);

                int successChance = interaction.getSuccessChance(villager, memory);
                successChance = successChance < 0 ? 0 : successChance;

                if (interaction.getBaseChance() != 0) {
                    RenderHelper.drawTextPopup(successChance + "%", button.xPosition - 30,
                            button.yPosition + 6);
                }
            }

            catch (Exception e) {
                continue;
            }
        }
    }

    super.drawScreen(i, j, f);
}

From source file:mca.client.render.RenderFishHook.java

License:Open Source License

/**
 * Renders the fish hook in the world./*from  ww  w  .  j  a va  2 s .  c om*/
 * 
 * @param    entityFishHook   The fish hook being rendered.
 * @param    posX         The x position the hook is being rendered at.
 * @param    posY         The y position the hook is being rendered at.
 * @param    posZ         The z position the hook is being rendered at.
 * @param    angle         The angle relative to the angler that the hook is rendered at.
 * @param    offsetY         The y offset of the hook.
 */
public void doRenderFishHook(EntityChoreFishHook entityFishHook, double posX, double posY, double posZ,
        float angle, float offsetY) {
    GL11.glPushMatrix();
    GL11.glTranslatef((float) posX, (float) posY, (float) posZ);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glScalef(0.5F, 0.5F, 0.5F);

    this.bindEntityTexture(entityFishHook);

    final Tessellator tessellator = Tessellator.instance;
    final float textureSizeU = (1 * 8 + 0) / 128.0F;
    final float textureSizeV = (1 * 8 + 8) / 128.0F;
    final float textureLocationX = (2 * 8 + 0) / 128.0F;
    final float textureLocationY = (2 * 8 + 8) / 128.0F;

    GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    tessellator.addVertexWithUV(0.0F - 0.5F, 0.0F - 0.5F, 0.0D, textureSizeU, textureLocationY);
    tessellator.addVertexWithUV(1.0F - 0.5F, 0.0F - 0.5F, 0.0D, textureSizeV, textureLocationY);
    tessellator.addVertexWithUV(1.0F - 0.5F, 1.0F - 0.5F, 0.0D, textureSizeV, textureLocationX);
    tessellator.addVertexWithUV(0.0F - 0.5F, 1.0F - 0.5F, 0.0D, textureSizeU, textureLocationX);
    tessellator.draw();

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();

    if (entityFishHook.angler != null) {
        final float orientation = MathHelper
                .sin(MathHelper.sqrt_float(entityFishHook.angler.getSwingProgress(offsetY)) * (float) Math.PI);

        final Vec3 vec3 = entityFishHook.worldObj.getWorldVec3Pool().getVecFromPool(-0.5D, 0.03D, 0.8D);
        vec3.rotateAroundX(-(entityFishHook.angler.prevRotationPitch
                + (entityFishHook.angler.rotationPitch - entityFishHook.angler.prevRotationPitch) * offsetY)
                * (float) Math.PI / 180.0F);
        vec3.rotateAroundY(-(entityFishHook.angler.prevRotationYaw
                + (entityFishHook.angler.rotationYaw - entityFishHook.angler.prevRotationYaw) * offsetY)
                * (float) Math.PI / 180.0F);
        vec3.rotateAroundY(orientation * 0.5F);
        vec3.rotateAroundX(-orientation * 0.7F);

        double correctedPosX = entityFishHook.angler.prevPosX
                + (entityFishHook.angler.posX - entityFishHook.angler.prevPosX) * (double) offsetY
                + vec3.xCoord;
        double correctedPosY = entityFishHook.angler.prevPosY
                + (entityFishHook.angler.posY - entityFishHook.angler.prevPosY) * (double) offsetY
                + vec3.yCoord;
        double correctedPosZ = entityFishHook.angler.prevPosZ
                + (entityFishHook.angler.posZ - entityFishHook.angler.prevPosZ) * (double) offsetY
                + vec3.zCoord;

        float scale = 0.7F;

        if (entityFishHook.angler instanceof EntityPlayerChild) {
            final int age = ((AbstractChild) entityFishHook.angler).age;
            scale = 0.55F + 0.39F / MCA.getInstance().getModProperties().kidGrowUpTimeMinutes * age;
        }

        final float offsetYaw = (entityFishHook.angler.prevRenderYawOffset
                + (entityFishHook.angler.renderYawOffset - entityFishHook.angler.prevRenderYawOffset) * offsetY)
                * (float) Math.PI / 180.0F;
        final double sinOffsetYaw = MathHelper.sin(offsetYaw);
        final double cosOffsetYaw = MathHelper.cos(offsetYaw);
        correctedPosX = entityFishHook.angler.prevPosX
                + (entityFishHook.angler.posX - entityFishHook.angler.prevPosX) * offsetY - cosOffsetYaw * 0.35D
                - sinOffsetYaw * 0.85D;
        correctedPosY = entityFishHook.angler.prevPosY + scale * 1.6
                + (entityFishHook.angler.posY - entityFishHook.angler.prevPosY) * offsetY - 0.45D;
        correctedPosZ = entityFishHook.angler.prevPosZ
                + (entityFishHook.angler.posZ - entityFishHook.angler.prevPosZ) * offsetY - sinOffsetYaw * 0.35D
                + cosOffsetYaw * 0.85D;

        final double distX = entityFishHook.prevPosX
                + (entityFishHook.posX - entityFishHook.prevPosX) * (double) offsetY;
        final double distY = entityFishHook.prevPosY
                + (entityFishHook.posY - entityFishHook.prevPosY) * (double) offsetY + 0.25D;
        final double distZ = entityFishHook.prevPosZ
                + (entityFishHook.posZ - entityFishHook.prevPosZ) * (double) offsetY;
        final double correctionX = (double) ((float) (correctedPosX - distX));
        final double correctionY = (double) ((float) (correctedPosY - distY));
        final double correctionZ = (double) ((float) (correctedPosZ - distZ));

        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        tessellator.startDrawing(3);
        tessellator.setColorOpaque_I(0);

        for (int loop = 0; loop <= 16; ++loop) {
            final float unknown = (float) loop / (float) 16;
            tessellator.addVertex(posX + correctionX * unknown,
                    posY + correctionY * (unknown * unknown + unknown) * 0.5D + 0.25D,
                    posZ + correctionZ * unknown);
        }

        tessellator.draw();
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
}

From source file:mca.client.render.RenderHuman.java

License:Open Source License

@Override
protected void preRenderCallback(EntityLivingBase entityLivingBase, float partialTickTime) {
    final EntityHuman entity = (EntityHuman) entityLivingBase;
    final AISleep sleepAI = entity.getAI(AISleep.class);
    float scale = entity.getIsMale() ? Constants.SCALE_M_ADULT : Constants.SCALE_F_ADULT;

    if (entity.getIsChild()) {
        final boolean doGradualGrowth = MCA.getConfig().isAgingEnabled;
        final float growthFactor = (entity.getIsMale() ? 0.39F : 0.37F) / MCA.getConfig().childGrowUpTime
                * entity.getAge();/* ww w .j  a  v  a2s  . com*/

        scale = 0.55F + growthFactor;

        if (entityLivingBase.ridingEntity != null) {
            GL11.glTranslated(0.0D, (1.0D + growthFactor) + growthFactor, 0.2D);
        }
    }

    GL11.glScalef(scale, scale + entity.getHeight(), scale);
    GL11.glScalef(scale + entity.getGirth(), scale, scale + entity.getGirth());

    if (sleepAI.getIsInBed()) {
        renderHumanSleeping(entity, partialTickTime);
    }

    else if (entityLivingBase.ridingEntity != null) {
        GL11.glTranslated(0.0D, 0.55D, 0.1D);
    }
}

From source file:mca.client.render.RenderHuman.java

License:Open Source License

private void renderHuman(EntityHuman entity, double posX, double posY, double posZ, float rotationYaw,
        float rotationPitch) {
    final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    final PlayerMemory memory = entity.getPlayerMemoryWithoutCreating(player);

    if (!entity.getDoDisplay()) {
        return;/*from   w  ww .ja v a  2  s  .c  om*/
    }

    //Pass special renders according to player memory here.
    if (RadixMath.getDistanceToEntity(entity, player) <= 5.0F && !entity.getAI(AISleep.class).getIsSleeping()
            && !entity.displayNameForPlayer && memory != null) {
        UVPoint uvp = memory.doDisplayFeedback() ? (memory.getLastInteractionSuccess() ? plus : minus)
                : memory.getHasQuest() ? exMark : null;

        if (uvp != null) {
            GL11.glPushMatrix();
            {
                GL11.glTranslatef((float) posX, (float) posY + entity.height + 0.25F + 0.5F, (float) posZ);
                GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
                GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
                GL11.glScalef(-LABEL_SCALE, -LABEL_SCALE, LABEL_SCALE);
                GL11.glDisable(GL11.GL_LIGHTING);
                GL11.glTranslatef(0.0F, 0.25F / LABEL_SCALE, 0.0F);
                RenderHelper.drawTexturedRectangle(gui, (int) posX, (int) posY + 12, uvp.getU(), uvp.getV(),
                        uvp.getWidth(), uvp.getHeight());
            }
            GL11.glPopMatrix();

            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_LIGHTING);
        }
    }

    double posYCorrection = posY - entity.yOffset;
    shadowOpaque = 1.0F;

    final ItemStack heldItem = entity.getHeldItem();
    modelArmorPlate.heldItemRight = modelArmor.heldItemRight = modelBipedMain.heldItemRight = heldItem == null
            ? 0
            : 1;
    modelArmorPlate.isSneak = modelArmor.isSneak = modelBipedMain.isSneak = entity.isSneaking();

    if (heldItem != null) {
        final EnumAction useAction = heldItem.getItemUseAction();

        if (useAction == EnumAction.bow) {
            modelArmorPlate.aimedBow = modelArmor.aimedBow = modelBipedMain.aimedBow = true;
        }
    }

    if (entity.isSneaking()) {
        posYCorrection -= 0.125D;
    }

    super.doRender(entity, posX, posYCorrection, posZ, rotationYaw, rotationPitch);
    modelArmorPlate.aimedBow = modelArmor.aimedBow = modelBipedMain.aimedBow = false;
    modelArmorPlate.isSneak = modelArmor.isSneak = modelBipedMain.isSneak = false;
    modelArmorPlate.heldItemRight = modelArmor.heldItemRight = modelBipedMain.heldItemRight = 0;
}

From source file:mca.client.render.RenderHuman.java

License:Open Source License

private void renderHearts(EntityHuman human, double posX, double posY, double posZ, int heartsLevel) {
    try {/*from  w w  w.ja v a  2 s.  c o m*/
        //Clamp to 10 first to calculate gold hearts.
        int clampedHearts = RadixMath.clamp(((Math.abs(heartsLevel) + 5) / 10), 0, 10);
        final boolean isNegative = heartsLevel < 0;
        int goldHearts = isNegative ? 0 : clampedHearts - 5;

        final int heartU = 5;
        final int goldHeartU = 37;
        final int negHeartU = 21;

        //Clamp down to 5 hearts since processing has completed, needed to generate the list properly.
        clampedHearts = RadixMath.clamp(clampedHearts, 0, 5);
        final List<Integer> heartsToDraw = new ArrayList<Integer>();

        //Add the needed gold hearts.
        while (goldHearts > 0) {
            heartsToDraw.add(goldHeartU);
            goldHearts--;
        }

        //Add the remaining hearts.
        while (heartsToDraw.size() < clampedHearts) {
            if (isNegative) {
                heartsToDraw.add(negHeartU);
            }

            else {
                heartsToDraw.add(heartU);
            }
        }

        //Draw hearts.
        if (!heartsToDraw.isEmpty()) {
            GL11.glPushMatrix();
            {
                GL11.glTranslatef((float) posX + 0.0F, (float) posY + human.height + 0.25F, (float) posZ);
                GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
                GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
                GL11.glScalef(-LABEL_SCALE, -LABEL_SCALE, LABEL_SCALE);
                GL11.glDisable(GL11.GL_LIGHTING);
                GL11.glTranslatef(0.0F, 0.25F / LABEL_SCALE, 0.0F);

                switch (heartsToDraw.size()) {
                case 1:
                    RenderHelper.drawTexturedRectangle(gui, ((int) posX + (10 * 2) - 22), (int) posY - 4,
                            heartsToDraw.get(0), 20, 9, 9);
                    break;
                case 2:
                    for (int i = 0; i < 2; i++) {
                        RenderHelper.drawTexturedRectangle(gui, ((int) posX + (10 * i) - 9), (int) posY - 4,
                                heartsToDraw.get(i), 20, 9, 9);
                    }
                    break;
                case 3:
                    for (int i = 0; i < 3; i++) {
                        RenderHelper.drawTexturedRectangle(gui, ((int) posX + (10 * i) - 14), (int) posY - 4,
                                heartsToDraw.get(i), 20, 9, 9);
                    }
                    break;
                case 4:
                    for (int i = 0; i < 4; i++) {
                        RenderHelper.drawTexturedRectangle(gui, ((int) posX + (10 * i) - 19), (int) posY - 4,
                                heartsToDraw.get(i), 20, 9, 9);
                    }
                    break;
                case 5:
                    for (int i = 0; i < 5; i++) {
                        RenderHelper.drawTexturedRectangle(gui, ((int) posX + (10 * i) - 23), (int) posY - 4,
                                heartsToDraw.get(i), 20, 9, 9);
                    }
                    break;
                }
            }
            GL11.glPopMatrix();

            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_LIGHTING);
        }
    }

    catch (Throwable e) {
        e.printStackTrace();
    }
}

From source file:mca.client.render.RenderHuman.java

License:Open Source License

/**
 * Renders a label above an entity's head.
 * // w  w  w. jav a  2 s.  c om
 * @param human The entity that the label should be rendered on.
 * @param labelText The text that should appear on the label.
 */
private void renderLabel(EntityHuman human, double posX, double posY, double posZ, String labelText) {
    if (human.isSneaking()) {
        final Tessellator tessellator = Tessellator.instance;
        final FontRenderer fontRendererObj = getFontRendererFromRenderManager();
        final int stringWidth = fontRendererObj.getStringWidth(labelText) / 2;

        GL11.glPushMatrix();
        {
            GL11.glTranslatef((float) posX + 0.0F, (float) posY + 2.3F, (float) posZ);
            GL11.glNormal3f(0.0F, 1.0F, 0.0F);
            GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
            GL11.glScalef(-LABEL_SCALE, -LABEL_SCALE, LABEL_SCALE);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glTranslatef(0.0F, 0.25F / LABEL_SCALE, 0.0F);
            GL11.glDepthMask(false);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

            GL11.glDisable(GL11.GL_TEXTURE_2D);

            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
            tessellator.addVertex(-stringWidth - 1, -1D, 0.0D);
            tessellator.addVertex(-stringWidth - 1, 8D, 0.0D);
            tessellator.addVertex(stringWidth + 1, 8D, 0.0D);
            tessellator.addVertex(stringWidth + 1, -1D, 0.0D);
            tessellator.draw();

            GL11.glEnable(GL11.GL_TEXTURE_2D);

            GL11.glDepthMask(true);
            fontRendererObj.drawString(labelText, -fontRendererObj.getStringWidth(labelText) / 2, 0,
                    0x20ffffff);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }
        GL11.glPopMatrix();
    }

    else {
        //RenderLivingLabel
        func_147906_a(human, labelText, posX, posY, posZ, 64);
    }
}

From source file:mca.client.render.RenderHumanSmall.java

License:Open Source License

/**
 * Renders the Entity scaled down to a child's size, depending on its age.
 * //  w w  w  .j  av a2  s  . c o  m
 * @param   entity            The entity being rendered.
 * @param   partialTickTime      The time since the last in-game tick.
 */
protected void renderScale(AbstractChild entity, float partialTickTime) {
    final boolean doGradualGrowth = MCA.getInstance().playerWorldManagerMap
            .get(Minecraft.getMinecraft().thePlayer
                    .getCommandSenderName()).worldProperties.childrenGrowAutomatically;

    if (doGradualGrowth && !entity.isAdult) {
        //Children initially start at 0.55F as their scale. Divide the distance between the player's size and the child's size by
        //the amount of time it takes for them to grow and multiply that times their age. This makes the child gradually get taller
        //as they get older.

        final int age = entity.age;
        final float interval = entity.isMale ? 0.39F : 0.37F;
        final float scale = 0.55F + interval / MCA.getInstance().getModProperties().kidGrowUpTimeMinutes * age;
        GL11.glScalef(scale, scale, scale);
    }

    else if (entity.isAdult) {
        if (entity.isMale) {
            GL11.glScalef(0.9375F, 0.9375F, 0.9375F);
        }

        else {
            GL11.glScalef(0.915F, 0.915F, 0.915F);
        }
    }

    else {
        GL11.glScalef(0.55F, 0.55F, 0.55F);
    }
}

From source file:mca.client.render.RenderMemorial.java

License:Open Source License

public void renderMemorialAt(TileMemorial memorialEntity, double posX, double posY, double posZ,
        float partialTickTime) {
    GL11.glPushMatrix();/*from w w  w.j a  va2 s  .  c  o  m*/

    GL11.glTranslated(posX + 0.50F, posY + 1.5F, posZ + 0.53F);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glScalef(0.7F, 1.0F, 0.7F);

    try {
        switch (memorialEntity.getType()) {
        case BROKEN_RING:
            bindResource(RING_TEXTURE);
            memorialModel.renderRing();
            break;
        case TRAIN:
            bindResource(TRAIN_TEXTURE);
            memorialModel.renderTrain();
            break;
        case DOLL:
            bindResource(DOLL_TEXTURE);
            memorialModel.renderDoll();
            break;
        }
    }

    catch (Exception e) {
        //Pass
    }

    GL11.glPopMatrix();
}