Example usage for org.lwjgl.opengl GL11 glNormal3f

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

Introduction

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

Prototype

public static native void glNormal3f(@NativeType("GLfloat") float nx, @NativeType("GLfloat") float ny,
        @NativeType("GLfloat") float nz);

Source Link

Document

Sets the current normal.

Usage

From source file:arrowsplus.client.render.RenderArrow.java

License:Open Source License

/**
 * Renders the arrow.//from   www.  ja v a  2s. c  o  m
 * 
 * @param entityArrow   The arrow to render.
 * @param posX         The x position to render the arrow at.
 * @param posY         The y position to render the arrow at.
 * @param posZ         The z position to render the arrow at.
 * @param yaw         The yaw rotation to render the arrow with.
 * @param pitch         The pitch to render the arrow with.
 */
public void renderArrow(EntityArrowBase entityArrow, double posX, double posY, double posZ, float yaw,
        float pitch) {
    this.func_110777_b(entityArrow);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) posX, (float) posY, (float) posZ);
    GL11.glRotatef(entityArrow.prevRotationYaw + (entityArrow.rotationYaw - entityArrow.prevRotationYaw) * pitch
            - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(
            entityArrow.prevRotationPitch + (entityArrow.rotationPitch - entityArrow.prevRotationPitch) * pitch,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.0F;
    float f3 = 0.5F;
    float f4 = (0 + b0 * 10) / 32.0F;
    float f5 = (5 + b0 * 10) / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = (5 + b0 * 10) / 32.0F;
    float f9 = (10 + b0 * 10) / 32.0F;
    float f10 = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    float f11 = entityArrow.arrowShake - pitch;

    if (f11 > 0.0F) {
        float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
        GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
    }

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(f10, f10, f10);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f9);
    tessellator.draw();
    GL11.glNormal3f(-f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, f2, f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, f3, f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, f3, f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, f2, f5);
        tessellator.draw();
    }

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

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

