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

📄 picktool.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: PickTool.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistribution of source code must retain the above copyright *   notice, this list of conditions and the following disclaimer. * * - Redistribution in binary form must reproduce the above copyright *   notice, this list of conditions and the following disclaimer in *   the documentation and/or other materials provided with the *   distribution. * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * This software is provided "AS IS," without a warranty of any * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed, licensed or * intended for use in the design, construction, operation or * maintenance of any nuclear facility. * * $Revision: 1.5 $ * $Date: 2007/02/09 17:20:24 $ * $State: Exp $ */package com.sun.j3d.utils.pickfast;import com.sun.j3d.utils.geometry.Primitive;import javax.vecmath.*;import javax.media.j3d.*;import com.sun.j3d.internal.*;/**  * The base class for optimized picking operations. * The picking methods will return a PickInfo object for each object picked,  * which can then be queried to  * obtain more detailed information about the specific objects that were * picked.  * <p> * The pick mode specifies the detail level of picking before the PickInfo * is returned: * <p> * <UL> * <LI> PickInfo.PICK_BOUNDS - Pick using the only bounds of the pickable nodes.  * </LI> * <LI> PickInfo.PICK_GEOMETRY will pick using the geometry of the pickable nodes. * Geometry nodes in the scene must have the ALLOW_INTERSECT capability set for * this mode.</LI> * <p> * The pick flags specifies the content of the PickInfo(s) returned by the  * pick methods. This is specified as one or more individual bits that are  * bitwise "OR"ed together to describe the PickInfo data. The flags include : * <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> * </UL> * <p> * When using pickAllSorted or pickClosest methods, the picks  * will be sorted by the distance from the start point of the pick shape to  * the intersection point. * * @see Locale#pickClosest(int,int,javax.media.j3d.PickShape) */public class PickTool {    /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>Shape3D</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_SHAPE3D = 0x1;    /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>Morph</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_MORPH = 0x2;    /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>Primitive</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_PRIMITIVE = 0x4;    /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>Link</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_LINK = 0x8;    /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>Group</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_GROUP = 0x10;      /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>TransformGroup</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_TRANSFORM_GROUP = 0x20;     /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>BranchGroup</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_BRANCH_GROUP = 0x40;    /**     * Flag to pass to      * <CODE>getNode(int)</CODE>     * to return a     * <code>Switch</code> node from      * the <code>SceneGraphPath</code>.      */    public static final int TYPE_SWITCH = 0x80;    private static final int ALL_FLAGS =         PickInfo.SCENEGRAPHPATH			|        PickInfo.NODE				|        PickInfo.LOCAL_TO_VWORLD		|        PickInfo.CLOSEST_INTERSECTION_POINT	|        PickInfo.CLOSEST_DISTANCE		|        PickInfo.CLOSEST_GEOM_INFO		|        PickInfo.ALL_GEOM_INFO;    private final boolean debug = false;    protected boolean userDefineShape = false;    PickShape pickShape;    /** Used to store the BranchGroup used for picking */    BranchGroup pickRootBG = null;    /** Used to store the Locale used for picking */    Locale pickRootL = null;    /** Used to store a reference point used in determining how "close" points        are.     */    Point3d start = null;    int mode = PickInfo.PICK_BOUNDS;    int flags = PickInfo.NODE;    /* ============================ METHODS ============================ */    /**      * Constructor with BranchGroup to be picked.     */    public PickTool (BranchGroup b) {	pickRootBG = b;    }    /**      * Constructor with the Locale to be picked.     */    public PickTool (Locale l) {	pickRootL = l;    }    /** Returns the BranchGroup to be picked if the tool was initialized	with a BranchGroup, null otherwise.       */    public BranchGroup getBranchGroup() {        return pickRootBG;    }    /**      * Returns the Locale to be picked if the tool was initialized with     * a Locale, null otherwise.     */    public Locale getLocale () {	return pickRootL;    }    // 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 PickInfo.PICK_BOUNDS.     * @param mode One of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY.      * @exception IllegalArgumentException if mode is not a legal value     */    public void setMode (int mode) {	if ((mode != PickInfo.PICK_BOUNDS) && (mode != PickInfo.PICK_GEOMETRY)) {	    throw new java.lang.IllegalArgumentException();	}	this.mode = mode;    }    /** Gets the picking detail mode.     */

⌨️ 快捷键说明

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