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

📄 node.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * $RCSfile: Node.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.6 $ * $Date: 2007/02/09 17:18:11 $ * $State: Exp $ */package javax.media.j3d;import java.util.Hashtable;import java.util.Enumeration;import java.lang.reflect.Constructor;/** * The Node class provides an abstract class for all Group and Leaf Nodes. * It provides a common framework for constructing a Java 3D scene graph, * specifically bounding volumes. * * <p> * For more information, see the * <a href="doc-files/intro.html">Introduction to the Java 3D API</a>. * * <p> * NOTE: Applications should <i>not</i> extend this class directly. */public abstract class Node extends SceneGraphObject {    /**     * Specifies that this Node will be reported in the pick      * SceneGraphPath if a pick occurs.  This capability is only      * specifiable for Group nodes; it is ignored for leaf nodes.     * The default for Group nodes is false.  All interior nodes not      * needed for uniqueness in a SceneGraphPath that don't have      * ENABLE_PICK_REPORTING set to true will not be reported in the      * SceneGraphPath.     * @see SceneGraphPath     */    public static final int    ENABLE_PICK_REPORTING = CapabilityBits.NODE_ENABLE_PICK_REPORTING;    /**     * Specifies that this Node will be reported in the collision      * SceneGraphPath if a collision occurs.  This capability is only     * specifiable for Group nodes; it is ignored for leaf nodes.     * The default for Group nodes is false.  All interior nodes not      * needed for uniqueness in a SceneGraphPath that don't have     * ENABLE_COLLISION_REPORTING set to true will not be reported     * in the SceneGraphPath.     * @see SceneGraphPath     */      public static final int    ENABLE_COLLISION_REPORTING = CapabilityBits.NODE_ENABLE_COLLISION_REPORTING;    /**     * Specifies that this Node allows read access to its bounds     * information.     */    public static final int    ALLOW_BOUNDS_READ = CapabilityBits.NODE_ALLOW_BOUNDS_READ;    /**     * Specifies that this Node allows write access to its bounds     * information.     */    public static final int    ALLOW_BOUNDS_WRITE = CapabilityBits.NODE_ALLOW_BOUNDS_WRITE;    /**     * Specifies that this Node allows reading its pickability state.     */    public static final int    ALLOW_PICKABLE_READ = CapabilityBits.NODE_ALLOW_PICKABLE_READ;    /**     * Specifies that this Node allows write access its pickability state.     */    public static final int    ALLOW_PICKABLE_WRITE = CapabilityBits.NODE_ALLOW_PICKABLE_WRITE;    /**     * Specifies that this Node allows reading its collidability state.     */    public static final int    ALLOW_COLLIDABLE_READ = CapabilityBits.NODE_ALLOW_COLLIDABLE_READ;    /**     * Specifies that this Node allows write access its collidability state.     */    public static final int    ALLOW_COLLIDABLE_WRITE = CapabilityBits.NODE_ALLOW_COLLIDABLE_WRITE;    /**     * Specifies that this Node allows read access to its bounds     * auto compute information.     */    public static final int    ALLOW_AUTO_COMPUTE_BOUNDS_READ = CapabilityBits.NODE_ALLOW_AUTO_COMPUTE_BOUNDS_READ;    /**     * Specifies that this Node allows write access to its bounds     * auto compute information.     */    public static final int    ALLOW_AUTO_COMPUTE_BOUNDS_WRITE = CapabilityBits.NODE_ALLOW_AUTO_COMPUTE_BOUNDS_WRITE;    /**     * Specifies that this Node allows read access to its local     * coordinates to virtual world (Vworld) coordinates transform.     */    public static final int    ALLOW_LOCAL_TO_VWORLD_READ = CapabilityBits.NODE_ALLOW_LOCAL_TO_VWORLD_READ;    /**     * Specifies that this Node allows read access to its parent Group node.     *     * @since Java 3D 1.4     */    public static final int	ALLOW_PARENT_READ = CapabilityBits.NODE_ALLOW_PARENT_READ;    /**     * Specifies that this Node allows read access to its Locale.     *     * @since Java 3D 1.4     */    public static final int        ALLOW_LOCALE_READ = CapabilityBits.NODE_ALLOW_LOCALE_READ;   // Array for setting default read capabilities    private static final int[] readCapabilities = {        ALLOW_BOUNDS_READ,        ALLOW_PICKABLE_READ,        ALLOW_COLLIDABLE_READ,        ALLOW_AUTO_COMPUTE_BOUNDS_READ,        ALLOW_LOCAL_TO_VWORLD_READ,        ALLOW_PARENT_READ,        ALLOW_LOCALE_READ    };    // for checking for cycles    private boolean visited = false;    /**     * Constructs a Node object with default parameters.  The default     * values are as follows:     * <ul>     * pickable : true<br>     * collidable : true<br>     * bounds auto compute : true<br>     * bounds : N/A (automatically computed)<br>     * </ul>     */    public Node() {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);    }    /**     * @return the parent of this node, or null if this node has no parent     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public Node getParent() {	if (isLiveOrCompiled()) {	    if(!this.getCapability(ALLOW_PARENT_READ)) {		throw new CapabilityNotSetException(J3dI18N.getString("Node0"));	    }	}	NodeRetained nr = ((NodeRetained)this.retained).getParent();	return (nr == null ? null :  (Node) nr.getSource());    }    /**     * Sets the geometric bounds of a node.     * @param bounds the bounding object for a node     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void setBounds(Bounds bounds) {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_BOUNDS_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Node1"));	((NodeRetained)this.retained).setBounds(bounds);    }    /**     * Returns the bounding object of a node.     * @return the node's bounding object     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     * @exception SceneGraphCycleException if there is a cycle in the     * scene graph     */    public Bounds getBounds() {		if (isLiveOrCompiled()) {	    if(!this.getCapability(ALLOW_BOUNDS_READ)) {		throw new CapabilityNotSetException(J3dI18N.getString("Node2"));	    }	}	else {	    // this will throw a SceneGraphCycleException if there is	    // a cycle	    checkForCycle();	}			return ((NodeRetained)this.retained).getBounds();    }   /**     * Returns the collidable value; this value determines whether this node     * and it's children, if a group node, can be considered for collision     * purposes; if it is set to false, then neither this node nor any      * children nodes will be traversed for collision purposes; the default     * value is true.   The collidable setting is the way that an      * application can perform collision culling.     *  @return the present collidable value for this node     */     public boolean getCollidable() {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_COLLIDABLE_READ))                throw new CapabilityNotSetException(J3dI18N.getString("Node16"));                       return ((NodeRetained)retained).getCollidable();    }    /**     * Sets the collidable value; determines whether this node and any of its      * children, if a group node, can be considered for collision purposes.     * @param collidable  the new collidable value for this node     */      public void setCollidable( boolean collidable ) {        if (isLiveOrCompiled())            if(!this.getCapability(ALLOW_COLLIDABLE_WRITE))                throw new CapabilityNotSetException(J3dI18N.getString("Node4"));	        ((NodeRetained)retained).setCollidable(collidable);    }    /**     * Turns the automatic calcuation of geometric bounds of a node on/off.     * @param autoCompute indicates if the node's bounding object is     * automatically computed.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void setBoundsAutoCompute(boolean autoCompute) {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_AUTO_COMPUTE_BOUNDS_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Node5"));	((NodeRetained)this.retained).setBoundsAutoCompute(autoCompute);    }    /**     * Gets the value indicating if the automatic calcuation of geometric bounds of a node is on/off.     * @return the node's auto compute flag for the geometric bounding object     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public boolean getBoundsAutoCompute() {	if (isLiveOrCompiled())

⌨️ 快捷键说明

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