⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 picktool.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }    // Methods used to define the pick shape    /** Sets the pick shape to a user-provided PickShape object       *  @param ps The pick shape to pick against.      *  @param startPt The start point to use for distance calculations      */    public void setShape (PickShape ps, Point3d startPt) {	this.pickShape = ps;	this.start = startPt;	userDefineShape = (ps != null);    }    /**  Sets the pick shape to use a user-provided Bounds object       *  @param bounds The bounds to pick against.      *  @param startPt The start point to use for distance calculations      */    public void setShapeBounds (Bounds bounds, Point3d startPt) {	this.pickShape = (PickShape) new PickBounds (bounds);	this.start = startPt;	userDefineShape = true;    }    /** Sets the picking detail mode.  The default is BOUNDS.     * @param mode One of BOUNDS, GEOMETRY, GEOMETRY_INTERSECT_INFO, or      * @exception IllegalArgumentException if mode is not a legal value     */    public void setMode (int mode) {	if ((mode != BOUNDS) && (mode != GEOMETRY) && 	      (mode != GEOMETRY_INTERSECT_INFO)) {	    throw new java.lang.IllegalArgumentException();	}	this.mode = mode;    }    /** Gets the picking detail mode.     */    public int getMode () {	return mode;    }    /**  Sets the pick shape to a PickRay.      *   @param start The start of the ray     *   @param dir The direction of the ray     */    public void setShapeRay (Point3d start, Vector3d dir) {	this.pickShape = (PickShape) new PickRay (start, dir);	this.start = start;	userDefineShape = true;    }    /**  Sets the pick shape to a PickSegment.	 @param start The start of the segmentp	 @param end The end of the segment     */    public void setShapeSegment (Point3d start, Point3d end) {	this.pickShape = (PickShape) new PickSegment (start, end);	this.start = start;	userDefineShape = true;    }    /**  Sets the pick shape to a capped PickCylinder      *   @param start The start of axis of the cylinder     *   @param end The end of the axis of the cylinder     *   @param radius The radius of the cylinder     */    public void setShapeCylinderSegment (Point3d start, Point3d end, 				   double radius) {	this.pickShape = (PickShape) 				new PickCylinderSegment (start, end, radius);	this.start = start;	userDefineShape = true;    }    /**  Sets the pick shape to an infinite PickCylinder.     *   @param start The start of axis of the cylinder     *   @param dir The direction of the axis of the cylinder     *   @param radius The radius of the cylinder     */    public void setShapeCylinderRay (Point3d start, Vector3d dir, 			       double radius) {	this.pickShape = (PickShape) new PickCylinderRay (start, dir, radius);	this.start = start;	userDefineShape = true;    }    /** Sets the pick shape to a capped PickCone      *   @param start The start of axis of the cone     *   @param end The end of the axis of the cone     *   @param angle The angle of the cone     */    public void setShapeConeSegment (Point3d start, Point3d end, 			       double angle) {	this.pickShape = (PickShape) new PickConeSegment (start, end, angle);	this.start = start;	userDefineShape = true;    }    /**  Sets the pick shape to an infinite PickCone.      *   @param start The start of axis of the cone     *   @param dir The direction of the axis of the cone     *   @param angle The angle of the cone     */    public void setShapeConeRay (Point3d start, Vector3d dir, 			   double angle) {	this.pickShape = (PickShape) new PickConeRay (start, dir, angle);	this.start = start;	userDefineShape = true;    }    /** Returns the PickShape for this object. */    public PickShape getPickShape () {	return pickShape;    }    /** Returns the start postion used for distance measurement. */    public Point3d getStartPosition () {	return start;    }    /** Selects all the nodes that intersect the PickShape.      @return An array of <code>PickResult</code> objects which will contain        information about the picked instances. <code>null</code> if nothing was        picked.    */     public PickResult[] pickAll () {	PickResult[] retval = null;	switch (mode) {	  case BOUNDS:	    retval =  pickAll(pickShape);	    break;	  case GEOMETRY:	    retval =  pickGeomAll(pickShape);	    break;	  case GEOMETRY_INTERSECT_INFO:	    retval =  pickGeomAllIntersect(pickShape);	    break;	  default:	    throw new RuntimeException("Invalid pick mode");	}	return retval;    }    /** Select one of the nodes that intersect the PickShape        @return A <code>PickResult</code> object which will contain          information about the picked instance. <code>null</code> if nothing 	 was picked.    */     public PickResult pickAny () {	PickResult retval = null;	switch (mode) {	  case BOUNDS:	    retval =  pickAny(pickShape);	    break;	  case GEOMETRY:	    retval =  pickGeomAny(pickShape);	    break;	  case GEOMETRY_INTERSECT_INFO:	    retval =  pickGeomAnyIntersect(pickShape);	    break;	  default:	    throw new RuntimeException("Invalid pick mode");	}	return retval;    }    /** Select all the nodes that intersect the         PickShape, returned sorted. The "closest" object will be returned first.        See note above to see how "closest" is determined.    	<p>	@return An array of <code>PickResult</code> objects which will contain 	information 	about the picked instances. <code>null</code> if nothing was picked.    */    public PickResult[] pickAllSorted () {	PickResult[] retval = null;	// System.out.println ("PickTool.pickAllSorted.");	switch (mode) {	  case BOUNDS:	      // System.out.println ("PickTool.pickAllSorted : Bounds");	      retval =  pickAllSorted(pickShape);	      break;	  case GEOMETRY:	      // System.out.println ("PickTool.pickAllSorted : Geometry");	      // TODO - BugId 4351050.	      // pickGeomAllSorted is broken for PickCone and PickCylinder :	      // The current Shape3D.intersect() API doesn't return the distance for	      // PickCone and PickCylinder.	      // 2) TODO - BugId 4351579.	      // pickGeomClosest is broken for multi-geometry Shape3D node :	      // The current Shape3D.intersect() API does't return the closest intersected	      // geometry.	      retval =  pickGeomAllSorted(pickShape);	      	      break;	  case GEOMETRY_INTERSECT_INFO:	      // System.out.println ("PickShape " + pickShape);	      // System.out.println ("PickTool.pickAllSorted : GEOMETRY_INTERSECT_INFO");	      retval =  pickGeomAllSortedIntersect(pickShape);	      break;	default:	    throw new RuntimeException("Invalid pick mode");	}	return retval;    }    /** Select the closest node that         intersects the PickShape. See note above to see how "closest" is 	determined.	<p>	@return A <code>PickResult</code> object which will contain 	information about the picked instance. <code>null</code> if nothing 	was picked.    */    public PickResult pickClosest () {	PickResult retval = null;	switch (mode) {	  case BOUNDS:	    retval =  pickClosest(pickShape);	    break;	  case GEOMETRY:	      // System.out.println("pickCloset -- Geometry based picking");	      // 1) TODO - BugId 4351050.	      // pickGeomClosest is broken for PickCone and PickCylinder :	      // The current Shape3D.intersect() API doesn't return the distance for	      // PickCone and PickCylinder.	      // 2) TODO - BugId 4351579.	      // pickGeomClosest is broken for multi-geometry Shape3D node :	      // The current Shape3D.intersect() API does't return the closest intersected	      // geometry.	      retval =  pickGeomClosest(pickShape);	      	      break;	case GEOMETRY_INTERSECT_INFO:	    // System.out.println ("PickShape " + pickShape);	    // System.out.println ("PickTool.pickClosest : GEOMETRY_INTERSECT_INFO");	    retval =  pickGeomClosestIntersect(pickShape);	    break;	  default:	    throw new RuntimeException("Invalid pick mode");	}	return retval;    }    private PickResult[] pickAll (PickShape pickShape) {	PickResult[] pr = null;	SceneGraphPath[] sgp = null;	if (pickRootBG != null) {	    sgp = pickRootBG.pickAll (pickShape);	} else if (pickRootL != null) {	    sgp = pickRootL.pickAll (pickShape);	}	if (sgp == null) return null; // no match	// Create PickResult array	pr = new PickResult [sgp.length];	for (int i=0;i<sgp.length;i++) {	    pr[i] = new PickResult (sgp[i], pickShape);	}	return pr;    }    private PickResult[] pickAllSorted (PickShape pickShape) {	PickResult[] pr = null;	SceneGraphPath[] sgp = null;	if (pickRootBG != null) {	    sgp = pickRootBG.pickAllSorted (pickShape);	} else if (pickRootL != null) {	    sgp = pickRootL.pickAllSorted (pickShape);	}	if (sgp == null) return null; // no match	// Create PickResult array	pr = new PickResult [sgp.length];	for (int i=0;i<sgp.length;i++) {	    pr[i] = new PickResult (sgp[i], pickShape);	}	return pr;    }    private PickResult pickAny (PickShape pickShape) {	PickResult pr = null;	SceneGraphPath sgp = null;	if (pickRootBG != null) {	    sgp = pickRootBG.pickAny (pickShape);	} else if (pickRootL != null) {	    sgp = pickRootL.pickAny (pickShape);	}	if (sgp == null) return null; // no match	// Create PickResult object	pr = new PickResult (sgp, pickShape);	return pr;    }    private PickResult pickClosest (PickShape pickShape) {	PickResult pr = null;	SceneGraphPath sgp = null;	if (pickRootBG != null) {	    sgp = pickRootBG.pickClosest (pickShape);	} else if (pickRootL != null) {	    sgp = pickRootL.pickClosest (pickShape);	}	if (sgp == null) return null; // no match	// Create PickResult object	pr = new PickResult (sgp, pickShape);	return pr;    }    // ================================================================    // GEOMETRY METHODS    // ================================================================    private PickResult[] pickGeomAll (PickShape pickShape) {	SceneGraphPath[] sgp = null;	Node obj[] = null;	int i, cnt=0;	// First pass	if (pickRootBG != null) {	    sgp = pickRootBG.pickAll(pickShape);	} else if (pickRootL != null) {	    sgp = pickRootL.pickAll(pickShape);	}	if (sgp == null) return null; // no match	// Second pass, check to see if geometries intersected	boolean found[] = new boolean [sgp.length];	obj = new Node [sgp.length];	PickResult[] pr = new PickResult[sgp.length];	for (i=0; i<sgp.length; i++) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -