Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31240/src/net/sourceforge/bprocessor/gl/model
Modified Files:
ClippingPlane.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: ClippingPlane.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model/ClippingPlane.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ClippingPlane.java 1 Nov 2005 07:31:19 -0000 1.1
--- ClippingPlane.java 6 Nov 2005 16:33:44 -0000 1.2
***************
*** 11,14 ****
--- 11,15 ----
import java.util.ArrayList;
+ import net.sourceforge.bprocessor.model.CoordinateSystem;
import net.sourceforge.bprocessor.model.Plane;
import net.sourceforge.bprocessor.model.Vertex;
***************
*** 29,32 ****
--- 30,37 ----
/** The placement of the clippingplane */
private Plane plane;
+
+ /** The coordinate sytem of the clipping plane */
+
+ private CoordinateSystem system;
/** The corners */
***************
*** 35,42 ****
/**
* The constructor
! * @param plane The plane the clippingplane is represented by
*/
! public ClippingPlane(Plane plane) {
! this.plane = plane;
findCorners();
}
--- 40,48 ----
/**
* The constructor
! * @param system The coordinatesystem the clippingplane is represented by
*/
! public ClippingPlane(CoordinateSystem system) {
! this.system = system;
! this.plane = system.plane();
findCorners();
}
***************
*** 87,92 ****
/**
* Find the 4 corners among intersections
! */
public void findCorners() {
log.info(plane);
Collection c = findIntersections();
--- 93,140 ----
/**
* Find the 4 corners among intersections
! */
!
public void findCorners() {
+ Collection c = findIntersections();
+ Iterator it = c.iterator();
+ double minX = Integer.MAX_VALUE;
+ double minY = Integer.MAX_VALUE;
+ double maxX = Integer.MIN_VALUE;
+ double maxY = Integer.MIN_VALUE;
+ while (it.hasNext()) {
+ Vertex v = (Vertex)it.next();
+ v = system.translate(v);
+ if (v.getX() < minX) {
+ minX = v.getX();
+ }
+ if (v.getX() > maxX) {
+ maxX = v.getX();
+ }
+ if (v.getY() < minY) {
+ minY = v.getY();
+ }
+ if (v.getY() > maxY) {
+ maxY = v.getY();
+ }
+ }
+ Vertex v1 = new Vertex("", minX - 1, minY - 1, 0.0);
+ Vertex v2 = new Vertex("", minX - 1, maxY + 1, 0.0);
+ Vertex v3 = new Vertex("", maxX + 1, maxY + 1, 0.0);
+ Vertex v4 = new Vertex("", maxX + 1, minY - 1, 0.0);
+ v1 = system.unTranslate(v1);
+ v2 = system.unTranslate(v2);
+ v3 = system.unTranslate(v3);
+ v4 = system.unTranslate(v4);
+ corners = new ArrayList();
+ corners.add(v1);
+ corners.add(v2);
+ corners.add(v3);
+ corners.add(v4);
+ }
+
+ /**
+ * Find a lot of corners among intersections
+ */
+ public void findManyCorners() {
log.info(plane);
Collection c = findIntersections();
|