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:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void drawCube(float r) {
    r /= 2f;//from   www. ja v a  2 s  .  com
    GL11.glBegin(GL11.GL_QUADS);
    // Front Face
    GL11.glNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-r, -r, r); // Point 1 (Front)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(r, -r, r); // Point 2 (Front)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(r, r, r); // Point 3 (Front)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-r, r, r); // Point 4 (Front)
    // Back Face
    GL11.glNormal3f(0.0f, 0.0f, -1.0f); // Normal Pointing Away From Viewer
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(-r, -r, -r); // Point 1 (Back)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(-r, r, -r); // Point 2 (Back)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(r, r, -r); // Point 3 (Back)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(r, -r, -r); // Point 4 (Back)
    // Top Face
    GL11.glNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-r, r, -r); // Point 1 (Top)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-r, r, r); // Point 2 (Top)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(r, r, r); // Point 3 (Top)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(r, r, -r); // Point 4 (Top)
    // Bottom Face
    GL11.glNormal3f(0.0f, -1.0f, 0.0f); // Normal Pointing Down
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(-r, -r, -r); // Point 1 (Bottom)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(r, -r, -r); // Point 2 (Bottom)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(r, -r, r); // Point 3 (Bottom)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(-r, -r, r); // Point 4 (Bottom)
    // Right face
    GL11.glNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(r, -r, -r); // Point 1 (Right)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(r, r, -r); // Point 2 (Right)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(r, r, r); // Point 3 (Right)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(r, -r, r); // Point 4 (Right)
    // Left Face
    GL11.glNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-r, -r, -r); // Point 1 (Left)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(-r, -r, r); // Point 2 (Left)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(-r, r, r); // Point 3 (Left)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-r, r, -r); // Point 4 (Left)
    // Done Drawing Quads
    GL11.glEnd();

}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBox.java

License:Open Source License

@Override
protected void doDisplay(I3dCamera camera) {
    float x0 = -size.x / 2;
    float x1 = size.x / 2;
    float y0 = -size.y / 2;
    float y1 = size.y / 2;
    float z0 = -size.z / 2;
    float z1 = size.z / 2;

    if (renderMode == RenderMode.PLAIN) {

        //GL11.glEnable(GL11.GL_LIGHTING);

        GL11.glBegin(GL11.GL_QUADS);/*from w w  w.  java 2  s .  c o  m*/

        GL11.glNormal3f(0, 1, 0);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y0, z1);

        GL11.glNormal3f(1, 0, 0);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x0, y0, z1);

        GL11.glNormal3f(0, -1, 0);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y1, z1);

        GL11.glNormal3f(-1, 0, 0);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x1, y1, z1);

        GL11.glNormal3f(0, 0, 1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x1, y0, z0);

        GL11.glNormal3f(0, 0, -1);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y1, z1);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LIGHTING);
    }
    if (renderMode == RenderMode.SOLID) {

        GL11.glLineWidth(thickness);

        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        GL11.glLineStipple(stippleFactor, stipplePattern);

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y0, z1);

        GL11.glEnd();

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z0);

        GL11.glEnd();

        GL11.glBegin(GL11.GL_LINES);

        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y1, z0);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    }
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DPolygonWalls.java

License:Open Source License

