[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java,1.84,1.85
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-05-03 14:12:34
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18980a/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Surface/Edge intersections implemented Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** View.java 3 May 2006 11:01:27 -0000 1.84 --- View.java 3 May 2006 14:12:25 -0000 1.85 *************** *** 153,156 **** --- 153,159 ---- /** The size of the viewing area */ protected static double gridSize = 25.0; + + /** The last touched surface */ + protected static Surface lastSurface; /** */ *************** *** 361,364 **** --- 364,369 ---- } + + /** * The constructor *************** *** 393,396 **** --- 398,409 ---- /** + * + * @return Surface + */ + public static Surface getLastSurface() { + return lastSurface; + } + + /** * The initialization part of the 3D view * @param gld The GLDrawable object *************** *** 1747,1750 **** --- 1760,1784 ---- } + // Set the last surface pointed at: + // If pointing at something different than a surface then dont + // change the lastSurface pointed at. + // This makes it possible to find the intersection between an + // edge and a surface even when the edge belongs to some other + // surface. + // Surface may be null in which + // case the lastSurface pointed at will be cleared (happens when pointing + // into empty space. + if (object == null && vertex == null && edge == null) { + lastSurface = surface; + } + + // If lastsurface is null, then use the surface currently under + // any other object pointed at. Surface may be null in which + // case the lastSurface pointed at will be cleared (happens when pointing + // into empty space. + if (lastSurface == null) { + lastSurface = surface; + } + if (intersections) { Transformation transformation = this.transformation(); *************** *** 1776,1780 **** double dy = (height - y) - projected.getY(); double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 6) { return new Intersection(i, Intersection.EDGE_INTERSECTION, edge); } --- 1810,1814 ---- double dy = (height - y) - projected.getY(); double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { return new Intersection(i, Intersection.EDGE_INTERSECTION, edge); } *************** *** 1791,1795 **** double dy = (height - y) - projected.getY(); double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 6) { return new Intersection(m, Intersection.EDGE_MIDPOINT, edge); } --- 1825,1829 ---- double dy = (height - y) - projected.getY(); double distance = Math.sqrt(dx * dx + dy * dy); ! if (distance < 5) { return new Intersection(m, Intersection.EDGE_MIDPOINT, edge); } *************** *** 1797,1800 **** --- 1831,1851 ---- { + if (lastSurface != null) { + Plane plane = lastSurface.plane(); + Vertex intersection = plane.intersection(edge); + 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 = edge.intersection(ray); Vertex intersection = intersect.getFrom(); |