List of usage examples for org.lwjgl.opengl GL11 glNormal3f
public static native void glNormal3f(@NativeType("GLfloat") float nx, @NativeType("GLfloat") float ny, @NativeType("GLfloat") float nz);
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawPatch(float[] p1, float[] p2, float[] p3, int level) { int i;//www . j av a2 s. c o m if (level > 0) { float[] q1 = new float[3], q2 = new float[3], q3 = new float[3]; // sub-vertices for (i = 0; i < 3; i++) { q1[i] = 0.5f * (p1[i] + p2[i]); q2[i] = 0.5f * (p2[i] + p3[i]); q3[i] = 0.5f * (p3[i] + p1[i]); } float length1 = (float) (1.0 / Math.sqrt(q1[0] * q1[0] + q1[1] * q1[1] + q1[2] * q1[2])); float length2 = (float) (1.0 / Math.sqrt(q2[0] * q2[0] + q2[1] * q2[1] + q2[2] * q2[2])); float length3 = (float) (1.0 / Math.sqrt(q3[0] * q3[0] + q3[1] * q3[1] + q3[2] * q3[2])); for (i = 0; i < 3; i++) { q1[i] *= length1; q2[i] *= length2; q3[i] *= length3; } drawPatch(p1, q1, q3, level - 1); drawPatch(q1, p2, q2, level - 1); drawPatch(q1, q2, q3, level - 1); drawPatch(q3, q2, p3, level - 1); } else { GL11.glNormal3f(p1[0], p1[1], p1[2]); GL11.glVertex3f(p1[0], p1[1], p1[2]); GL11.glNormal3f(p2[0], p2[1], p2[2]); GL11.glVertex3f(p2[0], p2[1], p2[2]); GL11.glNormal3f(p3[0], p3[1], p3[2]); GL11.glVertex3f(p3[0], p3[1], p3[2]); } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawTriangle(final float[] vAll, final int v0, final int v1, final int v2, boolean solid) { float[] u = new float[3], v = new float[3], normal = new float[3]; u[0] = vAll[v1] - vAll[v0];//v1[0] - v0[0]; u[1] = vAll[v1 + 1] - vAll[v0 + 1];//v1[1] - v0[1]; u[2] = vAll[v1 + 2] - vAll[v0 + 2];//v1[2] - v0[2]; v[0] = vAll[v2] - vAll[v0];//v2[0] - v0[0]; v[1] = vAll[v2 + 1] - vAll[v0 + 1];//v2[1] - v0[1]; v[2] = vAll[v2 + 2] - vAll[v0 + 2];//v2[2] - v0[2]; crossProduct3(normal, u, v);/*from www .j a v a 2s . c o m*/ normalizeVector3(normal); GL11.glBegin(solid ? GL11.GL_TRIANGLES : GL11.GL_LINE_STRIP); GL11.glNormal3f(normal[0], normal[1], normal[2]); GL11.glVertex3f(vAll[v0], vAll[v0 + 1], vAll[v0 + 2]);//, v0[0], v0[1], v0[2]); GL11.glVertex3f(vAll[v1], vAll[v1 + 1], vAll[v1 + 2]);//v1[0], v1[1], v1[2]); GL11.glVertex3f(vAll[v2], vAll[v2 + 1], vAll[v2 + 2]);//v2[0], v2[1], v2[2]); GL11.glEnd(); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawTriangle(final float[] v0, final float[] v1, final float[] v2, boolean solid) { float[] u = new float[3], v = new float[3], normal = new float[3]; u[0] = v1[0] - v0[0];//from w w w.j av a 2 s. com u[1] = v1[1] - v0[1]; u[2] = v1[2] - v0[2]; v[0] = v2[0] - v0[0]; v[1] = v2[1] - v0[1]; v[2] = v2[2] - v0[2]; crossProduct3(normal, u, v); normalizeVector3(normal); GL11.glBegin(solid ? GL11.GL_TRIANGLES : GL11.GL_LINE_STRIP); GL11.glNormal3f(normal[0], normal[1], normal[2]); GL11.glVertex3f(v0[0], v0[1], v0[2]); GL11.glVertex3f(v1[0], v1[1], v1[2]); GL11.glVertex3f(v2[0], v2[1], v2[2]); 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);/* ww w . ja va2 s . c om*/ 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 drawSky(float[] view_xyz) { GL11.glDisable(GL11.GL_LIGHTING);//w w w . j a v a2 s . c o m if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); sky_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0f, 0.5f, 1.0f); } // make sure sky depth is as far back as possible GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDepthRange(1, 1); final float ssize = 1000.0f; float x = ssize * sky_scale; float y = view_xyz[1] + sky_height; GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(x + offset, -x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glTexCoord2f(x + offset, x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, -x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glEnd(); offset = offset + 0.002f; if (offset > 1) offset -= 1; GL11.glDepthFunc(GL11.GL_LESS); GL11.glDepthRange(0, 1); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawGround() { GL11.glDisable(GL11.GL_LIGHTING);//from w ww .java2 s . c om GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); // GL11.glDepthRange (1,1); if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); ground_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(GROUND_R, GROUND_G, GROUND_B); } // ground fog seems to cause problems with TNT2 under windows /* GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1}; GL11.glEnable (GL_FOG); GL11.glFogi (GL_FOG_MODE, GL_EXP2); GL11.glFogfv (GL_FOG_COLOR, fogColor); GL11.glFogf (GL_FOG_DENSITY, 0.05f); GL11.glHint (GL_FOG_HINT, GL_NICEST); // GL_DONT_CARE); GL11.glFogf (GL_FOG_START, 1.0); GL11.glFogf (GL_FOG_END, 5.0); */ final float gsize = 100.0f; final float offset = 0; // -0.001f; ... polygon offsetting doesn't work well GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, -gsize); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, -gsize); GL11.glEnd(); GL11.glDisable(GL11.GL_FOG); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawPyramidGrid() { // setup stuff GL11.glEnable(GL11.GL_LIGHTING);//from w w w. ja va 2 s. c o m GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); // draw the pyramid grid for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { GL11.glPushMatrix(); GL11.glTranslatef(i, 0, j); if (i == 1 && j == 0) setColor(1, 0, 0, 1); else if (i == 0 && j == 1) setColor(0, 0, 1, 1); else setColor(1, 1, 0, 1); final float k = 0.03f; GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glNormal3f(0, 1, -1); GL11.glVertex3f(0, k, 0); GL11.glVertex3f(-k, 0, -k); GL11.glVertex3f(k, 0, -k); GL11.glNormal3f(1, 1, 0); GL11.glVertex3f(k, 0, k); GL11.glNormal3f(0, 1, 1); GL11.glVertex3f(-k, 0, k); GL11.glNormal3f(-1, 1, 0); GL11.glVertex3f(-k, 0, -k); GL11.glEnd(); GL11.glPopMatrix(); } } }
From source file:RediscoveredMod.RenderParrow.java
License:Open Source License
public void renderArrow(EntityParrow par1EntityParrow, double par2, double par4, double par6, float par8, float par9) { this.bindEntityTexture(par1EntityParrow); GL11.glPushMatrix();//from w w w . j a v a 2 s . co m GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glRotatef( par1EntityParrow.prevRotationYaw + (par1EntityParrow.rotationYaw - par1EntityParrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef( par1EntityParrow.prevRotationPitch + (par1EntityParrow.rotationPitch - par1EntityParrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float) (0 + b0 * 10) / 32.0F; float f5 = (float) (5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float) (5 + b0 * 10) / 32.0F; float f9 = (float) (10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); float f11 = (float) par1EntityParrow.arrowShake - par9; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:runes.Runes.Entites.RenderRuneArrow.java
License:Open Source License
public void renderArrow(EntityRuneArrow par1EntityArrow, double par2, double par4, double par6, float par8, float par9) { this.bindEntityTexture(par1EntityArrow); GL11.glPushMatrix();//from w w w. j av a 2 s.c o m GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glRotatef( par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef( par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float) (0 + b0 * 10) / 32.0F; float f5 = (float) (5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float) (5 + b0 * 10) / 32.0F; float f9 = (float) (10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); float f11 = (float) par1EntityArrow.arrowShake - par9; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:shadowmage.ancient_framework.client.model.PrimitiveBox.java
License:Open Source License
@Override protected void renderForDisplayList() { float tw = parent.getModel().textureWidth; float th = parent.getModel().textureHeight; float px = 1.f / tw; float py = 1.f / th; float w = (x2 - x1) * 16.f; float h = (y2 - y1) * 16.f; float l = (z2 - z1) * 16.f; float ty = this.ty(); float tx = this.tx(); float tx1, ty1, tx2, ty2; //render the cube. only called a single time when building the display list for a piece if (rx != 0) { GL11.glRotatef(rx, 1, 0, 0);//w w w . j a v a 2s .c o m } if (ry != 0) { GL11.glRotatef(ry, 0, 1, 0); } if (rz != 0) { GL11.glRotatef(rz, 0, 0, 1); } GL11.glBegin(GL11.GL_QUADS); AWLog.logDebug("tx, ty: " + tx + "," + ty); AWLog.logDebug("w,l,h: " + w + "," + l + "," + h); //front side tx1 = (tx + l) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x1, y1, z2); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x2, y1, z2); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x2, y2, z2); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x1, y2, z2); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); ////rear side tx1 = (tx + l + l + w) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w + l + w) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(0, 0, -1); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y1, z1); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y2, z1); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y2, z1); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); //right side tx1 = (tx + l + w) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l + w + l) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(1, 0, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y1, z2); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y2, z2); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x1, y2, z1); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); // //left side tx1 = (tx) * px; ty1 = (th - (ty + l + h)) * py; tx2 = (tx + l) * px; ty2 = (th - (ty + l)) * py; GL11.glNormal3f(-1, 0, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y1, z2); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x2, y1, z1); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x2, y2, z1); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y2, z2); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); // //top side tx1 = (tx + l) * px; ty1 = (th - (ty + l)) * py; tx2 = (tx + l + w) * px; ty2 = (th - (ty)) * py; GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y2, z1); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y2, z1); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y2, z2); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y2, z2); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); // //bottom side tx1 = (tx + l + w) * px; ty1 = (th - (ty + l)) * py; tx2 = (tx + l + w + w) * px; ty2 = (th - (ty)) * py; GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(tx1, ty1); GL11.glVertex3f(x2, y1, z2); GL11.glTexCoord2f(tx2, ty1); GL11.glVertex3f(x1, y1, z2); GL11.glTexCoord2f(tx2, ty2); GL11.glVertex3f(x1, y1, z1); GL11.glTexCoord2f(tx1, ty2); GL11.glVertex3f(x2, y1, z1); AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2)); GL11.glEnd(); }