[Bprocessor-commit] /gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.273, 1.274 Display.java
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2008-01-02 11:31:07
|
Update of /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5229/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: Made the planes, spanned by coordinatesystems when showplane is true, generate a intersection when hitdetection is made Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Display.java 30 Dec 2007 23:29:10 -0000 1.77 --- Display.java 2 Jan 2008 11:31:09 -0000 1.78 *************** *** 717,728 **** } if (system.showPlane()) { - int dist = 10; gl.glDepthMask(false); ! List<Vertex> corners = new LinkedList<Vertex>(); ! corners.add(system.unTranslate(new Vertex(dist / 2, dist / 2, 0))); ! corners.add(system.unTranslate(new Vertex(dist / 2, -dist / 2, 0))); ! corners.add(system.unTranslate(new Vertex(-dist / 2, -dist / 2, 0))); ! corners.add(system.unTranslate(new Vertex(-dist / 2, dist / 2, 0))); ! apply(misty, 0.3f); drawQuad(corners, false); gl.glDepthMask(true); --- 717,723 ---- } if (system.showPlane()) { gl.glDepthMask(false); ! List<Vertex> corners = system.getXYPlane(camera.distance(system.center()) * 8); ! apply(misty, 0.45f); drawQuad(corners, false); gl.glDepthMask(true); *************** *** 839,842 **** --- 834,846 ---- Collection<Edge> guides = current.guides(grid.size()); selectEdges(guides); + if (current instanceof CoordinateSystem) { + CoordinateSystem cs = (CoordinateSystem)current; + if (cs.showPlane()) { + List<Vertex> vertices = cs.getXYPlane(camera.distance(cs.center()) * 8); + push(current); + drawQuad(vertices, false); + pop(); + } + } } } Index: View.java =================================================================== RCS file: /cvsroot/bprocessor//gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.273 retrieving revision 1.274 diff -C2 -d -r1.273 -r1.274 *** View.java 28 Dec 2007 11:17:05 -0000 1.273 --- View.java 2 Jan 2008 11:31:09 -0000 1.274 *************** *** 1438,1525 **** } if (intersections) { ! Transformation transformation = this.transformation(); ! Vertex near = new Vertex(x, height - y, 0.0); ! Vertex far = new Vertex(x, height - y, 1.0); ! Edge ray = new Edge(near, far); ! ray = transformation.unProject(ray); ! if (vertex != null) { ! Vertex intersection = (Vertex)vertex.getLastInPath(); ! if (vertex.getPathLength() > 1) { ! intersection = (Vertex)vertex.translateOut(intersection); } ! return new Intersection(intersection, Intersection.VERTEX, intersection); ! } else { ! if (glo != null) { ! return glo.intersection(ray); ! } else if (edge != null) { ! Edge current = (Edge)edge.getLastInPath(); ! if (edge.getPathLength() > 1) { ! current = (Edge)edge.translateOut(current); ! } ! if (!current.getStrippled()) { ! Vertex m = current.getFrom().add(current.getTo()); ! m.scaleIt(0.5); ! Vertex projected = transformation.project(m); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { ! return new Intersection(m, Intersection.EDGE_MIDPOINT, current); ! } ! } ! Edge e1 = current; ! Vertex v1 = e1.getTo().minus(e1.getFrom()); ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge e2 = (Edge) iter.next(); ! Vertex v2 = e2.getTo().minus(e2.getFrom()); ! Vertex cross = v1.cross(v2); ! if (!cross.isZero()) { ! Edge intersect = e1.shortestEdge(e2); ! if (intersect != null) { ! if (intersect.getLength() < 0.0000001) { ! Vertex i = intersect.getFrom(); ! Vertex projected = transformation.project(i); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { ! return new Intersection(i, Intersection.EDGE_INTERSECTION, current); ! } ! } ! } ! } } ! { ! if (lastSurface != null) { ! if (!unWantedEntities.contains(lastSurface)) { ! Plane plane = lastSurface.plane(); ! Vertex intersection = plane.intersection(current); ! if (intersection != null) { ! Vertex projected = transformation.project(intersection); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { ! return new Intersection(intersection, ! Intersection.SURFACE_INTERSECTION, lastSurface); ! } } } } } ! { ! Edge intersect = current.shortestEdge(ray); ! Vertex intersection = intersect.getFrom(); ! return new Intersection(intersection, Intersection.EDGE, current); ! } ! } else { ! if (surface != null) { ! Surface theSurface = (Surface)surface.getLastInPath(); ! if (surface.getPathLength() > 1) { ! theSurface = (Surface)(surface.translateOut(theSurface)); ! } ! Plane plane = theSurface.plane(); ! for (Edge current : (Collection<Edge>) edges) { Vertex intersection = plane.intersection(current); if (intersection != null) { --- 1438,1519 ---- } if (intersections) { ! return findIntersected(unWantedEntities, xy, surface, vertex, edge, ! glo, object, edges); ! } else { ! if (object != null) { ! return object; ! } else if (vertex != null) { ! return vertex.getFirstInPath(); ! } else if (edge != null) { ! return edge.getFirstInPath(); ! } else if (surface != null) { ! return surface.getFirstInPath(); ! } else if (glo != null) { ! return glo; ! } ! } ! return null; ! } ! ! private Intersection findIntersected(Collection unWantedEntities, Plane xy, ! SelectionPath surface, SelectionPath vertex, SelectionPath edge, ! GlObject glo, Object object, Collection<Edge> edges) { ! Transformation transformation = this.transformation(); ! Vertex near = new Vertex(x, height - y, 0.0); ! Vertex far = new Vertex(x, height - y, 1.0); ! Edge ray = new Edge(near, far); ! ray = transformation.unProject(ray); ! if (vertex != null) { ! Vertex intersection = (Vertex)vertex.getLastInPath(); ! if (vertex.getPathLength() > 1) { ! intersection = (Vertex)vertex.translateOut(intersection); ! } ! return new Intersection(intersection, Intersection.VERTEX, intersection); ! } else { ! if (glo != null) { ! return glo.intersection(ray); ! } else if (edge != null) { ! Edge current = (Edge)edge.getLastInPath(); ! if (edge.getPathLength() > 1) { ! current = (Edge)edge.translateOut(current); } ! if (!current.getStrippled()) { ! Vertex m = current.getFrom().add(current.getTo()); ! m.scaleIt(0.5); ! Vertex projected = transformation.project(m); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { ! return new Intersection(m, Intersection.EDGE_MIDPOINT, current); } ! } ! Edge e1 = current; ! Vertex v1 = e1.getTo().minus(e1.getFrom()); ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge e2 = (Edge) iter.next(); ! Vertex v2 = e2.getTo().minus(e2.getFrom()); ! Vertex cross = v1.cross(v2); ! if (!cross.isZero()) { ! Edge intersect = e1.shortestEdge(e2); ! if (intersect != null) { ! if (intersect.getLength() < 0.0000001) { ! Vertex i = intersect.getFrom(); ! Vertex projected = transformation.project(i); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { ! return new Intersection(i, Intersection.EDGE_INTERSECTION, current); } } } } ! } ! { ! if (lastSurface != null) { ! if (!unWantedEntities.contains(lastSurface)) { ! Plane plane = lastSurface.plane(); Vertex intersection = plane.intersection(current); if (intersection != null) { *************** *** 1530,1566 **** if (distance < 5) { return new Intersection(intersection, ! Intersection.SURFACE_INTERSECTION, theSurface); } } } ! Vertex intersection = plane.intersection(ray); ! return new Intersection(intersection, Intersection.SURFACE, theSurface); ! } else if (object instanceof ClippingPlane) { ! // find out what is intersected ! Plane p = ((ClippingPlane)object).getPlane(); ! Vertex intersection = p.intersection(ray); ! if (intersection != null) { ! return new Intersection(intersection, Intersection.PLANE_INTERSECTION, p); ! } ! } else { ! Vertex intersection = xy.intersection(ray); if (intersection != null) { ! return new Intersection(intersection, Intersection.PLANE_INTERSECTION, xy); } } } } - } else { - if (object != null) { - return object; - } else if (vertex != null) { - return vertex.getFirstInPath(); - } else if (edge != null) { - return edge.getFirstInPath(); - } else if (surface != null) { - return surface.getFirstInPath(); - } else if (glo != null) { - return glo; - } } return null; --- 1524,1581 ---- if (distance < 5) { return new Intersection(intersection, ! Intersection.SURFACE_INTERSECTION, lastSurface); } } } ! } ! } ! { ! Edge intersect = current.shortestEdge(ray); ! Vertex intersection = intersect.getFrom(); ! return new Intersection(intersection, Intersection.EDGE, current); ! } ! } else { ! if (surface != null) { ! Surface theSurface = (Surface)surface.getLastInPath(); ! if (surface.getPathLength() > 1) { ! theSurface = (Surface)(surface.translateOut(theSurface)); ! } ! Plane plane = theSurface.plane(); ! for (Edge current : (Collection<Edge>) edges) { ! Vertex intersection = plane.intersection(current); if (intersection != null) { ! Vertex projected = transformation.project(intersection); ! double dx = x - projected.getX(); ! double dy = (height - y) - projected.getY(); ! double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { ! return new Intersection(intersection, ! Intersection.SURFACE_INTERSECTION, theSurface); ! } } } + Vertex intersection = plane.intersection(ray); + return new Intersection(intersection, Intersection.SURFACE, theSurface); + } else if (object instanceof ClippingPlane) { + // find out what is intersected + Plane p = ((ClippingPlane)object).getPlane(); + Vertex intersection = p.intersection(ray); + if (intersection != null) { + return new Intersection(intersection, Intersection.PLANE_INTERSECTION, p); + } + } else if (object instanceof CoordinateSystem) { + // find out what is intersected + Plane p = ((CoordinateSystem)object).plane(); + Vertex intersection = p.intersection(ray); + if (intersection != null) { + return new Intersection(intersection, Intersection.PLANE_INTERSECTION, p); + } + } else { + Vertex intersection = xy.intersection(ray); + if (intersection != null) { + return new Intersection(intersection, Intersection.PLANE_INTERSECTION, xy); + } } } } return null; |