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:org.blockartistry.mod.ThermalRecycling.machines.entity.renderers.VendingTileEntityRenderer.java

License:MIT License

protected void renderItem(final ItemStack stack, final int x, final int y, final boolean includeQuantity,
        final boolean noResources) {

    if (stack == null)
        return;/* ww  w .ja v  a  2  s .co m*/

    item.setEntityItemStack(stack);

    GL11.glPushMatrix();

    // Flip
    GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(xOffset[x], yOffset[y], FRONT_EDGE_OFFSET);
    GL11.glPushMatrix();

    GL11.glScalef(BLOCK_SCALE * 1.1F, BLOCK_SCALE * 1.1F, BLOCK_SCALE * 1.1F);

    final Block block = Block.getBlockFromItem(stack.getItem());
    if (block != Blocks.air) {
        GL11.glTranslatef(0.0F, 0.22F, 0.0F);
        GL11.glRotatef(90, 0, 1F, 0);
    }

    itemRenderer.doRender(item, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
    GL11.glPopMatrix();

    if (includeQuantity && (stack.stackSize > 1 || noResources)) {

        final FontRenderer font = Minecraft.getMinecraft().fontRenderer;

        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GL11.glScalef(-f1, -f1, f1);

        GL11.glDisable(2896);
        GL11.glDisable(2929);
        GL11.glDisable(3042);

        String amt = String.valueOf(stack.stackSize);
        if (noResources)
            amt = EnumChatFormatting.RED + amt;

        font.drawStringWithShadow(amt, 13 - font.getStringWidth(amt), -12, 16777215);
        GL11.glEnable(2896);
        GL11.glEnable(2929);

    }

    GL11.glPopMatrix();
}

From source file:org.blockartistry.mod.ThermalRecycling.machines.entity.renderers.VendingTileEntityRenderer.java

License:MIT License

protected void renderName(final String name) {
    if (name.isEmpty())
        return;//from  ww  w .j ava2  s.co  m

    final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
    final Tessellator tessellator = Tessellator.instance;

    final int nameWidth = font.getStringWidth(name) / 2;

    GL11.glPushMatrix();

    // Flip
    GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(0F, 0.48F, -0.51F);
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GL11.glScalef(-f1, -f1, f1);
    GL11.glDisable(2896);
    GL11.glDepthMask(false);
    GL11.glDisable(2929);
    GL11.glEnable(3042);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    final byte byte0 = 0;
    GL11.glDisable(3553);
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
    tessellator.addVertex(-nameWidth - 1, -1 + byte0, 0.0D);
    tessellator.addVertex(-nameWidth - 1, 8 + byte0, 0.0D);
    tessellator.addVertex(nameWidth + 1, 8 + byte0, 0.0D);
    tessellator.addVertex(nameWidth + 1, -1 + byte0, 0.0D);
    tessellator.draw();
    GL11.glEnable(3553);
    font.drawString(name, -nameWidth, byte0, 553648127);
    GL11.glEnable(2929);
    GL11.glDepthMask(true);
    font.drawString(name, -nameWidth, byte0, -1);
    GL11.glEnable(2896);
    GL11.glDisable(3042);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:org.eclipse.swt.opengl.examples.LWJGLExample.java

License:Open Source License

static void drawTorus(float r, float R, int nsides, int rings) {
    float ringDelta = 2.0f * (float) Math.PI / rings;
    float sideDelta = 2.0f * (float) Math.PI / nsides;
    float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f;
    for (int i = rings - 1; i >= 0; i--) {
        float theta1 = theta + ringDelta;
        float cosTheta1 = (float) Math.cos(theta1);
        float sinTheta1 = (float) Math.sin(theta1);
        GL11.glBegin(GL11.GL_QUAD_STRIP);
        float phi = 0.0f;
        for (int j = nsides; j >= 0; j--) {
            phi += sideDelta;/*from   www  . j a v a  2  s  .co m*/
            float cosPhi = (float) Math.cos(phi);
            float sinPhi = (float) Math.sin(phi);
            float dist = R + r * cosPhi;
            GL11.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
            GL11.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
            GL11.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
            GL11.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
        }
        GL11.glEnd();
        theta = theta1;
        cosTheta = cosTheta1;
        sinTheta = sinTheta1;
    }
}

From source file:org.jtrfp.mtmx.draw.ModelDrawer.java

License:Open Source License

public void draw() {
    IBinData binData = model.getBinData();
    IBinVertex[] vertexes = binData.getVertexes();
    IBinFace[] faces = binData.getFaces();

    GL11.glPushMatrix();//from w  w  w .  jav  a 2s . co  m

    if (translation != null) {
        GL11.glTranslatef(translation.getX(), translation.getY(), translation.getZ());
    }
    if (scale != null) {
        GL11.glScalef(scale.getX(), scale.getY(), scale.getZ());
    }
    if (rotationAxis != null) {
        GL11.glRotatef(rotationAngle, rotationAxis.getX(), rotationAxis.getY(), rotationAxis.getZ());
    }

    float n = 1.0f / 65536;
    for (int i = 0; i < faces.length; i++) {
        IBinFace face = faces[i];

        ITextureManager textureManager = engine.getResourceManager().getTextureManager();
        ITexture texture = textureManager.get(face.getTextureName());
        texture.bind();

        IBinVertex normal = face.getNormal();

        GL11.glBegin(renderMode);
        IBinTexCoord[] coords = face.getTexCoords();

        for (int j = coords.length - 1; j >= 0; j--) {
            IBinTexCoord coord = coords[j];
            IBinVertex vertex = vertexes[coord.getVertexIndex()];

            GL11.glNormal3f(-normal.getX() * n, normal.getY() * n, normal.getZ() * n);
            GL11.glTexCoord2f(coord.getU(), coord.getV());

            GL11.glVertex3f(-vertex.getX() * IDrawer.SCALE, vertex.getY() * IDrawer.SCALE,
                    vertex.getZ() * IDrawer.SCALE);
        }
        GL11.glEnd();
    }

    GL11.glPopMatrix();
}

From source file:org.meanworks.engine.scene.Node.java

License:Open Source License

public static void drawCube(float w, float h, float l) {
    final float minx = -(w / 2);
    final float miny = -(h / 2);
    final float minz = -(l / 2);
    final float maxx = (w / 2);
    final float maxy = (h / 2);
    final float maxz = (l / 2);
    // Quad 1/*from   www .  j ava  2s.  c  o m*/
    GL11.glNormal3f(1, 0, 0);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(maxx, maxy, maxz); // V2
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(maxx, miny, maxz); // V1
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(maxx, miny, minz); // V3
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(maxx, maxy, minz); // V4
    // Quad 2
    GL11.glNormal3f(0, 0, -1);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(maxx, maxy, minz); // V4
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(maxx, miny, minz); // V3
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(minx, miny, minz); // V5
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(minx, maxy, minz); // V6
    // Quad 3
    GL11.glNormal3f(-1, 0, 0);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(minx, maxy, minz); // V6
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(minx, miny, minz); // V5
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(minx, miny, maxz); // V7
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(minx, maxy, maxz); // V8
    // Quad 4
    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(minx, maxy, maxz); // V8
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(minx, miny, maxz); // V7
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(maxx, miny, maxz); // V1
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(maxx, maxy, maxz); // V2
    // Quad 5
    GL11.glNormal3f(0, 1, 0);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(minx, maxy, minz); // V6
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(minx, maxy, maxz); // V8
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(maxx, maxy, maxz); // V2
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(maxx, maxy, minz); // V4
    // Quad 6
    GL11.glNormal3f(0, -1, 0);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(minx, miny, maxz); // V7
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(minx, miny, minz); // V5
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(maxx, miny, minz); // V3
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(maxx, miny, maxz); // V1
}

From source file:org.mkdev.ai.langton3d.misc.GLUT.java

License:GNU General Public License

public static void drawBox(double size, int type) {

    float v[][] = new float[8][3];
    float sz = (float) size;
    int i;//  w  w w . j  a va 2 s  .c  o  m

    v[0][0] = v[1][0] = v[2][0] = v[3][0] = -sz / 2.0f;
    v[4][0] = v[5][0] = v[6][0] = v[7][0] = sz / 2.0f;
    v[0][1] = v[1][1] = v[4][1] = v[5][1] = -sz / 2.0f;
    v[2][1] = v[3][1] = v[6][1] = v[7][1] = sz / 2.0f;
    v[0][2] = v[3][2] = v[4][2] = v[7][2] = -sz / 2.0f;
    v[1][2] = v[2][2] = v[5][2] = v[6][2] = sz / 2.0f;

    for (i = 5; i >= 0; i--) {
        GL11.glBegin(type);

        GL11.glNormal3f(CUBE_NORMALS[i][0], CUBE_NORMALS[i][1], CUBE_NORMALS[i][2]);
        GL11.glVertex3f(v[CUBE_FACES[i][0]][0], v[CUBE_FACES[i][0]][1], v[CUBE_FACES[i][0]][2]);
        GL11.glVertex3f(v[CUBE_FACES[i][1]][0], v[CUBE_FACES[i][1]][1], v[CUBE_FACES[i][1]][2]);
        GL11.glVertex3f(v[CUBE_FACES[i][2]][0], v[CUBE_FACES[i][2]][1], v[CUBE_FACES[i][2]][2]);
        GL11.glVertex3f(v[CUBE_FACES[i][3]][0], v[CUBE_FACES[i][3]][1], v[CUBE_FACES[i][3]][2]);

        GL11.glEnd();
    }
}

From source file:org.mkdev.ai.langton3d.misc.GLUT.java

License:GNU General Public License

public static void drawWholeCube(float d, float x1, float x2, float x3, int i, int j, int k) {
    GL11.glNormal3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-d + x1, -d + x2, d + x3); // v1
    GL11.glVertex3f(d + x1, -d + x2, d + x3); // v2
    GL11.glVertex3f(d + x1, d + x2, d + x3); // v3
    GL11.glVertex3f(-d + x1, d + x2, d + x3); // v4

    GL11.glNormal3f(1.0f, 0.0f, 0.0f);/*from ww w . ja va2  s .  c  o m*/
    GL11.glVertex3f(d + x1, -d + x2, d + x3); // v2
    GL11.glVertex3f(d + x1, -d + x2, -d + x3); // v6
    GL11.glVertex3f(d + x1, d + x2, -d + x3); // v5
    GL11.glVertex3f(d + x1, d + x2, d + x3); // v3

    GL11.glNormal3f(0.0f, 1.0f, 0.0f);
    GL11.glVertex3f(d + x1, d + x2, d + x3); // v3
    GL11.glVertex3f(d + x1, d + x2, -d + x3); // v5
    GL11.glVertex3f(-d + x1, d + x2, -d + x3); // v7
    GL11.glVertex3f(-d + x1, d + x2, d + x3); // v4

    GL11.glNormal3f(0.0f, -1.0f, 0.0f);
    GL11.glVertex3f(-d + x1, -d + x2, d + x3); // v1
    GL11.glVertex3f(-d + x1, -d + x2, -d + x3); // v8
    GL11.glVertex3f(d + x1, -d + x2, -d + x3); // v6
    GL11.glVertex3f(d + x1, -d + x2, d + x3); // v2

    GL11.glNormal3f(0.0f, 0.0f, -1.0f);
    GL11.glVertex3f(-d + x1, -d + x2, -d + x3); // v8
    GL11.glVertex3f(-d + x1, d + x2, -d + x3); // v7
    GL11.glVertex3f(d + x1, d + x2, -d + x3); // v5
    GL11.glVertex3f(d + x1, -d + x2, -d + x3); // v6

    GL11.glNormal3f(-1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(-d + x1, -d + x2, -d + x3); // v8
    GL11.glVertex3f(-d + x1, -d + x2, d + x3); // v1
    GL11.glVertex3f(-d + x1, d + x2, d + x3); // v4
    GL11.glVertex3f(-d + x1, d + x2, -d + x3); // v7
}

From source file:org.mkdev.ai.langton3d.misc.GLUT.java

License:GNU General Public License

public static void drawCube(float x11, float x21, float x31, float d1, int mapCubeNeighbours) {
    if ((mapCubeNeighbours & CubeFaces.FRONT.getValue()) == 0) {
        GL11.glNormal3f(0.0f, 0.0f, 1.0f);
        GL11.glVertex3f(-d1 + x11, -d1 + x21, d1 + x31); // v1
        GL11.glVertex3f(d1 + x11, -d1 + x21, d1 + x31); // v2
        GL11.glVertex3f(d1 + x11, d1 + x21, d1 + x31); // v3
        GL11.glVertex3f(-d1 + x11, d1 + x21, d1 + x31); // v4
    }//from  w w w . j a v a2  s.  c o m
    if ((mapCubeNeighbours & CubeFaces.RIGHT.getValue()) == 0) {
        GL11.glNormal3f(1.0f, 0.0f, 0.0f);
        GL11.glVertex3f(d1 + x11, -d1 + x21, d1 + x31); // v2
        GL11.glVertex3f(d1 + x11, -d1 + x21, -d1 + x31); // v6
        GL11.glVertex3f(d1 + x11, d1 + x21, -d1 + x31); // v5
        GL11.glVertex3f(d1 + x11, d1 + x21, d1 + x31); // v3
    }
    if ((mapCubeNeighbours & CubeFaces.TOP.getValue()) == 0) {
        GL11.glNormal3f(0.0f, 1.0f, 0.0f);
        GL11.glVertex3f(d1 + x11, d1 + x21, d1 + x31); // v3
        GL11.glVertex3f(d1 + x11, d1 + x21, -d1 + x31); // v5
        GL11.glVertex3f(-d1 + x11, d1 + x21, -d1 + x31); // v7
        GL11.glVertex3f(-d1 + x11, d1 + x21, d1 + x31); // v4
    }
    if ((mapCubeNeighbours & CubeFaces.BOTTOM.getValue()) == 0) {
        GL11.glNormal3f(0.0f, -1.0f, 0.0f);
        GL11.glVertex3f(-d1 + x11, -d1 + x21, d1 + x31); // v1
        GL11.glVertex3f(-d1 + x11, -d1 + x21, -d1 + x31); // v8
        GL11.glVertex3f(d1 + x11, -d1 + x21, -d1 + x31); // v6
        GL11.glVertex3f(d1 + x11, -d1 + x21, d1 + x31); // v2
    }
    if ((mapCubeNeighbours & CubeFaces.BACK.getValue()) == 0) {
        GL11.glNormal3f(0.0f, 0.0f, -1.0f);
        GL11.glVertex3f(-d1 + x11, -d1 + x21, -d1 + x31); // v8
        GL11.glVertex3f(-d1 + x11, d1 + x21, -d1 + x31); // v7
        GL11.glVertex3f(d1 + x11, d1 + x21, -d1 + x31); // v5
        GL11.glVertex3f(d1 + x11, -d1 + x21, -d1 + x31); // v6
    }
    if ((mapCubeNeighbours & CubeFaces.LEFT.getValue()) == 0) {
        GL11.glNormal3f(-1.0f, 0.0f, 0.0f);
        GL11.glVertex3f(-d1 + x11, -d1 + x21, -d1 + x31); // v8
        GL11.glVertex3f(-d1 + x11, -d1 + x21, d1 + x31); // v1
        GL11.glVertex3f(-d1 + x11, d1 + x21, d1 + x31); // v4
        GL11.glVertex3f(-d1 + x11, d1 + x21, -d1 + x31); // v7
    }
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void drawConvex(float[] _planes, int _planecount, float[] _points, int _pointcount, int[] _polygons) {
    //unsigned //from  w w w .java  2s .  c  o m
    int polyindex = 0;
    for (int i = 0; i < _planecount; ++i) {
        //unsigned 
        int pointcount = _polygons[polyindex];
        polyindex++;
        GL11.glBegin(GL11.GL_POLYGON);
        GL11.glNormal3f(_planes[(i * 4) + 0], _planes[(i * 4) + 1], _planes[(i * 4) + 2]);
        for (int j = 0; j < pointcount; ++j) {
            GL11.glVertex3f(_points[_polygons[polyindex] * 3], _points[(_polygons[polyindex] * 3) + 1],
                    _points[(_polygons[polyindex] * 3) + 2]);
            polyindex++;
        }
        GL11.glEnd();
    }
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void drawBox(final float[] sides) {
    float lx = sides[0] * 0.5f;
    float ly = sides[1] * 0.5f;
    float lz = sides[2] * 0.5f;

    // sides// w  w  w.  ja v  a  2s  .  com
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glNormal3f(-1, 0, 0);
    GL11.glVertex3f(-lx, -ly, -lz);
    GL11.glVertex3f(-lx, -ly, lz);
    GL11.glVertex3f(-lx, ly, -lz);
    GL11.glVertex3f(-lx, ly, lz);
    GL11.glNormal3f(0, 1, 0);
    GL11.glVertex3f(lx, ly, -lz);
    GL11.glVertex3f(lx, ly, lz);
    GL11.glNormal3f(1, 0, 0);
    GL11.glVertex3f(lx, -ly, -lz);
    GL11.glVertex3f(lx, -ly, lz);
    GL11.glNormal3f(0, -1, 0);
    GL11.glVertex3f(-lx, -ly, -lz);
    GL11.glVertex3f(-lx, -ly, lz);
    GL11.glEnd();

    // top face
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glNormal3f(0, 0, 1);
    GL11.glVertex3f(-lx, -ly, lz);
    GL11.glVertex3f(lx, -ly, lz);
    GL11.glVertex3f(lx, ly, lz);
    GL11.glVertex3f(-lx, ly, lz);
    GL11.glEnd();

    // bottom face
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glNormal3f(0, 0, -1);
    GL11.glVertex3f(-lx, -ly, -lz);
    GL11.glVertex3f(-lx, ly, -lz);
    GL11.glVertex3f(lx, ly, -lz);
    GL11.glVertex3f(lx, -ly, -lz);
    GL11.glEnd();
}