private void renderSign(double x, double y, double z, float tickTime, String[] signText, int meta,
        boolean renderingItem) {
    if (signText.length == 0)
        return;//from  w w  w .  j  a  va2s .  c  o m
    int i = 0;
    for (String line : signText)
        if (!Strings.isNullOrEmpty(line)) {
            i++;
        }
    if (i == 0)
        return;

    GL11.glPushMatrix();
    float f1 = 0.6666667F;
    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F);
    float f2 = 0.0F;

    switch (meta) {
    case 0:
        break;
    case 1:
        f2 = 90f;
        break;
    case 2:
        f2 = 180f;
        break;
    case 3:
        f2 = -90f;

    }
    GL11.glTranslated(0, -0.3, 0);
    if (renderingItem)
        GL11.glTranslated(0, 0.03, 0);

    GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F);
    GL11.glTranslated(0, -1.2, 0);

    GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    GL11.glTranslatef(0f, 0.8F, 0.5f);
    MODEL_SIGN.signStick.showModel = false;

    this.bindTexture(SIGN_TEXTURE);
    GL11.glPushMatrix();
    GL11.glScalef(f1, -f1, -f1);
    MODEL_SIGN.renderSign();
    GL11.glPopMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    f2 = 0.016666668F * f1;
    GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    GL11.glScalef(f2, -f2, f2);
    GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    GL11.glDepthMask(false);
    byte b0 = 0;

    for (int j = 0; j < signText.length; ++j) {
        GL11.glPushMatrix();
        String s = signText[j];
        int width = fontrenderer.getStringWidth(s);
        if (width > 95) {
            float f = 1f - ((width) * 0.0015f);
            GL11.glScalef(f, f, f);
        }
        fontrenderer.drawString(s, -width / 2, j * 10 - 20, b0);
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:ccm.placeableTools.client.ToolRenderer.java

License:Open Source License

private void renderSign(double x, double y, double z, float tickTime, int facing, String[] signText, int meta) {
    GL11.glPushMatrix();/*from  w  w w . j a v  a  2  s  . co  m*/
    float f1 = 0.6666667F;
    float f2 = 0.0F;

    switch (facing) {
    case 0:
    case 8:
        f2 = -90f;
        break;
    case 1:
    case 7:
        f2 = 90f;
        break;
    case 2:
    case 5:
        f2 = 180f;
    }

    if (meta >= 2) {
        GL11.glTranslated(0, -1.2, 0);
    }

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F);
    GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);

    GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    GL11.glTranslatef(0f, 0.8F, 0.5f);
    MODEL_SIGN.signStick.showModel = false;

    if (facing > 4) {
        if (meta >= 2)
            GL11.glTranslated(-0.6, 0, 0);
        //GL11.glTranslated(b ? -0.4 : -0.6, 0, 0);

        if (meta == 2 && facing == 7)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 3 && facing == 8)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 4 && facing == 6)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 5 && facing == 5)
            GL11.glTranslated(1.2, 0, 0);
    }

    this.bindTexture(SIGN_TEXTURE);
    GL11.glPushMatrix();
    GL11.glScalef(f1, -f1, -f1);
    MODEL_SIGN.renderSign();
    GL11.glPopMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    f2 = 0.016666668F * f1;
    GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    GL11.glScalef(f2, -f2, f2);
    GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    GL11.glDepthMask(false);
    byte b0 = 0;

    for (int j = 0; j < signText.length; ++j) {
        GL11.glPushMatrix();
        String s = signText[j];
        int width = fontrenderer.getStringWidth(s);
        if (width > 95) {
            float f = 1f - ((width) * 0.0015f);
            GL11.glScalef(f, f, f);
        }
        fontrenderer.drawString(s, -width / 2, j * 10 - signText.length * 5, b0);
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:cellSim2.GradientWall.java

License:Open Source License

public boolean specialRender(IGL gl, Transform t) {
    if (grad == null) {
        return false;
    }/*from   w  w  w  .ja  v a  2 s  .co  m*/

    //get the time 
    long ti = sim.getCurrentTimeMicroseconds();
    int axis = grad.getAxis();

    float[] wallSize = new float[3];
    getSize().get(wallSize);
    float blockSize = wallSize[axis] / (float) drawnSegments;

    float[] diagonal = new float[3];
    switch (axis) {
    case 0:
        diagonal[0] = -blockSize;
        diagonal[1] = -wallSize[1];//height
        diagonal[2] = 0;
        break;
    case 1:
        diagonal[0] = wallSize[0];//width
        diagonal[1] = blockSize;
        diagonal[2] = 0;
        break;
    case 2:
        diagonal[0] = 0;
        diagonal[1] = wallSize[1];
        diagonal[2] = blockSize;
        break;
    }
    Vector3f diagonalVector = new Vector3f(diagonal);
    //System.out.println(diagonalVector);

    float[] nextPos = new float[] { 0f, 0f, 0f };
    nextPos[axis] = blockSize;
    Vector3f nextPositionVector = new Vector3f(nextPos);
    //System.out.println(nextPositionVector);

    float[] dist = new float[] { 0f, 0f, 0f };
    dist[axis] = distanceFromSource;
    Vector3f distVector = new Vector3f(dist);

    gl.glPushMatrix();

    t.getOpenGLMatrix(glMat);
    gl.glMultMatrix(glMat);
    GL11.glNormal3f(0f, 0f, -1f);
    Vector3f vecOne = new Vector3f(startPoint);
    Vector3f vecTwo = new Vector3f(vecOne);
    vecTwo.add(diagonalVector);
    for (int i = 0; i < drawnSegments; i++) {
        //Find the concentration at this time and position
        //System.out.println("VecOne: " + vecOne + " VecTwo: " + vecTwo);
        Vector3f gradPos = new Vector3f();
        gradPos.add(vecOne, distVector);
        float[] color = grad.getColor(grad.getConcentration(ti, gradPos));
        GL11.glColor3f(color[0], color[1], color[2]);
        GL11.glBegin(GL11.GL_QUADS);
        //System.out.println(i + "ri: " + ri + " le: " + le + " con: " + con + " mi: " + mi);
        GL11.glVertex3f(vecOne.x, vecOne.y, vecOne.z);
        GL11.glVertex3f(vecTwo.x, vecOne.y, vecTwo.z);
        GL11.glVertex3f(vecTwo.x, vecTwo.y, vecTwo.z);
        GL11.glVertex3f(vecOne.x, vecTwo.y, vecOne.z);
        GL11.glEnd();
        vecOne.add(nextPositionVector);
        vecTwo.add(vecOne, diagonalVector);
        //System.out.println(startPoint + ", " + vecOne + ", " +addOnVector +", "+ vecTwo);
    }
    gl.glPopMatrix();

    return true;
    //return false;
}

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java

License:Apache License

public final void glNormal3f(float nx, float ny, float nz) {
    GL11.glNormal3f(nx, ny, nz);
}

From source file:com.blogspot.jabelarminecraft.wildanimals.renderers.RenderThrowableSpawnEgg.java

License:Open Source License

/**
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
 * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
 *//*from  w  w w  .  j av  a  2  s  .  com*/
public void doRender(EntityWildAnimalsEgg parEntityWildAnimalsEgg, double parPosX, double parPosY,
        double parPosZ, float p_76986_8_, float parTweenFactor) {
    bindEntityTexture(parEntityWildAnimalsEgg);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) parPosX, (float) parPosY, (float) parPosZ);
    GL11.glRotatef(parEntityWildAnimalsEgg.prevRotationYaw
            + (parEntityWildAnimalsEgg.rotationYaw - parEntityWildAnimalsEgg.prevRotationYaw) * parTweenFactor
            - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(parEntityWildAnimalsEgg.prevRotationPitch
            + (parEntityWildAnimalsEgg.rotationPitch - parEntityWildAnimalsEgg.prevRotationPitch)
                    * parTweenFactor,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.0F;
    float f3 = 0.5F;
    float f4 = 0.0F;
    float f5 = 5 / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = 5 / 32.0F;
    float f9 = 10 / 32.0F;
    float scaleFactor = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    float f11 = -parTweenFactor;

    if (f11 > 0.0F) {
        float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
        GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
    }

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(scaleFactor, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f9);
    tessellator.draw();
    GL11.glNormal3f(-scaleFactor, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, scaleFactor);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, f2, f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, f3, f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, f3, f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, f2, f5);
        tessellator.draw();
    }

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