private void drawQuad(V3DVect3 point0, V3DVect3 point1) {
    float normX = -(point1.y - point0.y);
    float normY = (point1.x - point0.x);
    float normLenght = (float) Math.sqrt(normX * normX + normY * normY);
    GL11.glNormal3f(normX / normLenght, normY / normLenght, 0);
    float z0 = -height / 2;
    float z1 = height / 2;
    GL11.glVertex3d(point0.x, point0.y, z1);
    GL11.glVertex3d(point0.x, point0.y, z0);
    GL11.glVertex3d(point1.x, point1.y, z0);
    GL11.glVertex3d(point1.x, point1.y, z1);
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DTube.java

License:Open Source License

private void drawQuad(V3DVect3 point0, V3DVect3 point1) {
    float z0 = -height / 2;
    float z1 = height / 2;

    float normLenght = 1f / radius;
    GL11.glNormal3f(point0.x / normLenght, point0.y / normLenght, 0);
    GL11.glVertex3d(point0.x, point0.y, z1);
    GL11.glVertex3d(point0.x, point0.y, z0);

    GL11.glNormal3f(point1.x / normLenght, point1.y / normLenght, 0);
    GL11.glVertex3d(point1.x, point1.y, z0);
    GL11.glVertex3d(point1.x, point1.y, z1);
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void draw3dQuadList() {
    int quadCount = buffer.getInt();
    GL11.glBegin(GL11.GL_QUADS);//from w w w .j ava 2 s .  c o  m

    for (int quadIndex = 0; quadIndex < quadCount; quadIndex++) {
        for (int i = 0; i < 4; i++) {
            GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat());
            GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
            GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());

        }
    }
    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void draw3dTriangleList() {
    int triangleCount = buffer.getInt();

    GL11.glBegin(GL11.GL_TRIANGLES);//from  w  ww  . j  av  a  2s .c  o  m
    for (int triangleIndex = 0; triangleIndex < triangleCount; triangleIndex++) {

        for (int i = 0; i < 3; i++) {
            GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat());
            GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
            GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
        }
    }
    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void draw3dPolygonList() {
    int polygonCount = buffer.getInt();

    for (int polygonIndex = 0; polygonIndex < polygonCount; polygonIndex++) {
        GL11.glBegin(GL11.GL_POLYGON);//w w w  . j ava  2s .  c  om
        int vertexCount = buffer.getInt();
        for (int i = 0; i < vertexCount; i++) {
            GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat());
            GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
            GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
        }
        GL11.glEnd();
    }
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void drawRegistrated3dConcavePolygon() {
    int polygonIndex = buffer.getInt();
    Tesselation tesselation = concavePolygonList.get(polygonIndex);

    List<Integer> vertexTypeList = tesselation.getVertexTypeList();

    for (int i = 0; i < vertexTypeList.size(); i++) {

        List<V3DrawVertex> vertexList = tesselation.getVertexListList().get(i);

        GL11.glBegin(vertexTypeList.get(i));
        for (V3DrawVertex vertex : vertexList) {
            GL11.glTexCoord2f(vertex.texture.x, vertex.texture.y);
            GL11.glNormal3f(vertex.normal.x, vertex.normal.y, vertex.normal.z);
            GL11.glVertex3f(vertex.position.x, vertex.position.y, vertex.position.z);
        }/*from ww  w.  j a v a 2  s  . com*/
        GL11.glEnd();
    }
}

From source file:fr.mcnanotech.kevin_68.nanotechmod.city.client.renderer.tileentity.TileEntityTextSpotLightRender.java

License:Creative Commons License

public void renderTileEntitySignAt(TileEntityTextSpotLight tileentity, double par2, double par4, double par6,
        float par8) {
    float f = tileentity.isActiveFloat();
    if (f > 0.0F) {
        GL11.glPushMatrix();/* w  w w .  j  a v  a 2s  .c  om*/
        float f1 = 0.6666667F;
        float f2 = 0.0F;

        float d2 = (float) tileentity.getWorldObj().getTotalWorldTime() + par8;
        byte b1 = 1;
        double d3 = (double) d2 * 0.025D * (1.0D - (double) (b1 & 1) * 2.5D);
        int i1 = (tileentity.get(TileEntityTextSpotLight.REVERSEROTATION) == 1 ? -1 : 1);

        GL11.glTranslatef((float) par2 + 0.5F, (float) par4 + 0.75F * f1, (float) par6 + 0.5F);
        GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScaled(0.9D, 0.9D, 0.9D);
        if (tileentity.get(TileEntityTextSpotLight.ROTATE) == 0) {
            GL11.glRotated(d3 * 5 * tileentity.get(TileEntityTextSpotLight.ROTATIONSPEED) * i1, 0.0F, 1.0F,
                    0.0F);
        } else {
            GL11.glRotatef(tileentity.get(TileEntityTextSpotLight.ANGLE), 0.0F, 1.0F, 0.0F);
        }
        this.modelSign.signStick.showModel = false;

        this.bindTexture(field_110638_a);
        GL11.glPushMatrix();
        GL11.glScalef(f1, -f1, -f1);
        this.modelSign.renderSign();
        GL11.glPopMatrix();
        FontRenderer fontrenderer = this.func_147498_b();
        f2 = 0.016666668F * f1;
        GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
        GL11.glScalef(f2 * 5, -f2 * 5, f2 * 5);
        GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
        GL11.glDepthMask(false);

        GL11.glTranslated(0.0F, -tileentity.get(TileEntityTextSpotLight.HEIGHT), 0.0F);
        // GL11.glTranslated(0.0F, tileentity.getScale() / 5.0F, 0.0F);
        GL11.glScaled(1.0 + (1.0 * (tileentity.get(TileEntityTextSpotLight.SCALE) / 10)),
                1.0 + (1.0 * (tileentity.get(TileEntityTextSpotLight.SCALE) / 10)),
                1.0 + (1.0 * (tileentity.get(TileEntityTextSpotLight.SCALE) / 10)));

        String s = tileentity.signText;
        fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, -20,
                (tileentity.get(TileEntityTextSpotLight.RED) * 65536)
                        + (tileentity.get(TileEntityTextSpotLight.GREEN) * 256)
                        + tileentity.get(TileEntityTextSpotLight.BLUE));
        // GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
        // fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2,
        // -20, (tileentity.getRedValue() * 65536) +
        // (tileentity.getGreenValue() * 256) + tileentity.getBlueValue());

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

From source file:game.states.State_PREFAB_EDITOR.java

License:Open Source License

private void DrawWall(int x, int y, int i) {
    // BOTTOM//from   w ww  . j a  v  a 2  s .  co  m
    GL11.glBegin(GL11.GL_QUADS);
    TileDefinition.setColor(i);
    GL11.glNormal3f(0, -1, 0);
    GL11.glVertex3f(-1f, -1f, 0f);
    GL11.glVertex3f(1f, -1f, 0);
    GL11.glVertex3f(1f, 1f, 0f);
    GL11.glVertex3f(-1f, 1f, 0f);

    // SIDES
    GL11.glNormal3f(1, 0, 0);
    GL11.glVertex3f(-1f, -1f, 0f);
    GL11.glVertex3f(1f, -1f, 0f);
    GL11.glVertex3f(1f, -1f, -4f);
    GL11.glVertex3f(-1f, -1f, -4f);

    GL11.glNormal3f(0, 0, 1);
    GL11.glVertex3f(1f, -1f, 0f);
    GL11.glVertex3f(1f, 1f, 0f);
    GL11.glVertex3f(1f, 1f, -4f);
    GL11.glVertex3f(1f, -1f, -4f);

    GL11.glNormal3f(1, 0, 0);
    GL11.glVertex3f(1f, 1f, 0f);
    GL11.glVertex3f(-1f, 1f, 0f);
    GL11.glVertex3f(-1f, 1f, -4f);
    GL11.glVertex3f(1f, 1f, -4f);

    GL11.glNormal3f(0, 0, 1);
    GL11.glVertex3f(-1f, 1f, 0f);
    GL11.glVertex3f(-1f, -1f, 0f);
    GL11.glVertex3f(-1f, -1f, -4f);
    GL11.glVertex3f(-1f, 1f, -4f);

    // BOTTOM
    GL11.glNormal3f(0, 1, 0);
    GL11.glVertex3f(-1f, -1f, -4f);
    GL11.glVertex3f(1f, -1f, -4f);
    GL11.glVertex3f(1f, 1f, -4f);
    GL11.glVertex3f(-1f, 1f, -4f);
    GL11.glEnd();

}