[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view Display.java, 1.38, 1.39
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-10-23 07:20:41
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18143/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: smooth normals Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Display.java 19 Oct 2007 12:17:22 -0000 1.38 --- Display.java 23 Oct 2007 07:20:44 -0000 1.39 *************** *** 112,115 **** --- 112,116 ---- glu.gluTessProperty(tesselator, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); + byte b1 = (byte) 0x88; byte b2 = (byte) 0x22; *************** *** 185,193 **** gl.glEnd(); } ! /** {@inheritDoc} */ public void vertex(Object object) { ! Vertex vertex = (Vertex) object; ! gl.glVertex3d(vertex.getX(), vertex.getY(), vertex.getZ()); } } --- 186,202 ---- gl.glEnd(); } ! /** {@inheritDoc} */ + @Override public void vertex(Object object) { ! double[] vertex = (double[]) object; ! gl.glNormal3dv(vertex, 3); ! gl.glVertex3dv(vertex, 0); ! } ! ! /** {@inheritDoc} */ ! @Override ! public void error(int arg0) { ! System.out.println(glu.gluErrorString(arg0)); } } *************** *** 451,454 **** --- 460,464 ---- private static void paintSurfaces(Collection<Surface> surfaces, boolean transparency) { gl.glEnable(GL.GL_LIGHTING); + gl.glShadeModel(GL.GL_SMOOTH); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); gl.glPolygonOffset(1.0f, 1.0f); *************** *** 463,467 **** paint(current, color, 1.0f, false); } else if (transparency) { - paint(current, color, 0.3f, false); } --- 473,476 ---- *************** *** 499,503 **** for (Surface current : surface.getHoles()) { if (surface.getOwner() == current.getOwner()) { ! drawContour(current, false); } } --- 508,512 ---- for (Surface current : surface.getHoles()) { if (surface.getOwner() == current.getOwner()) { ! drawContour(current, reverse); } } *************** *** 507,518 **** private static void drawContour(Surface surface, boolean reverse) { List<Vertex> vertices = surface.getVertices(); if (vertices.size() > 2) { vertices.add(vertices.get(0)); if (reverse) { Collections.reverse(vertices); } glu.gluTessBeginContour(tesselator); for (Vertex current : vertices) { ! glu.gluTessVertex(tesselator, current.values(), 0, current); } glu.gluTessEndContour(tesselator); --- 516,549 ---- private static void drawContour(Surface surface, boolean reverse) { List<Vertex> vertices = surface.getVertices(); + List<Vertex> normals = surface.getNormals(); + int index = 0; if (vertices.size() > 2) { vertices.add(vertices.get(0)); if (reverse) { Collections.reverse(vertices); + index = vertices.size() - 1; } glu.gluTessBeginContour(tesselator); + Vertex normal = surface.normal(); for (Vertex current : vertices) { ! double[] content = new double[6]; ! if (normals != null) { ! normal = normals.get(index % normals.size()); ! if (reverse) { ! content[3] = -normal.getX(); ! content[4] = -normal.getY(); ! content[5] = -normal.getZ(); ! index--; ! } else { ! content[3] = normal.getX(); ! content[4] = normal.getY(); ! content[5] = normal.getZ(); ! index++; ! } ! } ! content[0] = current.getX(); ! content[1] = current.getY(); ! content[2] = current.getZ(); ! glu.gluTessVertex(tesselator, content, 0, content); } glu.gluTessEndContour(tesselator); |