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

📄 picktool.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public int getMode () {	return mode;    }    /** Sets the PickInfo content flags. The default is PickInfo.NODE.     * @param flags specified as one or more individual bits that are      * bitwise "OR"ed together :      * <ul>     * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br>         * <code>PickInfo.NODE</code> - request for computed intersected Node.<br>     * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br>     * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br>     * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br>     * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br>     * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br>     * </ul>     * @exception IllegalArgumentException if any other bits besides the above are set.     */    public void setFlags (int flags) {	if ((flags & ~ALL_FLAGS) != 0) {	    throw new java.lang.IllegalArgumentException();	}	this.flags = flags;    }    /** Gets the PickInfo content flags.     */    public int getFlags () {	return flags;    }    /**  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 segment	 @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>PickInfo</code> objects which will contain        information about the picked instances. <code>null</code> if nothing was        picked.    */     public PickInfo[] pickAll () {	PickInfo[] pickInfos = null;	if (pickRootBG != null) {	    pickInfos = pickRootBG.pickAll(mode, flags, pickShape);	} else if (pickRootL != null) {	    pickInfos = pickRootL.pickAll(mode, flags, pickShape);	}	return pickInfos;    }    /** Select one of the nodes that intersect the PickShape        @return A <code>PickInfo</code> object which will contain          information about the picked instance. <code>null</code> if nothing 	 was picked.    */     public PickInfo pickAny () {	PickInfo pickInfo = null;	if (pickRootBG != null) {	    pickInfo = pickRootBG.pickAny(mode, flags, pickShape);	} else if (pickRootL != null) {	    pickInfo = pickRootL.pickAny(mode, flags, pickShape);	}	return pickInfo;    }    /** 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>PickInfo</code> objects which will contain 	information 	about the picked instances. <code>null</code> if nothing was picked.    */    public PickInfo[] pickAllSorted () {	PickInfo[] pickInfos = null;	if (pickRootBG != null) {	    pickInfos = pickRootBG.pickAllSorted(mode, flags, pickShape);	} else if (pickRootL != null) {	    pickInfos = pickRootL.pickAllSorted(mode, flags, pickShape);	}	return pickInfos;    }    /** Select the closest node that         intersects the PickShape. See note above to see how "closest" is 	determined.	<p>	@return A <code>PickInfo</code> object which will contain 	information about the picked instance. <code>null</code> if nothing 	was picked.    */    public PickInfo pickClosest () {	// System.out.println("PickTool : pickClosest ...");	PickInfo pickInfo = null;	if (pickRootBG != null) {	    pickInfo = pickRootBG.pickClosest(mode, flags, pickShape);	} else if (pickRootL != null) {	    pickInfo = pickRootL.pickClosest(mode, flags, pickShape);	}	// System.out.println(" -- pickInfo is " + pickInfo);		return pickInfo;    }    /** Get the first node of a certain type up the SceneGraphPath      *@param type the type of node we are interested in     *@return a Node object     *     * @exception NullPointerException if pickInfo does not contain a     * Scenegraphpath or a picked node     */    public Node getNode (PickInfo pickInfo, int type) {       	// System.out.println("pickInfo is " + pickInfo);	if (pickInfo == null) {	    return null;        }		SceneGraphPath sgp = pickInfo.getSceneGraphPath();	Node pickedNode = pickInfo.getNode();	// System.out.println("sgp = " + sgp + " pickedNode = " + pickedNode);	/* 	 *  Do not check for null for pickNode and sgp.	 *  Will throw NPE if pickedNode or sgp isn't set in pickInfo  	 */	        if ((pickedNode instanceof Shape3D) && ((type & TYPE_SHAPE3D) != 0)){	    if (debug) System.out.println("Shape3D found");	    return pickedNode;	} 	else if ((pickedNode instanceof Morph) && ((type & TYPE_MORPH) != 0)){	    if (debug) System.out.println("Morph found"); 	    return pickedNode;	}	else {	    for (int j=sgp.nodeCount()-1; j>=0; j--){		Node pNode = sgp.getNode(j); 		if (debug) System.out.println("looking at node " + pNode);	    		if ((pNode instanceof Primitive) &&		    ((type & TYPE_PRIMITIVE) != 0)){		    if (debug) System.out.println("Primitive found");		    return pNode;		}		else if ((pNode instanceof Link) && ((type & TYPE_LINK) != 0)){		    if (debug) System.out.println("Link found");		    return pNode;		}		else if ((pNode instanceof Switch) && ((type & TYPE_SWITCH) != 0)){		    if (debug) System.out.println("Switch found");		    return pNode;		}		else if ((pNode instanceof TransformGroup) &&			 ((type & TYPE_TRANSFORM_GROUP) != 0)){		    if (debug) System.out.println("xform group found");		    return pNode;		}		else if ((pNode instanceof BranchGroup) &&			 ((type & TYPE_BRANCH_GROUP) != 0)){		    if (debug) System.out.println("Branch group found");		    return pNode;		}		else if ((pNode instanceof Group) && ((type & TYPE_GROUP) != 0)){		    if (debug) System.out.println("Group found");		    return pNode;		}	     	    }	}	return null; // should not be reached    }} // PickTool

⌨️ 快捷键说明

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