Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.5,1.6
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-08-17 08:56:19
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27837 Modified Files: AbstractView.java Log Message: changed the look so that surfaces is draw solid with a little transparency and edges a bit more massive Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractView.java 16 Aug 2005 12:03:26 -0000 1.5 --- AbstractView.java 17 Aug 2005 08:56:08 -0000 1.6 *************** *** 9,13 **** import net.sourceforge.bprocessor.kernel.notification.Notification; - import net.sourceforge.bprocessor.gl.tool.Util; import net.sourceforge.bprocessor.gl.GLView; --- 9,12 ---- *************** *** 45,49 **** /** the std line color*/ ! public static final double[] STD_LINE_COLOR = new double[] {0.0, 0.0, 0.0}; /** Used for the actual drawing line */ --- 44,48 ---- /** the std line color*/ ! public static final double[] STD_LINE_COLOR = new double[] {0.1, 0.1, 0.1}; /** Used for the actual drawing line */ *************** *** 51,58 **** /** Used for the actual drawing line */ ! public static final double[] GRID_COLOR = new double[] {0.85, 0.85, 0.85}; /** Used for selected objects */ ! public static final double[] SELECTED_COLOR = new double[] {1.0, 0.4, 1.0}; /** The view transformation matrix (it is shown transposed) see p. 187 [GL BIBLE]*/ --- 50,60 ---- /** Used for the actual drawing line */ ! public static final double[] GRID_COLOR = new double[] {0.85, 0.85, 0.85, 0.8}; ! ! /** Surface color for all not selected surfaces */ ! public static final double[] SURFACE_COLOR = new double[] {0.93, 0.93, 0.93, 0.7}; /** Used for selected objects */ ! public static final double[] SELECTED_COLOR = new double[] {1.0, 0.4, 1.0, 0.7}; /** The view transformation matrix (it is shown transposed) see p. 187 [GL BIBLE]*/ *************** *** 131,135 **** gl = gld.getGL(); glu = gld.getGLU(); - gl.glEnable(GL.GL_CULL_FACE); this.width = gld.getSize().getWidth(); this.height = gld.getSize().getHeight(); --- 133,136 ---- *************** *** 139,142 **** --- 140,145 ---- drawable = gld; + gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL.GL_BLEND); gl.glClearColor(0.7f, 0.7f, 0.7f, 0.0f); gl.glViewport(0, 0, (int)width, (int)height); *************** *** 150,165 **** long before = System.currentTimeMillis(); gl = gld.getGL(); glu = gld.getGLU(); drawable = gld; - gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glViewport(0, 0, (int)width, (int)height); camera(gld); ! grid(); coords(); gl.glColor3dv(STD_LINE_COLOR); ! gl.glLineWidth(1.0f); drawAll(gld); long after = System.currentTimeMillis(); --- 153,172 ---- long before = System.currentTimeMillis(); gl = gld.getGL(); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + glu = gld.getGLU(); drawable = gld; gl.glViewport(0, 0, (int)width, (int)height); camera(gld); ! ! gl.glLineWidth(1.0f); grid(); + gl.glLineWidth(3.0f); coords(); gl.glColor3dv(STD_LINE_COLOR); ! gl.glLineWidth(2.0f); drawAll(gld); long after = System.currentTimeMillis(); *************** *** 172,175 **** --- 179,191 ---- /** + * Resets the working attributes of the view + */ + public void reset() { + setAlignVertex(null); + setSnapVertex(null); + setAlignPoint(null); + } + + /** * Called by the drawable during the first repaint after the component has been resized. * @param gld The GLDrawable *************** *** 204,208 **** */ protected void drawAll(GLDrawable gld) { ! Set edges = EdgeFacade.getInstance().findAll(); gl = gld.getGL(); --- 220,224 ---- */ protected void drawAll(GLDrawable gld) { ! Set surfaces = SurfaceFacade.getInstance().findAll(); Set edges = EdgeFacade.getInstance().findAll(); gl = gld.getGL(); *************** *** 210,218 **** gl.glInitNames(); ! Iterator it = edges.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); ! drawEdge(e); } --- 226,245 ---- gl.glInitNames(); ! Iterator it = surfaces.iterator(); ! gl.glColor4dv(SURFACE_COLOR); ! while (it.hasNext()) { ! Surface s = (Surface)it.next(); ! if (!s.equals(selectedSurface)) { ! drawSurface(s); ! } ! } ! ! it = edges.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); ! if (!e.equals(selectedEdge)) { ! drawEdge(e); ! } } *************** *** 231,234 **** --- 258,262 ---- } gl.glBegin(GL.GL_LINES); + gl.glLineWidth(1.0f); gl.glVertex3d(from.getX(), from.getY(), from.getZ()); gl.glVertex3d(to.getX(), to.getY(), to.getZ()); *************** *** 265,269 **** // draw selected vertex if (selectedVertex != null) { ! gl.glColor3dv(SELECTED_COLOR); gl.glPointSize(5.0f); gl.glBegin(GL.GL_POINTS); --- 293,297 ---- // draw selected vertex if (selectedVertex != null) { ! gl.glColor4dv(SELECTED_COLOR); gl.glPointSize(5.0f); gl.glBegin(GL.GL_POINTS); *************** *** 276,280 **** // draw selected edge if (selectedEdge != null) { ! gl.glColor3dv(SELECTED_COLOR); selectedEdge = EdgeFacade.getInstance().findById(selectedEdge.getId()); Vertex to = selectedEdge.getTo(); --- 304,308 ---- // draw selected edge if (selectedEdge != null) { ! gl.glColor4dv(SELECTED_COLOR); selectedEdge = EdgeFacade.getInstance().findById(selectedEdge.getId()); Vertex to = selectedEdge.getTo(); *************** *** 288,292 **** // draw selected surface if (selectedSurface != null) { ! gl.glColor3dv(SELECTED_COLOR); selectedSurface = SurfaceFacade.getInstance().findById(selectedSurface.getId()); drawSurface(selectedSurface); --- 316,320 ---- // draw selected surface if (selectedSurface != null) { ! gl.glColor4dv(SELECTED_COLOR); selectedSurface = SurfaceFacade.getInstance().findById(selectedSurface.getId()); drawSurface(selectedSurface); *************** *** 299,308 **** */ private void drawSurface(Surface s) { ! List l = Util.traverse(s); if (l != null) { gl.glBegin(GL.GL_POLYGON); for (int i = 0; i < l.size(); i++) { ! Vertex v = (Vertex)l.get(i); ! gl.glVertex3d(v.getX(), v.getY(), v.getZ()); } gl.glEnd(); --- 327,358 ---- */ private void drawSurface(Surface s) { ! List l = s.getEdges(); if (l != null) { gl.glBegin(GL.GL_POLYGON); + Vertex previous = null; + Edge previousEdge = null; for (int i = 0; i < l.size(); i++) { ! Edge e = (Edge)l.get(i); ! if (previous == null) { ! previous = e.getTo(); ! // will be drawn with the secound vertex as to find out if it is to or from that counts ! } else { ! Vertex temp = e.otherVertex(previous); ! if (temp != null) { ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! previous = temp; ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! } else { ! temp = previousEdge.otherVertex(previous); ! gl.glVertex3d(temp.getX(), temp.getY(), temp.getZ()); ! previous = e.otherVertex(temp); ! if (previous == null) { ! log.warn("[drawSurface] could not find vertex " + temp + " on " + e); ! } else { ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! } ! } ! } ! previousEdge = e; } gl.glEnd(); |