summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-11-03 22:46:51 +0000
committerjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-11-03 22:46:51 +0000
commitc6805f980728cf8ebe1a329dc0e584c741accc8d (patch)
tree2b5989ad02fb6bd3d418a8adadd1658e3845b894
parent514fe3f6240041c178ff9262d0b91e838fad1d3b (diff)
1) Modified IntersectTest to use the new pickfast utils.
2) Cleanup PickTest
-rw-r--r--src/PickTest/IntersectInfoBehavior.java29
-rw-r--r--src/PickTest/IntersectTest.java8
-rw-r--r--src/PickTest/PickTest.java6
3 files changed, 13 insertions, 30 deletions
diff --git a/src/PickTest/IntersectInfoBehavior.java b/src/PickTest/IntersectInfoBehavior.java
index 1ca39c6..d583cc2 100644
--- a/src/PickTest/IntersectInfoBehavior.java
+++ b/src/PickTest/IntersectInfoBehavior.java
@@ -47,7 +47,7 @@ import java.awt.event.*;
import java.util.*;
import javax.media.j3d.*;
import javax.vecmath.*;
-import com.sun.j3d.utils.picking.*;
+import com.sun.j3d.utils.pickfast.*;
import com.sun.j3d.utils.geometry.*;
/**
@@ -63,7 +63,7 @@ public class IntersectInfoBehavior extends Behavior {
float size;
PickCanvas pickCanvas;
- PickResult[] pickResult;
+ PickInfo[] pickInfoArr;
Appearance oldlook, redlookwf, redlook, greenlook, bluelook;
Node oldNode = null;
GeometryArray oldGeom = null;
@@ -76,7 +76,8 @@ public class IntersectInfoBehavior extends Behavior {
float size) {
pickCanvas = new PickCanvas(canvas3D, branchGroup);
pickCanvas.setTolerance(5.0f);
- pickCanvas.setMode(PickCanvas.GEOMETRY_INTERSECT_INFO);
+ pickCanvas.setMode(PickInfo.PICK_GEOMETRY);
+ pickCanvas.setFlags(PickInfo.LOCAL_TO_VWORLD | PickInfo.CLOSEST_GEOM_INFO);
this.size = size;
// Create an Appearance.
redlook = new Appearance();
@@ -146,15 +147,13 @@ public class IntersectInfoBehavior extends Behavior {
int y = ((MouseEvent)event[i]).getY();
pickCanvas.setShapeLocation(x, y);
- Point3d eyePos = pickCanvas.getStartPosition ();
- pickResult = pickCanvas.pickAllSorted();
+ pickInfoArr = pickCanvas.pickAllSorted();
// Use this to do picking benchmarks
/*
long start = System.currentTimeMillis();
- for (int l=0;l<3;l++) {
+ for (int l=0;l<2;l++) {
if (l == 0) System.out.print ("BOUNDS: ");
if (l == 1) System.out.print ("GEOMETRY: ");
- if (l == 2) System.out.print ("GEOMETRY_INTERSECT_INFO: ");
for (int k=0;k<1000;k++) {
if (l == 0) {
@@ -165,23 +164,21 @@ public class IntersectInfoBehavior extends Behavior {
pickCanvas.setMode(PickTool.GEOMETRY);
pickResult = pickCanvas.pickAllSorted();
}
- if (l == 2) {
- pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
- pickResult = pickCanvas.pickAllSorted();
- }
}
long delta = System.currentTimeMillis() - start;
System.out.println ("\t"+delta+" ms / 1000 picks");
}
*/
- if (pickResult != null) {
+ if (pickInfoArr != null) {
// Get closest intersection results
- PickIntersection pi =
- pickResult[0].getClosestIntersection(eyePos);
+ Transform3D l2vw = pickInfoArr[0].getLocalToVWorld();
+ PickInfo.IntersectionInfo[] iInfoArr = pickInfoArr[0].getIntersectionInfos();
+ PickIntersection pi = new PickIntersection(l2vw, iInfoArr[0]);
+
+ // Safe to assume the return geometry is of GeometryArray type.
+ GeometryArray curGeomArray = (GeometryArray) iInfoArr[0].getGeometry();
- GeometryArray curGeomArray = pi.getGeometryArray();
-
// Position sphere at intersection point
Vector3d v = new Vector3d();
Point3d intPt = pi.getPointCoordinatesVW();
diff --git a/src/PickTest/IntersectTest.java b/src/PickTest/IntersectTest.java
index f4e70cb..ef27f7a 100644
--- a/src/PickTest/IntersectTest.java
+++ b/src/PickTest/IntersectTest.java
@@ -51,7 +51,6 @@ import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.keyboard.*;
-import com.sun.j3d.utils.picking.PickTool;
public class IntersectTest extends Applet {
@@ -109,9 +108,6 @@ public class IntersectTest extends Applet {
Shape3D shape = new Shape3D(geom);
- // use the utility method to set the capabilities
- PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
-
objTrans.addChild(shape);
}
}
@@ -143,8 +139,6 @@ public class IntersectTest extends Applet {
Shape3D shape = new Shape3D();
shape.setGeometry (la);
- // use the utility method to set the capabilities
- PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
objTrans.addChild(shape);
}
@@ -169,8 +163,6 @@ public class IntersectTest extends Applet {
Shape3D shape = new Shape3D();
shape.setGeometry (pa);
- // use the utility method to set the capabilities
- PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
objTrans.addChild(shape);
}
diff --git a/src/PickTest/PickTest.java b/src/PickTest/PickTest.java
index 88feef7..802b1d4 100644
--- a/src/PickTest/PickTest.java
+++ b/src/PickTest/PickTest.java
@@ -243,7 +243,6 @@ public class PickTest extends Applet implements ActionListener {
morph = new Morph((GeometryArray[]) geomMorph, appearance);
morph.setCapability(Morph.ALLOW_WEIGHTS_READ);
morph.setCapability(Morph.ALLOW_WEIGHTS_WRITE);
- //PickTool.setCapabilities(morph, PickTool.INTERSECT_FULL);
spinTg.addChild(morph);
} else {
// Geometry picking require this to be set.
@@ -263,7 +262,6 @@ public class PickTest extends Applet implements ActionListener {
shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
shape.setCapability(Shape3D.ENABLE_PICK_REPORTING);
- //PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
spinTg.addChild(shape);
}
@@ -294,7 +292,6 @@ public class PickTest extends Applet implements ActionListener {
String pickModeString = new String("Pick Mode");
String boundsString = new String("BOUNDS");
String geometryString = new String("GEOMETRY");
- //String geometryIntersectString = new String("GEOMETRY_INTERSECT_INFO");
String toleranceString = new String("Pick Tolerance");
String tolerance0String = new String("0");
String tolerance2String = new String("2");
@@ -327,7 +324,6 @@ public class PickTest extends Applet implements ActionListener {
bg = new ButtonGroup();
addRadioButton(panel, bg, pickModeString, boundsString, true);
addRadioButton(panel, bg, pickModeString, geometryString, false);
- //addRadioButton(panel, bg, pickModeString, geometryIntersectString, false);
panel.add(new JLabel(toleranceString));
bg = new ButtonGroup();
@@ -352,8 +348,6 @@ public class PickTest extends Applet implements ActionListener {
setPickMode(PickInfo.PICK_BOUNDS);
} else if (value == geometryString) {
setPickMode(PickInfo.PICK_GEOMETRY);
- //} else if (value == geometryIntersectString) {
- //setPickMode(PickInfo.PICK_GEOMETRY);
} else {
System.out.println("Unknown pick mode: " + value);
}