[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.232, 1.233 Display.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-09-23 19:41:14
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5432/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: Progress on new display mechanism Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Display.java 23 Sep 2007 18:20:26 -0000 1.3 --- Display.java 23 Sep 2007 19:41:16 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- package net.sourceforge.bprocessor.gl.view; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; *************** *** 27,30 **** --- 28,32 ---- import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Project; + import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; *************** *** 40,43 **** --- 42,46 ---- private static GL gl; private static GLU glu; + private static ArrayList objects; private static float[] white = new float[] {1.0f, 1.0f, 1.0f}; *************** *** 45,48 **** --- 48,54 ---- private static float[] blueish = new float[] {0.1f, 0.2f, 0.5f}; private static float[] redish = new float[] {0.5f, 0.2f, 0.1f}; + + private static byte[] highlight = new byte[128]; + /** * *************** *** 66,69 **** --- 72,93 ---- glu.gluTessCallback(tesselator, GLU.GLU_TESS_VERTEX, callback); glu.gluTessProperty(tesselator, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); + + byte b1 = (byte) 0x88; + byte b2 = (byte) 0x22; + byte b3 = (byte) 0x00; + for (int i = 0; i < highlight.length; i++) { + int d = ((int)(i / 4)) % 4; + + if (d == 0) { + highlight[i] = b1; + } else if (d == 1) { + highlight[i] = b3; + } else if (d == 2) { + highlight[i] = b2; + } else if (d == 3) { + highlight[i] = b3; + } + } + initialized = true; } *************** *** 97,100 **** --- 121,148 ---- } + /** + * Set the objects table + * @param value ArrayList + */ + public static void objects(ArrayList value) { + objects = value; + } + + private static void push(Object object) { + objects.add(object); + gl.glPushName(objects.size()); + } + private static void pop() { + gl.glPopName(); + } + + private static void selectSurfaces(Collection<Surface> surfaces) { + for (Surface current : surfaces) { + push(current); + draw(current, false); + pop(); + } + } + private static void drawSurfaces(Collection<Surface> surfaces) { gl.glEnable(GL.GL_LIGHTING); *************** *** 130,133 **** --- 178,189 ---- } + private static void highlight(Surface surface) { + gl.glEnable(GL.GL_POLYGON_STIPPLE); + gl.glPolygonStipple(highlight, 0); + gl.glColor3fv(redish, 0); + draw(surface, false); + gl.glDisable(GL.GL_POLYGON_STIPPLE); + } + private static void draw(Surface surface, boolean reverse) { glu.gluTessBeginPolygon(tesselator, null); *************** *** 156,163 **** --- 212,227 ---- private static void drawEdges(Collection<Edge> edges) { gl.glColor3fv(black, 0); + gl.glLineWidth(1.0f); for (Edge current : edges) { draw(current); } } + private static void selectEdges(Collection<Edge> edges) { + for (Edge current : edges) { + push(current); + draw(current); + pop(); + } + } private static void draw(Edge edge) { *************** *** 246,257 **** } - - - - gl.glEnable(GL.GL_DEPTH_TEST); - drawSurfaces(surfaces); - drawEdges(edges); for (Space current : elements) { draw(current); --- 310,346 ---- } + gl.glEnable(GL.GL_DEPTH_TEST); + if (selecting()) { + selectSurfaces(surfaces); + } else { + drawSurfaces(surfaces); + gl.glEnable(GL.GL_POLYGON_STIPPLE); + gl.glPolygonStipple(highlight, 0); + gl.glColor3fv(redish, 0); + for (Geometric current : Selection.primary()) { + if (current.getOwner() == space) { + if (current instanceof Surface) { + draw((Surface) current, false); + } + } + } + gl.glDisable(GL.GL_POLYGON_STIPPLE); + } + if (selecting()) { + selectEdges(edges); + } else { + gl.glColor3fv(redish, 0); + gl.glLineWidth(2.0f); + for (Geometric current : Selection.primary()) { + if (current.getOwner() == space) { + if (current instanceof Edge) { + draw((Edge) current); + } + } + } + drawEdges(edges); + } for (Space current : elements) { draw(current); Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.232 retrieving revision 1.233 diff -C2 -d -r1.232 -r1.233 *** View.java 23 Sep 2007 16:02:08 -0000 1.232 --- View.java 23 Sep 2007 19:41:16 -0000 1.233 *************** *** 691,694 **** --- 691,695 ---- Display.selecting(hitdetection); initNames(gl); + Display.objects(objectTable); Display.draw(gld); Display.selecting(false); |