[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.49,1.50 View.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-11-01 07:36:17
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19538/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java View.java Log Message: added ClippingPlane functionality, there are still several problems 1) selection does not work proberly yet 2) The size of the Clipping plane need to be larger 3) there need to be a arrow or something to select clipping planes every time 4) the transparency also need to be greater 5) need its own icon Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** AbstractView.java 31 Oct 2005 07:52:45 -0000 1.49 --- AbstractView.java 1 Nov 2005 07:36:09 -0000 1.50 *************** *** 9,12 **** --- 9,13 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.tool.SelectTool; + import net.sourceforge.bprocessor.gl.model.ClippingPlane; import net.sourceforge.bprocessor.model.CoordinateSystem; *************** *** 58,68 **** private static final int SURFACES = 1; ! /** Select for for selecting vertices */ ! private static final int VERTICES = 2; ! /** Select mode for selecting ALL **/ ! ! private static final int ALL = 3; /** The width of the window */ --- 59,70 ---- private static final int SURFACES = 1; ! /** Select for for selecting vertices */ private static final int VERTICES = 2; ! ! /** Select for for selecting clipplanes */ ! private static final int CLIPPLANES = 3; ! /** Select mode for selecting ALL **/ ! private static final int ALL = 4; /** The width of the window */ *************** *** 159,162 **** --- 161,167 ---- protected static byte[] highlight = new byte[128]; + /** The list of clipping planes */ + private List clippingPlanes; + static { setTransparency(100); *************** *** 169,179 **** */ public static void setTransparency(int percent) { ! byte b1 = (byte)0xaa; ! byte b2 = (byte)0x55; ! for (int i = 0; i < transparency.length; i++) { ! if (((int)(i / 4)) % 2 == 0) { ! transparency[i] = b1; ! } else { ! transparency[i] = b2; } } --- 174,194 ---- */ public static void setTransparency(int percent) { ! if (percent == 50) { ! byte b1 = (byte)0xaa; ! byte b2 = (byte)0x55; ! for (int i = 0; i < transparency.length; i++) { ! if (((int)(i / 4)) % 2 == 0) { ! transparency[i] = b1; ! } else { ! transparency[i] = b2; ! } ! } ! } else if (percent < 50) { ! for (int i = 0; i < transparency.length; i++) { ! transparency[i] = 0; ! } ! } else if (percent > 50) { ! for (int i = 0; i < transparency.length; i++) { ! transparency[i] = 1; } } *************** *** 208,211 **** --- 223,227 ---- public AbstractView(GLView glv) { this.glv = glv; + clippingPlanes = new ArrayList(); } *************** *** 272,275 **** --- 288,297 ---- 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); *************** *** 281,288 **** coords(); gl.glColor3fv(STD_LINE_COLOR); gl.glLineWidth(1.0f); drawAll(gld); ! gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); --- 303,328 ---- coords(); + // 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(); + drawClipplane(cp); + } + gl.glDisable(GL.GL_POLYGON_STIPPLE); + + clipit = clippingPlanes.iterator(); + while (clipit.hasNext()) { + ClippingPlane cp = (ClippingPlane)clipit.next(); + gl.glClipPlane(GL.GL_CLIP_PLANE0 + cp.getNumber(), cp.getPlane().getDoublev()); + gl.glEnable(GL.GL_CLIP_PLANE0 + cp.getNumber()); + } + gl.glColor3fv(STD_LINE_COLOR); gl.glLineWidth(1.0f); drawAll(gld); ! gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); *************** *** 549,553 **** Set vertices = Project.getInstance().getVertices(); Collection selection = glv.getTool().getSelection(); ! int[] mode = new int[1]; gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); --- 589,593 ---- Set vertices = Project.getInstance().getVertices(); Collection selection = glv.getTool().getSelection(); ! int[] mode = new int[1]; gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); *************** *** 555,561 **** gl = gld.getGL(); glu = gld.getGLU(); ! initNames(gl); ! if (mode[0] != GL.GL_SELECT) { gl.glEnable(GL.GL_DEPTH_TEST); // draw selection --- 595,601 ---- gl = gld.getGL(); glu = gld.getGLU(); ! initNames(gl); ! if (mode[0] != GL.GL_SELECT) { gl.glEnable(GL.GL_DEPTH_TEST); // draw selection *************** *** 567,571 **** } - // Draw edges if (doDrawEdges) { --- 607,610 ---- *************** *** 630,638 **** break; } ! } ! ! ! ! // draw target --- 669,673 ---- break; } ! } // draw target *************** *** 701,705 **** } } else { - // HERE STARTS SELECTION MODE DRAWING if (selectMode == VERTICES || selectMode == ALL) { --- 736,739 ---- *************** *** 733,740 **** --- 767,803 ---- } } + if (selectMode == CLIPPLANES || selectMode == ALL) { + Iterator it = clippingPlanes.iterator(); + while (it.hasNext()) { + ClippingPlane cp = (ClippingPlane)it.next(); + pushName(gl, cp); + drawClipplane(cp); + popName(gl); + } + } } } /** + * Draw a clippingPlane + * @param clipplane The clipplane to draw + */ + 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(); + } + + /** * Draw an object * @param o The Object *************** *** 766,769 **** --- 829,833 ---- } } + /** * Draw a surface *************** *** 1133,1137 **** if (near < nearest) { nearest = near; ! closest = current; } bufferOffset += names; --- 1197,1204 ---- if (near < nearest) { nearest = near; ! if (!(current instanceof ClippingPlane && closest != null)) { ! // if the closest are set we don't care about clipplanes ! closest = current; ! } } bufferOffset += names; *************** *** 1167,1176 **** } } return closest; } ! ! ! /** * Gets id of the object under a point. For use in selection. * @param x the x coordinate of the point in mouse coordinates --- 1234,1244 ---- } } + if (closest instanceof ClippingPlane) { + ClippingPlane cp = (ClippingPlane) closest; + } return closest; } ! /** * Gets id of the object under a point. For use in selection. * @param x the x coordinate of the point in mouse coordinates *************** *** 1205,1208 **** --- 1273,1298 ---- /** + * Adds a clippingPlane to the view + * @param cp The clippingPlane + */ + public void addClippingPlane(ClippingPlane cp) { + int[] maxclip = new int[1]; + gl.glGetIntegerv(GL.GL_MAX_CLIP_PLANES, maxclip); + if (clippingPlanes.size() < maxclip[0] || maxclip[0] == 0) { + log.info("Added clipplane"); + cp.setNumber(clippingPlanes.size()); + clippingPlanes.add(cp); + } + } + + /** + * Remove the given clippingplane + * @param cp The clippingplane to remove + */ + public void removeClippingPlane(ClippingPlane cp) { + clippingPlanes.remove(cp); + } + + /** * The camera init function * @param gld The GLDrawable object Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** View.java 31 Oct 2005 07:52:45 -0000 1.16 --- View.java 1 Nov 2005 07:36:09 -0000 1.17 *************** *** 10,13 **** --- 10,14 ---- import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Plane; + import net.sourceforge.bprocessor.gl.model.ClippingPlane; import net.sourceforge.bprocessor.model.Surface; *************** *** 60,63 **** --- 61,67 ---- public static final float[] SELECTED_COLOR = new float[] {1.0f, 0.4f, 1.0f}; + /** Used for clipping planes */ + public static final float[] CLIP_PLANE_COLOR = new float[] {1.0f, 0.65f, 0.0f}; + /** Used for target objects */ public static final float[] TARGET_COLOR = new float[] {0.8f, 0.8f, 0.1f}; *************** *** 71,75 **** /** Can be used for setting lighting mode */ public static final int LIGHTING_MODE = 2; ! /** * Resets the working attributes of the view --- 75,91 ---- /** Can be used for setting lighting mode */ public static final int LIGHTING_MODE = 2; ! ! /** ! * Adds a clippingPlane to the view ! * @param cp The clippingPlane ! */ ! public void addClippingPlane(ClippingPlane cp); ! ! /** ! * Remove the given clippingplane ! * @param cp The clippingplane to remove ! */ ! public void removeClippingPlane(ClippingPlane cp); ! /** * Resets the working attributes of the view |