List of usage examples for org.lwjgl.opengl GL11 glVertex3d
public static native void glVertex3d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z);
From source file:fr.def.iss.vd2.lib_v3d.element.V3DRectangle.java
License:Open Source License
@Override protected void doDisplay(I3dCamera camera) { float x0 = -size.x / 2; float y0 = -size.y / 2; float x1 = size.x / 2; float y1 = size.y / 2; GL11.glLineWidth(thickness);/*from w w w . j ava 2 s.c om*/ if (renderMode == RenderMode.SOLID) { GL11.glEnable(GL11.GL_LINE_STIPPLE); GL11.glLineStipple(stippleFactor, stipplePattern); GL11.glBegin(GL11.GL_LINE_LOOP); GL11.glVertex3d(x0, y1, 0); GL11.glVertex3d(x0, y0, 0); GL11.glVertex3d(x1, y0, 0); GL11.glVertex3d(x1, y1, 0); GL11.glEnd(); GL11.glDisable(GL11.GL_LINE_STIPPLE); } else { GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3d(x0, y1, 0); GL11.glVertex3d(x0, y0, 0); GL11.glVertex3d(x1, y0, 0); GL11.glVertex3d(x1, y1, 0); GL11.glEnd(); } }
From source file:fr.def.iss.vd2.lib_v3d.element.V3DTriangle.java
License:Open Source License
@Override protected void doDisplay(I3dCamera camera) { float x0 = -size.x / 2; float y0 = -size.y / 2; float x1 = size.x / 2; float y1 = size.y / 2; GL11.glLineWidth(thickness);// w w w . ja va 2s . co m if (renderMode == RenderMode.SOLID) { GL11.glEnable(GL11.GL_LINE_STIPPLE); GL11.glLineStipple(stippleFactor, stipplePattern); GL11.glBegin(GL11.GL_LINE_LOOP); GL11.glVertex3d(x0, y1, 0); GL11.glVertex3d((x1 + x0) / 2, y0, 0); GL11.glVertex3d(x1, y1, 0); GL11.glEnd(); GL11.glDisable(GL11.GL_LINE_STIPPLE); } else { GL11.glBegin(GL11.GL_TRIANGLES); GL11.glVertex3d(x0, y1, 0); GL11.glVertex3d((x1 + x0) / 2, y0, 0); GL11.glVertex3d(x1, y1, 0); GL11.glEnd(); } }
From source file:fr.def.iss.vd2.lib_v3d.element.V3DTube.java
License:Open Source License
@Override protected void doDisplay(I3dCamera camera) { if (renderMode == RenderMode.PLAIN) { GL11.glEnable(GL11.GL_LIGHTING); GL11.glBegin(GL11.GL_QUADS);/* w w w . j ava2 s. c om*/ for (int i = 0; i < pointList.size(); i++) { if (i == 0) { drawQuad(pointList.get(pointList.size() - 1), pointList.get(i)); } else { drawQuad(pointList.get(i - 1), pointList.get(i)); } } GL11.glEnd(); GL11.glDisable(GL11.GL_LIGHTING); } if (renderMode == RenderMode.SOLID) { GL11.glLineWidth(thickness); GL11.glBegin(GL11.GL_LINES); for (V3DVect3 point : pointList) { float z0 = -height / 2; float z1 = height / 2; GL11.glVertex3d(point.x, point.y, z1); GL11.glVertex3d(point.x, point.y, z0); } GL11.glEnd(); } /* Dessine des normales sur les sommets en gradients de couleurs GL11.glLineWidth(thickness); GL11.glEnable(GL11.GL_LINE_STIPPLE); GL11.GLLineStipple(1, (short) 0xFFFF); GL11.glPushAttrib(GL11.GL_COLOR); GL11.glBegin(GL11.GL_LINES); for (int i = 0; i < pointList.size(); i++) { drawNorm( pointList.get(i), radius * 0.6f); } GL11.glPopAttrib(); GL11.glEnd(); GL11.glDisable(GL11.GL_LINE_STIPPLE); */ }
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:info.plugmania.novacraft.event.gui.Render3DOverlayEvent.java
License:GNU General Public License
public void drawLine(Position point1, Position point2, int colour, float lineWidth) { float red = (float) (colour >> 24 & 255) / 255.0F; float green = (float) (colour >> 16 & 255) / 255.0F; float blue = (float) (colour >> 8 & 255) / 255.0F; float alpha = (float) (colour & 255) / 255.0F; GL11.glColor4f(red, green, blue, alpha); GL11.glLineWidth(lineWidth);//from w w w .j a va 2 s. c o m enable(); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(point1.getX() - p.posX, point1.getY() - p.posY, point1.getZ() - p.posZ); GL11.glVertex3d(point2.getX() - p.posX, point2.getY() - p.posY, point2.getZ() - p.posZ); GL11.glEnd(); disable(); }
From source file:net.jamcraft.chowtime.core.renders.TileEntityFermenterRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8) { GL11.glBegin(GL11.GL_QUADS);//from w w w .j ava 2s. c o m GL11.glVertex3d(x, y, z); GL11.glVertex3d(x + 1D, y, z); GL11.glVertex3d(x + 1D, y + 1D, z); GL11.glVertex3d(x, y + 1D, z); GL11.glEnd(); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawConvexD(double[] _planes, int _planecount, double[] _points, int _pointcount, int[] _polygons) { //unsigned //from w w w.j a v a 2 s.c om int polyindex = 0; for (int i = 0; i < _planecount; ++i) { //unsigned int pointcount = _polygons[polyindex]; polyindex++; GL11.glBegin(GL11.GL_POLYGON); GL11.glNormal3d(_planes[(i * 4) + 0], _planes[(i * 4) + 1], _planes[(i * 4) + 2]); for (int j = 0; j < pointcount; ++j) { GL11.glVertex3d(_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 drawTriangle(final DVector3C v0, final DVector3C v1, final DVector3C v2, boolean solid) { float[] u = new float[3], v = new float[3], normal = new float[3]; u[0] = (float) (v1.get0() - v0.get0()); u[1] = (float) (v1.get1() - v0.get1()); u[2] = (float) (v1.get2() - v0.get2()); v[0] = (float) (v2.get0() - v0.get0()); v[1] = (float) (v2.get1() - v0.get1()); v[2] = (float) (v2.get2() - v0.get2()); crossProduct3(normal, u, v);//from w w w. j av a 2 s . co m normalizeVector3(normal); GL11.glBegin(solid ? GL11.GL_TRIANGLES : GL11.GL_LINE_STRIP); GL11.glNormal3f(normal[0], normal[1], normal[2]); GL11.glVertex3d(v0.get0(), v0.get1(), v0.get2()); GL11.glVertex3d(v1.get0(), v1.get1(), v1.get2()); GL11.glVertex3d(v2.get0(), v2.get1(), v2.get2()); GL11.glEnd(); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawCapsule(float l, float r) { int i, j;/*from w ww .ja v a 2s . co m*/ float tmp, nx, ny, nz, start_nx, start_ny, a, ca, sa; // number of sides to the cylinder (divisible by 4): final int n = capped_cylinder_quality * 4; l *= 0.5; a = (float) ((M_PI * 2.0) / n); sa = (float) Math.sin(a); ca = (float) Math.cos(a); // draw cylinder body ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_STRIP); for (i = 0; i <= n; i++) { GL11.glNormal3d(ny, nz, 0); GL11.glVertex3d(ny * r, nz * r, l); GL11.glNormal3d(ny, nz, 0); GL11.glVertex3d(ny * r, nz * r, -l); // rotate ny,nz tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); // draw first cylinder cap start_nx = 0; start_ny = 1; for (j = 0; j < (n / 4); j++) { // get start_n2 = rotated start_n float start_nx2 = ca * start_nx + sa * start_ny; float start_ny2 = -sa * start_nx + ca * start_ny; // get n=start_n and n2=start_n2 nx = start_nx; ny = start_ny; nz = 0; float nx2 = start_nx2, ny2 = start_ny2, nz2 = 0; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); for (i = 0; i <= n; i++) { GL11.glNormal3d(ny2, nz2, nx2); GL11.glVertex3d(ny2 * r, nz2 * r, l + nx2 * r); GL11.glNormal3d(ny, nz, nx); GL11.glVertex3d(ny * r, nz * r, l + nx * r); // rotate n,n2 tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; tmp = ca * ny2 - sa * nz2; nz2 = sa * ny2 + ca * nz2; ny2 = tmp; } GL11.glEnd(); start_nx = start_nx2; start_ny = start_ny2; } // draw second cylinder cap start_nx = 0; start_ny = 1; for (j = 0; j < (n / 4); j++) { // get start_n2 = rotated start_n float start_nx2 = ca * start_nx - sa * start_ny; float start_ny2 = sa * start_nx + ca * start_ny; // get n=start_n and n2=start_n2 nx = start_nx; ny = start_ny; nz = 0; float nx2 = start_nx2, ny2 = start_ny2, nz2 = 0; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); for (i = 0; i <= n; i++) { GL11.glNormal3d(ny, nz, nx); GL11.glVertex3d(ny * r, nz * r, -l + nx * r); GL11.glNormal3d(ny2, nz2, nx2); GL11.glVertex3d(ny2 * r, nz2 * r, -l + nx2 * r); // rotate n,n2 tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; tmp = ca * ny2 - sa * nz2; nz2 = sa * ny2 + ca * nz2; ny2 = tmp; } GL11.glEnd(); start_nx = start_nx2; start_ny = start_ny2; } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawCylinder(float l, float r, float zoffset) { int i;//from w ww . ja v a 2 s .c om float tmp, ny, nz, a, ca, sa; final int n = 24; // number of sides to the cylinder (divisible by 4) l *= 0.5; a = (float) (M_PI * 2.0 / n); sa = (float) Math.sin(a); ca = (float) Math.cos(a); // draw cylinder body ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_STRIP); for (i = 0; i <= n; i++) { GL11.glNormal3d(ny, nz, 0); GL11.glVertex3d(ny * r, nz * r, l + zoffset); GL11.glNormal3d(ny, nz, 0); GL11.glVertex3d(ny * r, nz * r, -l + zoffset); // rotate ny,nz tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); // draw top cap GL11.glShadeModel(GL11.GL_FLAT); ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glNormal3d(0, 0, 1); GL11.glVertex3d(0, 0, l + zoffset); for (i = 0; i <= n; i++) { if (i == 1 || i == n / 2 + 1) setColor(color[0] * 0.75f, color[1] * 0.75f, color[2] * 0.75f, color[3]); GL11.glNormal3d(0, 0, 1); GL11.glVertex3d(ny * r, nz * r, l + zoffset); if (i == 1 || i == n / 2 + 1) setColor(color[0], color[1], color[2], color[3]); // rotate ny,nz tmp = ca * ny - sa * nz; nz = sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); // draw bottom cap ny = 1; nz = 0; // normal vector = (0,ny,nz) GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glNormal3d(0, 0, -1); GL11.glVertex3d(0, 0, -l + zoffset); for (i = 0; i <= n; i++) { if (i == 1 || i == n / 2 + 1) setColor(color[0] * 0.75f, color[1] * 0.75f, color[2] * 0.75f, color[3]); GL11.glNormal3d(0, 0, -1); GL11.glVertex3d(ny * r, nz * r, -l + zoffset); if (i == 1 || i == n / 2 + 1) setColor(color[0], color[1], color[2], color[3]); // rotate ny,nz tmp = ca * ny + sa * nz; nz = -sa * ny + ca * nz; ny = tmp; } GL11.glEnd(); }