From source file:com.builtbroken.icbm.content.fragments.RenderFragment.java

private void doRenderArrow(EntityFragment entity, double xx, double yy, double zz, float p_76986_8_,
        float p_76986_9_) {
    GL11.glPushMatrix();/*from   w  w w . jav  a2  s. co  m*/
    GL11.glTranslatef((float) xx, (float) yy, (float) zz);
    GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * p_76986_9_ - 90.0F,
            0.0F, 1.0F, 0.0F);
    GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * p_76986_9_,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.0F;
    float f3 = 0.5F;
    float f4 = (float) (0 + b0 * 10) / 32.0F;
    float f5 = (float) (5 + b0 * 10) / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = (float) (5 + b0 * 10) / 32.0F;
    float f9 = (float) (10 + b0 * 10) / 32.0F;
    float f10 = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(f10, f10, f10);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();
    GL11.glNormal3f(-f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5);
        tessellator.draw();
    }

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

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {//  w w  w .  j av a2 s  . co m
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.kanbekotori.keycraft.renderer.RenderJavelin.java

License:Open Source License

public void doRender(EntityJavelin entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
    this.bindEntityTexture(entity);
    GL11.glPushMatrix();//from  w w  w.ja v  a2s  .  c om
    GL11.glTranslated(x, y, z);
    //
    GL11.glTranslatef(0.0F, entity.height / 2.0F, 0.0F);
    GL11.glRotatef(entity.prevRotationYaw - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(entity.prevRotationPitch, 0.0F, 0.0F, 1.0F);

    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    float f10 = 0.05625F;
    GL11.glScalef(f10, f10, f10);
    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-3.25D, -0.5D, 0.0D, 1.0D / 16.0D, 14.0D / 16.0D); // 
        tessellator.addVertexWithUV(3.25D, -0.5D, 0.0D, 14.0D / 16.0D, 1.0D / 16.0D); // 
        tessellator.addVertexWithUV(3.25D, 0.5D, 0.0D, 16.0D / 16.0D, 3.0D / 16.0D); // 
        tessellator.addVertexWithUV(-3.25D, 0.5D, 0.0D, 3.0D / 16.0D, 16.0D / 16.0D); // 
        tessellator.draw();
    }

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

From source file:com.kegare.caveworld.client.renderer.RenderCaveman.java

License:Minecraft Mod Public

@Override
public void doRender(Entity entity, double par2, double par3, double par4, float par5, float par6) {
    super.doRender(entity, par2, par3, par4, par5, par6);

    if (Config.cavemanShowHealthBar && entity instanceof EntityCaveman) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        EntityPlayer player = mc.thePlayer;
        EntityCaveman living = (EntityCaveman) entity;

        if (living.isTamed()
                && player.getGameProfile().getId().toString()
                        .equals(Strings.nullToEmpty(living.func_152113_b()))
                && living.getEntitySenses().canSee(player) && living.getDistanceToEntity(player) <= 3.5F
                && mc.objectMouseOver.typeOfHit == MovingObjectType.ENTITY
                && mc.objectMouseOver.entityHit == living) {
            float scale = 0.01666667F * 1.5F;
            int width = 15;
            double top = 5.0D;
            double under = top + 2.0D;

            GL11.glPushMatrix();/* w  w  w .ja  v  a2  s  .  c o  m*/
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glTranslatef((float) par2, (float) par3 + 2.3F, (float) par4);
            GL11.glNormal3f(0.0F, 1.0F, 0.0F);
            GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
            GL11.glScalef(-scale, -scale, scale);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glTranslatef(0.0F, (living.isSittingAndStopped() ? 0.6F : 0.12F) / scale, 0.0F);
            GL11.glDepthMask(false);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(770, 771);

            int x = living.getBrightnessForRender((float) par2);
            int y = x % 65536;
            int z = x / 65536;

            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, y / 1.0F, z / 1.0F);
            Tessellator tessellator = Tessellator.instance;
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(0, 115);
            tessellator.addVertex(-width - 1, top - 0.5D, 0.0D);
            tessellator.addVertex(-width - 1, under + 0.5D, 0.0D);
            tessellator.addVertex(width + 1, under + 0.5D, 0.0D);
            tessellator.addVertex(width + 1, top - 0.5D, 0.0D);
            tessellator.draw();
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);

            Tessellator tessellator1 = Tessellator.instance;
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            float max = living.getMaxHealth();
            int health = (int) (2.0D * width * living.getHealth() / max);

            if (renderHealth < 0.0D) {
                renderHealth = health;
            } else {
                double dh = renderHealth - health;
                double distance = Math.abs(Math.sqrt(dh * dh));

                if ((int) renderHealth < health) {
                    if (distance > 10.0D) {
                        renderHealth += 0.35D;
                    } else if (distance < 1.5D) {
                        renderHealth += 0.01D;
                    } else {
                        renderHealth += 0.1D;
                    }
                } else if ((int) renderHealth > health) {
                    if (distance > 10.0D) {
                        renderHealth -= 0.35D;
                    } else if (distance < 1.5D) {
                        renderHealth -= 0.01D;
                    } else {
                        renderHealth -= 0.1D;
                    }
                }
            }

            int color = Color.GREEN.getRGB();

            if (renderHealth < max / 4) {
                color = Color.RED.getRGB();
            } else if (renderHealth < max / 2) {
                color = Color.YELLOW.getRGB();
            }

            tessellator1.startDrawingQuads();
            tessellator1.setColorRGBA_I(color, 145);
            tessellator1.addVertex(-width, top, 0.0D);
            tessellator1.addVertex(-width, under, 0.0D);
            tessellator1.addVertex(-width + renderHealth, under, 0.0D);
            tessellator1.addVertex(-width + renderHealth, top, 0.0D);
            tessellator1.draw();
            GL11.glEnable(GL11.GL_TEXTURE_2D);

            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glPopMatrix();
        } else {
            renderHealth = -1.0D;
        }
    }
}