[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java,1.8,1.9 View3D.java,1.13,1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-09-02 13:21:28
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12369 Modified Files: View.java View3D.java AbstractView.java Log Message: Added toPlaneCoords for the views Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractView.java 1 Sep 2005 06:05:15 -0000 1.18 --- AbstractView.java 2 Sep 2005 13:21:19 -0000 1.19 *************** *** 11,14 **** --- 11,15 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.EdgeFacade; *************** *** 134,138 **** /** The drawing mode. Either wireframe, solid og lighting */ ! protected int drawMode = WIREFRAME_MODE; /** The transparency of surfaces */ --- 135,139 ---- /** The drawing mode. Either wireframe, solid og lighting */ ! protected int drawMode = View.WIREFRAME_MODE; /** The transparency of surfaces */ *************** *** 148,155 **** */ public static void setTransparency(int percent) { ! byte b = (byte)0xff; //(byte)(255 * (percent / 100)); ! log.info("value = " + b); for (int i = 0; i < transparency.length; i++) { ! transparency[i] = b; } } --- 149,160 ---- */ 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; ! } } } *************** *** 225,234 **** // set up lighting for the model if (drawMode == LIGHTING_MODE) { ! gl.glShadeModel(GL.GL_SMOOTH); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); gl.glEnable(GL.GL_COLOR_MATERIAL); gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1); ! //gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE); gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] {0.3f, 0.3f, 0.3f, 1.0f}); --- 230,239 ---- // set up lighting for the model if (drawMode == LIGHTING_MODE) { ! //gl.glShadeModel(GL.GL_SMOOTH); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); gl.glEnable(GL.GL_COLOR_MATERIAL); gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1); ! gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE); gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] {0.3f, 0.3f, 0.3f, 1.0f}); *************** *** 314,319 **** --- 319,327 ---- if (selectedSurface != null) { gl.glColor3fv(SELECTED_COLOR); + gl.glEnable(GL.GL_POLYGON_STIPPLE); + gl.glPolygonStipple(transparency); selectedSurface = SurfaceFacade.getInstance().findById(selectedSurface.getId()); drawSurface(selectedSurface); + gl.glDisable(GL.GL_POLYGON_STIPPLE); } *************** *** 330,333 **** --- 338,342 ---- } + gl.glDisable(GL.GL_LIGHTING); // draw activeEdge different if it is parallel with axis if (activeEdge != null) { *************** *** 409,415 **** } } ! ! // HERE STARTS SELECTION MODE DRAWING } else { if (selectMode == SURFACES) { Iterator it = surfaces.iterator(); --- 418,424 ---- } } ! gl.glEnable(GL.GL_LIGHTING); } else { + // HERE STARTS SELECTION MODE DRAWING if (selectMode == SURFACES) { Iterator it = surfaces.iterator(); *************** *** 455,462 **** */ private void drawSurface(Surface s) { - //gl.glEnable(GL.GL_POLYGON_STIPPLE); - //gl.glDisable(GL.GL_BLEND); - //glblend.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - //gl.glPolygonStipple(transparency); List l = s.getEdges(); if (l != null) { --- 464,467 ---- *************** *** 895,898 **** --- 900,913 ---- /** + * Return the 3D coordinates for the canvas matching the given 2D coords + * @param coords The coordinate to convert + * @param plane The plane to find intersection with + * @return The point in 3D + */ + public double[] toPlaneCoords(double[] coords, Plane plane) { + return toCanvasCoords(coords); + } + + /** * representation of a 3D point. */ Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** View3D.java 31 Aug 2005 08:33:55 -0000 1.13 --- View3D.java 2 Sep 2005 13:21:19 -0000 1.14 *************** *** 164,188 **** */ public double[] toCanvasCoords(double[] coords) { ! if (coords.length == 2) { ! double x = coords[0]; double y = AbstractView.getHeight() - coords[1]; ! Transformation transformation = transformation(); ! ! Plane xy = new Plane(0, 0, 1, 0); Vertex near = new Vertex("near", x, y, 0.0); Vertex far = new Vertex("far", x, y, 1.0); Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); ! Vertex vertex = xy.intersection(ray); ! return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; ! } else { ! log.warn("Too many arguments"); ! return new double[] {0.0, 0.0, 0.0}; ! } } ! /** * Get transformation for model to screen coordinates --- 164,197 ---- */ public double[] toCanvasCoords(double[] coords) { ! return toPlaneCoords(coords, new Plane(0, 0, 1, 0)); ! } ! ! /** ! * Return the point in the space that intersects with the given plane ! * @return The intersection between the ray through the space and the given plane ! * @param coords The screen coordinate ! * @param plane The plane in the space to intersect with ! */ ! public double[] toPlaneCoords(double[] coords, Plane plane) { ! if (coords.length == 2 && plane != null) { double x = coords[0]; double y = AbstractView.getHeight() - coords[1]; ! Transformation transformation = transformation(); ! Vertex near = new Vertex("near", x, y, 0.0); Vertex far = new Vertex("far", x, y, 1.0); Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); ! Vertex vertex = plane.intersection(ray); ! if (vertex != null) { ! return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; ! } ! } ! log.warn("Too many arguments"); ! return new double[] {0.0, 0.0, 0.0}; } ! /** * Get transformation for model to screen coordinates Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** View.java 30 Aug 2005 13:20:08 -0000 1.8 --- View.java 2 Sep 2005 13:21:19 -0000 1.9 *************** *** 11,14 **** --- 11,15 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.Plane; import net.java.games.jogl.GLEventListener; *************** *** 76,79 **** --- 77,88 ---- /** + * Return the 3D coordinates for the canvas matching the given 2D coords + * @param coords The window coordinates + * @param plane The plane to find intersection with + * @return The relative 3D coordinates + */ + public double[] toPlaneCoords(double[] coords, Plane plane); + + /** * Return the distance on the canvas matching the given double * @param dist The window coordinates |