[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view Display.java, 1.28, 1.29
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-10-11 13:57:26
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17207/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: Attempts to implement transparency Ð not finished Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Display.java 11 Oct 2007 13:12:12 -0000 1.28 --- Display.java 11 Oct 2007 13:57:28 -0000 1.29 *************** *** 284,290 **** */ ! private static void apply(float[] color) { ! float[] alpha = new float[]{color[0], color[1], color[2], 1.0f}; ! gl.glColor4fv(alpha, 0); } --- 284,294 ---- */ ! private static void apply(float[] color, float a) { ! if (a == 1.0) { ! gl.glColor3fv(color, 0); ! } else { ! float[] alpha = new float[]{color[0], color[1], color[2], a}; ! gl.glColor4fv(alpha, 0); ! } } *************** *** 363,369 **** ! private static void selectSurfaces(Collection<Surface> surfaces) { for (Surface current : surfaces) { ! if (!transparent(current)) { push(current); draw(current, false); --- 367,373 ---- ! private static void selectSurfaces(Collection<Surface> surfaces, boolean transparency) { for (Surface current : surfaces) { ! if (!transparent(current) || transparency) { push(current); draw(current, false); *************** *** 376,380 **** gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); gl.glPolygonOffset(1.0f, 1.0f); ! apply(color); for (Surface current : surfaces) { if (!transparent(current)) { --- 380,384 ---- gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); gl.glPolygonOffset(1.0f, 1.0f); ! apply(color, 1.0f); for (Surface current : surfaces) { if (!transparent(current)) { *************** *** 385,390 **** } ! private static void paintSurfaces(Collection<Surface> surfaces) { ! gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); --- 389,403 ---- } ! private static float[] colorOf(Space space) { ! if (space.isVoid()) { ! return misty; ! } else if (space.isConstructionSpace()) { ! return Defaults.getFrontColor(); ! } else { ! return Defaults.getBackColor(); ! } ! } ! ! private static void paintSurfaces(Collection<Surface> surfaces, boolean transparency) { gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); *************** *** 393,423 **** gl.glCullFace(GL.GL_BACK); for (Surface current : surfaces) { if (!transparent(current)) { ! Space front = current.getFrontDomain(); ! Vertex n = current.normal(); ! gl.glNormal3d(n.getX(), n.getY(), n.getZ()); ! if (front.isVoid()) { ! apply(misty); ! } else if (front.isConstructionSpace()) { ! apply(Defaults.getFrontColor()); ! } else { ! apply(Defaults.getBackColor()); ! } ! draw(current, false); } } for (Surface current : surfaces) { if (!transparent(current)) { ! Space back = current.getBackDomain(); ! Vertex n = current.normal(); ! gl.glNormal3d(-n.getX(), -n.getY(), -n.getZ()); ! if (back.isVoid()) { ! apply(misty); ! } else if (back.isConstructionSpace()) { ! apply(Defaults.getFrontColor()); ! } else { ! apply(Defaults.getBackColor()); ! } ! draw(current, true); } } --- 406,428 ---- gl.glCullFace(GL.GL_BACK); for (Surface current : surfaces) { + Space front = current.getFrontDomain(); + Vertex n = current.normal(); + gl.glNormal3d(n.getX(), n.getY(), n.getZ()); + float[] color = colorOf(front); if (!transparent(current)) { ! paint(current, color, 1.0f, false); ! } else if (transparency) { ! paint(current, color, 0.3f, false); } } for (Surface current : surfaces) { + Space back = current.getBackDomain(); + Vertex n = current.normal(); + gl.glNormal3d(-n.getX(), -n.getY(), -n.getZ()); + float[] color = colorOf(back); if (!transparent(current)) { ! paint(current, color, 1.0f, true); ! } else if (transparency) { ! paint(current, color, 0.3f, true); } } *************** *** 427,430 **** --- 432,440 ---- } + private static void paint(Surface surface, float[] color, float alpha, boolean reverse) { + apply(color, alpha); + draw(surface, reverse); + } + private static void draw(Surface surface, boolean reverse) { glu.gluTessBeginPolygon(tesselator, null); *************** *** 637,643 **** for (Surface current : visible) { if (!hidden.contains(current)) { ! if (!transparent(current)) { ! surfaces.add(current); ! } } } --- 647,651 ---- for (Surface current : visible) { if (!hidden.contains(current)) { ! surfaces.add(current); } } *************** *** 712,716 **** if (inside) { if (mode != View.WIREFRAME_MODE) { ! selectSurfaces(surfaces); } } --- 720,728 ---- if (inside) { if (mode != View.WIREFRAME_MODE) { ! if (mode == View.LIGHTING_MODE) { ! selectSurfaces(surfaces, true); ! } else { ! selectSurfaces(surfaces, false); ! } } } *************** *** 725,730 **** if (mode == View.SOLID_MODE) { paintSurfaces(surfaces, alice); ! } else if (mode == View.LIGHTING_MODE || mode == View.SPACE_ASSGN_MODE) { ! paintSurfaces(surfaces); } else if (mode == View.WIREFRAME_MODE) { // do not paint surfaces --- 737,744 ---- if (mode == View.SOLID_MODE) { paintSurfaces(surfaces, alice); ! } else if (mode == View.LIGHTING_MODE) { ! paintSurfaces(surfaces, true); ! } else if (mode == View.SPACE_ASSGN_MODE) { ! paintSurfaces(surfaces, false); } else if (mode == View.WIREFRAME_MODE) { // do not paint surfaces |