[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.53,1.54 View.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-11-06 16:33:56
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31240/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java View.java Log Message: Fixed some issues with clipping planes: - The ClipPlane are defined by a CoordinateSystem (which can return a plane) to make some calculations easier - The ClipPlane now always points away from camera when being defined. - The corners of the ClipPlane are calculated in local coordinates of the plane with a margin of 1 (meter) to better distinguish the plane from existing geometry. Then translated to global coordinates. - The ClipPlane are moved 0.001 (a millimeter) in the positive direction. - The edges of the ClipPlane are shown. - Clipping is turned off when drawing the 2d overlay (space names) - The modelview matrix is pushed after camera setup, which fixes a weird OpenGL lighting problem (involving clipplanes and the 2d overlay). Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** AbstractView.java 4 Nov 2005 09:38:55 -0000 1.53 --- AbstractView.java 6 Nov 2005 16:33:44 -0000 1.54 *************** *** 275,278 **** --- 275,279 ---- */ public void display(GLDrawable gld) { + Plane xy = new Plane(0, 0, 1, 0); gl = gld.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); *************** *** 292,303 **** camera(gld); picking = 0; ! Iterator clipit = clippingPlanes.iterator(); ! while (clipit.hasNext()) { ! ClippingPlane cp = (ClippingPlane)clipit.next(); ! gl.glDisable(GL.GL_CLIP_PLANE0 + cp.getNumber()); ! } ! // grid and coords are always completely lit gl.glDisable(GL.GL_DEPTH_TEST); --- 293,301 ---- camera(gld); + gl.glPushMatrix(); picking = 0; ! ! // grid and coords are always completely lit gl.glDisable(GL.GL_DEPTH_TEST); *************** *** 310,317 **** // draw the clipping planes ! clipit = clippingPlanes.iterator(); gl.glEnable(GL.GL_POLYGON_STIPPLE); ! setTransparency(50); ! gl.glPolygonStipple(transparency); while (clipit.hasNext()) { ClippingPlane cp = (ClippingPlane)clipit.next(); --- 308,315 ---- // draw the clipping planes ! ! Iterator clipit = clippingPlanes.iterator(); gl.glEnable(GL.GL_POLYGON_STIPPLE); ! gl.glPolygonStipple(highlight); while (clipit.hasNext()) { ClippingPlane cp = (ClippingPlane)clipit.next(); *************** *** 330,333 **** --- 328,337 ---- gl.glLineWidth(1.0f); drawAll(gld); + + clipit = clippingPlanes.iterator(); + while (clipit.hasNext()) { + ClippingPlane cp = (ClippingPlane)clipit.next(); + gl.glDisable(GL.GL_CLIP_PLANE0 + cp.getNumber()); + } gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); *************** *** 335,338 **** --- 339,343 ---- if (glv.getTool() instanceof SelectTool) { gl.glMatrixMode(GL.GL_PROJECTION); + gl.glPushMatrix(); gl.glLoadIdentity(); if (mode[0] == GL.GL_SELECT) { *************** *** 342,349 **** glu.gluOrtho2D(0, width, 0, height); gl.glMatrixMode(GL.GL_MODELVIEW); ! gl.glLoadIdentity(); labelSelection(mode[0] == GL.GL_SELECT); } ! if (mode[0] == GL.GL_SELECT) { gl.glFlush(); --- 347,360 ---- glu.gluOrtho2D(0, width, 0, height); gl.glMatrixMode(GL.GL_MODELVIEW); ! gl.glPushMatrix(); ! gl.glLoadIdentity(); labelSelection(mode[0] == GL.GL_SELECT); + gl.glMatrixMode(GL.GL_PROJECTION); + gl.glPopMatrix(); + gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glPopMatrix(); + } ! gl.glPopMatrix(); if (mode[0] == GL.GL_SELECT) { gl.glFlush(); *************** *** 363,366 **** --- 374,378 ---- gl.glPushMatrix(); gl.glTranslated(x, y, 0.1); + gl.glRasterPos2i(0, 0); glut.glutBitmapString(gl, GLUT.BITMAP_HELVETICA_18, string); *************** *** 512,515 **** --- 524,529 ---- } + + if (clickable) { //Name must be "front" *************** *** 531,534 **** --- 545,549 ---- } //draw the front domain name + if (frontDomain instanceof FunctionalSpace) { gl.glColor3d(0.2 + fcb, 0.2 + fcb, 0.5 + fcb); *************** *** 538,541 **** --- 553,557 ---- gl.glColor3d(0.2 + fcb, 0.2 + fcb, 0.2 + fcb); } + drawString(frontTextAnchor.getX(), frontTextAnchor.getY(), frontName); *************** *** 552,555 **** --- 568,572 ---- gl.glColor3d(0.2 + bcb, 0.2 + bcb, 0.2 + bcb); } + drawString(backTextAnchor.getX(), backTextAnchor.getY(), backName); *************** *** 582,586 **** private void drawClickBox(double x, double y, double z, int width, int height, String name) { ! pushName(gl, name); gl.glBegin(GL.GL_POLYGON); gl.glVertex3d(x, y, z); --- 599,603 ---- private void drawClickBox(double x, double y, double z, int width, int height, String name) { ! pushName(gl, name); gl.glBegin(GL.GL_POLYGON); gl.glVertex3d(x, y, z); *************** *** 803,807 **** ClippingPlane cp = (ClippingPlane)it.next(); pushName(gl, cp); ! drawClipplane(cp); popName(gl); } --- 820,824 ---- ClippingPlane cp = (ClippingPlane)it.next(); pushName(gl, cp); ! //drawClipplane(cp); popName(gl); } *************** *** 815,831 **** */ private void drawClipplane(ClippingPlane clipplane) { ! gl.glColor3fv(CLIP_PLANE_COLOR); double[] d = clipplane.getPlane().getDoublev(); - gl.glBegin(GL.GL_QUADS); - gl.glNormal3d(d[0], d[1], d[2]); Collection corners = clipplane.getCorners(); ! Iterator it = corners.iterator(); ! while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); gl.glVertex3d(v.getX(), v.getY(), v.getZ()); } - gl.glEnd(); } --- 832,868 ---- */ private void drawClipplane(ClippingPlane clipplane) { ! double[] d = clipplane.getPlane().getDoublev(); Collection corners = clipplane.getCorners(); ! { ! gl.glColor3fv(CLIP_PLANE_COLOR); ! gl.glBegin(GL.GL_QUADS); ! gl.glNormal3d(d[0], d[1], d[2]); ! Iterator it = corners.iterator(); ! while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! gl.glVertex3d(v.getX(), ! v.getY(), ! v.getZ()); ! } ! gl.glEnd(); ! } ! { ! gl.glColor3fv(CLIP_PLANE_COLOR); ! gl.glLineWidth(2.0f); ! gl.glBegin(GL.GL_LINE_STRIP); ! Iterator it = corners.iterator(); ! while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! gl.glVertex3d(v.getX(), ! v.getY(), ! v.getZ()); ! } ! Vertex v = (Vertex) corners.iterator().next(); gl.glVertex3d(v.getX(), v.getY(), v.getZ()); + gl.glEnd(); } } *************** *** 1483,1491 **** */ public boolean facingFront(Surface surface) { ! Vertex normal = surface.normal(); Transformation transformation = transformation(); ! Vertex center = transformation.project(surface.center()); ! Vertex from = new Vertex("", center.getX(), center.getY(), 0.0); ! Vertex to = new Vertex("", center.getX(), center.getY(), 1.0); Edge ray = new Edge("", from, to); Vertex rayDir; --- 1520,1538 ---- */ public boolean facingFront(Surface surface) { ! return facingFront(surface.coordinateSystem()); ! } ! ! /** ! * Returns a boolean idicating wherther or not we are facing ! * the front of the CoordinateSystem. ! * @param system the coordinate system ! * @return the boolean ! */ ! public boolean facingFront(CoordinateSystem system) { ! Vertex normal = system.getN(); Transformation transformation = transformation(); ! Vertex origin = transformation.project(system.origin()); ! Vertex from = new Vertex("", origin.getX(), origin.getY(), 0.0); ! Vertex to = new Vertex("", origin.getX(), origin.getY(), 1.0); Edge ray = new Edge("", from, to); Vertex rayDir; Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** View.java 3 Nov 2005 11:08:08 -0000 1.18 --- View.java 6 Nov 2005 16:33:44 -0000 1.19 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.gl.view; + import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Vertex; *************** *** 224,227 **** --- 225,236 ---- /** + * Returns a boolean idicating wherther or not we are facing + * the front of the CoordinateSystem. + * @param system the coordinate system + * @return the boolean + */ + public boolean facingFront(CoordinateSystem system); + + /** * Called when a space-label corresponding to the front of a Surface is selected. */ |