Example usage for org.lwjgl.opengl GL11 glVertex3f

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

Introduction

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

Prototype

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

Source Link

Document

Specifies a single vertex between #glBegin Begin and #glEnd End by giving its coordinates in three dimensions.

Usage

From source file:org.free.jake2.render.lwjgl.Warp.java

License:Open Source License

/**
 * EmitWaterPolys/*from w w  w .  jav a2s . c  o m*/
 * Does a water warp on the pre-fragmented glpoly_t chain
 */
void EmitWaterPolys(msurface_t fa) {
    float rdt = r_newrefdef.time;

    float scroll;
    if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) {
        scroll = -64 * ((r_newrefdef.time * 0.5f) - (int) (r_newrefdef.time * 0.5f));
    } else {
        scroll = 0;
    }

    int i;
    float s, t, os, ot;
    glpoly_t p, bp;
    for (bp = fa.polys; bp != null; bp = bp.next) {
        p = bp;

        GL11.glBegin(GL11.GL_TRIANGLE_FAN);
        for (i = 0; i < p.numverts; i++) {
            os = p.s1(i);
            ot = p.t1(i);

            s = os + Warp.SIN[(int) ((ot * 0.125f + r_newrefdef.time) * TURBSCALE) & 255];
            s += scroll;
            s *= (1.0f / 64);

            t = ot + Warp.SIN[(int) ((os * 0.125f + rdt) * TURBSCALE) & 255];
            t *= (1.0f / 64);

            GL11.glTexCoord2f(s, t);
            GL11.glVertex3f(p.x(i), p.y(i), p.z(i));
        }
        GL11.glEnd();
    }
}

From source file:org.free.jake2.render.lwjgl.Warp.java

License:Open Source License

/**
 * MakeSkyVec//from   w w  w  . jav  a 2  s  . c  om
 * @param s
 * @param t
 * @param axis
 */
void MakeSkyVec(float s, float t, int axis) {
    b[0] = s * 2300;
    b[1] = t * 2300;
    b[2] = 2300;

    int j, k;
    for (j = 0; j < 3; j++) {
        k = st_to_vec[axis][j];
        if (k < 0) {
            v1[j] = -b[-k - 1];
        } else {
            v1[j] = b[k - 1];
        }
    }

    // avoid bilerp seam
    s = (s + 1) * 0.5f;
    t = (t + 1) * 0.5f;

    if (s < sky_min) {
        s = sky_min;
    } else if (s > sky_max) {
        s = sky_max;
    }
    if (t < sky_min) {
        t = sky_min;
    } else if (t > sky_max) {
        t = sky_max;
    }

    t = 1.0f - t;
    GL11.glTexCoord2f(s, t);
    GL11.glVertex3f(v1[0], v1[1], v1[2]);
}

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   ww w.ja v a2 s  .c o 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   w w w.jav  a2 s. co 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.minetweak.world.World.java

License:Apache License

private void renderOverlay() {
    Configuration conf = Game.getInstance().getConfiguration();

    Game.getInstance().initOverlayRendering();

    GL11.glColor3f(1, 1, 1);/*ww w  . ja  v  a  2  s  .co  m*/

    if (Game.RENDER_INFORMATION_OVERLAY) {
        GLFont infoFont = FontStorage.getFont("Monospaced_20");

        /* Down Left Info */
        infoFont.print(4, 4, "CraftMania");
        infoFont.print(4, 30, _player.coordinatesToString());
        infoFont.print(4, 45, "Visible Chunks:      " + _visibleChunks.size());
        infoFont.print(4, 60, "Updading Blocks:     " + _updatingBlocks);
        infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount());
        infoFont.print(4, 90, "Local Chunks:        " + _localChunks.size());
        infoFont.print(4, 105, "Total Local Blocks:  " + _localBlockCount);
        infoFont.print(4, 120, "Time:  " + _time);
        infoFont.print(4, 135, "Sunlight:  " + _sunlight);

    }
    /** RENDER **/
    if (currentGui != null) {
        Game.getInstance().renderTransculentOverlayLayer();
        currentGui.render();
    } else {
        int width = conf.getWidth();
        int height = conf.getHeight();
        // Center Cross
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        if (CENTER_CROSS_CALL_LIST == 0) {
            CENTER_CROSS_CALL_LIST = GL11.glGenLists(1);
            GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            int crossSize = 10;
            int crossHole = 5;

            GL11.glLineWidth(2.5f);

            GL11.glColor3f(0, 0, 0);
            GL11.glBegin(GL11.GL_LINES);
            GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0);

            GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(CENTER_CROSS_CALL_LIST);
        }
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        // Inventory bar
        GL11.glPushMatrix();
        Texture texGui = TextureStorage.getTexture("gui.gui");
        texGui.bind();
        float tileSize = 20.0f / texGui.getImageWidth();
        if (INVENTORY_BAR_CALL_LIST == 0) {
            INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2);

            /* Bar */
            GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0);
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, 0);
            GL11.glVertex2f(0, 40);

            GL11.glTexCoord2f(tileSize * 9, 0);
            GL11.glVertex2f(9 * 40, 40);

            GL11.glTexCoord2f(tileSize * 9, tileSize);
            GL11.glVertex2f(9 * 40, 0);

            GL11.glTexCoord2f(0, tileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();

            /* Little frame around selected item */
            float frameTileSize = 24.0f / texGui.getImageWidth();
            float frameTileY = 22.0f / texGui.getImageHeight();

            GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, frameTileY);
            GL11.glVertex2f(0, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY);
            GL11.glVertex2f(48, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize);
            GL11.glVertex2f(48, 0);

            GL11.glTexCoord2f(0, frameTileY + frameTileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(INVENTORY_BAR_CALL_LIST);
        }

        /* Content */
        GL11.glPushMatrix();
        GL11.glTranslatef(20, 20, 0);
        for (int i = 0; i < 9; ++i) {
            Inventory.InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i);
            if (place != null) {
                place.render();
            }
            GL11.glTranslatef(40, 0, 0);
        }
        texGui.bind();
        GL11.glPopMatrix();
        GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0);
        GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1);

        GL11.glPopMatrix();
    }
}

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;/* ww  w .j  av a 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);/*from www.  j  a v a  2  s.c om*/
    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);
    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  ww w .  j a  v  a 2s  .  co 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. j  a  va2 s .  co 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/*from  w  ww . ja  v  a 2 s. co m*/
    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();
}