List of usage examples for org.lwjgl.opengl GL11 glNormal3d
public static native void glNormal3d(@NativeType("GLdouble") double nx, @NativeType("GLdouble") double ny, @NativeType("GLdouble") double nz);
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 www . ja va2 s. 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.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 drawCapsule(float l, float r) { int i, j;//from www . j a v a2 s . c o 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;//ww w . ja v a 2s. co m 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(); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glNormal3d(double a, double b, double c) { GL11.glNormal3d(a, b, c); }