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

📄 shape3d.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: Shape3D.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.5 $ * $Date: 2007/02/09 17:18:23 $ * $State: Exp $ */package javax.media.j3d;import java.util.Enumeration;/** * The Shape3D leaf node specifies all geometric objects.  It contains * a list of one or more Geometry component objects and a single * Appearance component object.  The geometry objects define the shape * node's geometric data.  The appearance object specifies that * object's appearance attributes, including color, material, texture, * and so on. * <p> * The list of geometry objects must all be of the same equivalence * class, that is, the same basic type of primitive.  For subclasses * of GeometryArray, all point objects are equivalent, all line * objects are equivalent, and all polygon objects are equivalent. * For other subclasses of Geometry, only objects of the same * subclass are equivalent.  The equivalence classes are as follows: * <ul> * <li>GeometryArray (point): [Indexed]PointArray</li> * <li>GeometryArray (line): [Indexed]{LineArray, LineStripArray}</li> * <li>GeometryArray (polygon): [Indexed]{TriangleArray, TriangleStripArray, * TriangleFanArray, QuadArray}</li> * <li>CompressedGeometry</li> * <li>Raster</li> * <li>Text3D</li> * </ul> * <p> * When Shape3D is used with multiple geometry components, Java 3D may * choose to use individual geometry bounds instead of the shape's * bounds for region of influence operations, such as lighting. * For example, the individual characters of a Text3D shape object * may be rendered with a different light set. */public class Shape3D extends Leaf {    /**     * Id used in the compile optimization to determine     * how to get to the geometry in the case of read     * or picking ..     */    int id;    /**     * Specifies that the node allows read access to its geometry information.     */    public static final int    ALLOW_GEOMETRY_READ = CapabilityBits.SHAPE3D_ALLOW_GEOMETRY_READ;    /**     * Specifies that the node allows write access to its geometry information.     */    public static final int    ALLOW_GEOMETRY_WRITE = CapabilityBits.SHAPE3D_ALLOW_GEOMETRY_WRITE;    /**     * Specifies that the node allows read access to its appearance     * information.     */    public static final int    ALLOW_APPEARANCE_READ = CapabilityBits.SHAPE3D_ALLOW_APPEARANCE_READ;    /**     * Specifies that the node allows write access to its appearance     * information.     */    public static final int    ALLOW_APPEARANCE_WRITE = CapabilityBits.SHAPE3D_ALLOW_APPEARANCE_WRITE;    /**     * Specifies that the node allows reading its collision Bounds     */    public static final int    ALLOW_COLLISION_BOUNDS_READ = CapabilityBits.SHAPE3D_ALLOW_COLLISION_BOUNDS_READ;    /**     * Specifies the node allows writing its collision Bounds     */    public static final int    ALLOW_COLLISION_BOUNDS_WRITE = CapabilityBits.SHAPE3D_ALLOW_COLLISION_BOUNDS_WRITE;    /**     * Specifies that this node allows reading its appearance override     * enable flag.     *     * @since Java 3D 1.2     */    public static final int ALLOW_APPEARANCE_OVERRIDE_READ =	CapabilityBits.SHAPE3D_ALLOW_APPEARANCE_OVERRIDE_READ;    /**     * Specifies that this node allows writing its appearance override     * enable flag.     *     * @since Java 3D 1.2     */    public static final int ALLOW_APPEARANCE_OVERRIDE_WRITE =	CapabilityBits.SHAPE3D_ALLOW_APPEARANCE_OVERRIDE_WRITE;   // Array for setting default read capabilities    private static final int[] readCapabilities = {        ALLOW_GEOMETRY_READ,        ALLOW_APPEARANCE_READ,        ALLOW_COLLISION_BOUNDS_READ,                ALLOW_APPEARANCE_OVERRIDE_READ            };        /**     * Constructs a Shape3D node with default parameters.  The default     * values are as follows:     * <ul>     * appearance : null<br>     * geometry : { null }<br>     * collision bounds : null<br>     * appearance override enable : false<br>     * </ul>     * The list of geometry components is initialized with a null     * geometry component as the single element with an index of 0.     * A null geometry component specifies     * that no geometry is drawn. A null appearance component specifies     * that default values are used for all appearance attributes.     */    public Shape3D() {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);            }    /**     * Constructs and initializes a Shape3D node with the specified     * geometry component and a null appearance component.     * The list of geometry components is initialized with the     * specified geometry component as the single element with an     * index of 0.     * A null appearance component specifies that default values are     * used for all appearance attributes.     * @param geometry the geometry component with which to initialize     * this shape node.     */    public Shape3D(Geometry geometry) {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);        ((Shape3DRetained)retained).setGeometry(geometry, 0);    }    /**     * Constructs and initializes a Shape3D node with the specified     * geometry and appearance components.     * The list of geometry components is initialized with the     * specified geometry component as the single element with an     * index of 0.     * @param geometry the geometry component with which to initialize     * this shape node     * @param appearance the appearance component of the shape node     */    public Shape3D(Geometry geometry, Appearance appearance) {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);        ((Shape3DRetained)retained).setGeometry(geometry, 0);	((Shape3DRetained)retained).setAppearance(appearance);    }    /**     * Creates the retained mode Shape3DRetained object that this     * Shape3D object will point to.     */    void createRetained() {	retained = new Shape3DRetained();	retained.setSource(this);    }    /**      * Sets the collision bounds of a node.      * @param bounds the collision 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 setCollisionBounds(Bounds bounds) {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_COLLISION_BOUNDS_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D0"));		((Shape3DRetained)this.retained).setCollisionBounds(bounds);    }    /**      * Returns the collision bounding object of this node.      * @return the node's collision bounding object      * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph      */    public Bounds getCollisionBounds() {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_COLLISION_BOUNDS_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D1"));	return ((Shape3DRetained)this.retained).getCollisionBounds(id);    }     /**     * Replaces the geometry component at index 0 in this Shape3D node's     * list of geometry components with the specified geometry component.     * If there are existing geometry components in the list (besides     * the one being replaced), the new geometry component must be of     * the same equivalence class (point, line, polygon, CompressedGeometry,     * Raster, Text3D) as the others.     * @param geometry the geometry component to be stored at index 0.     * @exception IllegalArgumentException if the new geometry     * component is not of of the same equivalence class as the     * existing geometry components.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void setGeometry(Geometry geometry) {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_GEOMETRY_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D2"));		((Shape3DRetained)retained).setGeometry(geometry, 0);    }    /**     * Retrieves the geometry component at index 0 from this Shape3D node's     * list of geometry components.     * @return the geometry component at index 0.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public Geometry getGeometry() {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_GEOMETRY_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D3"));		return ((Shape3DRetained)retained).getGeometry(0, id);    }    /**     * Replaces the geometry component at the specified index in this     * Shape3D node's list of geometry components with the specified     * geometry component.     * If there are existing geometry components in the list (besides     * the one being replaced), the new geometry component must be of     * the same equivalence class (point, line, polygon, CompressedGeometry,     * Raster, Text3D) as the others.     * @param geometry the geometry component to be stored at the     * specified index.     * @param index the index of the geometry component to be replaced.     * @exception IllegalArgumentException if the new geometry     * component is not of of the same equivalence class as the     * existing geometry components.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.2     */    public void setGeometry(Geometry geometry, int index) {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_GEOMETRY_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D2"));		((Shape3DRetained)retained).setGeometry(geometry, index);    }    /**     * Retrieves the geometry component at the specified index from     * this Shape3D node's list of geometry components.     * @param index the index of the geometry component to be returned.     * @return the geometry component at the specified index.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.2     */    public Geometry getGeometry(int index) {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_GEOMETRY_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D3"));		return ((Shape3DRetained)retained).getGeometry(index, id);    }    /**     * Inserts the specified geometry component into this Shape3D     * node's list of geometry components at the specified index.     * If there are existing geometry components in the list, the new     * geometry component must be of the same equivalence class     * (point, line, polygon, CompressedGeometry, Raster, Text3D) as     * the others.     * @param geometry the geometry component to be inserted at the     * specified index.     * @param index the index at which the geometry component is inserted.     * @exception IllegalArgumentException if the new geometry     * component is not of of the same equivalence class as the     * existing geometry components.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.2     */    public void insertGeometry(Geometry geometry, int index) {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_GEOMETRY_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D2"));	((Shape3DRetained)retained).insertGeometry(geometry, index);    }    /**     * Removes the geometry component at the specified index from     * this Shape3D node's list of geometry components.     * @param index the index of the geometry component to be removed.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.2     */    public void removeGeometry(int index) {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_GEOMETRY_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D2"));	((Shape3DRetained)retained).removeGeometry(index);    }      /**     * Returns an enumeration of this Shape3D node's list of geometry     * components.     * @return an Enumeration object containing all geometry components in     * this Shape3D node's list of geometry components.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.2     */    public Enumeration getAllGeometries() {	if (isLiveOrCompiled())	    if (!this.getCapability(ALLOW_GEOMETRY_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Shape3D3"));	return ((Shape3DRetained)retained).getAllGeometries(id);    }    /**     * Appends the specified geometry component to this Shape3D     * node's list of geometry components.     * If there are existing geometry components in the list, the new     * geometry component must be of the same equivalence class     * (point, line, polygon, CompressedGeometry, Raster, Text3D) as     * the others.     * @param geometry the geometry component to be appended.     * @exception IllegalArgumentException if the new geometry     * component is not of of the same equivalence class as the     * existing geometry components.     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.2

⌨️ 快捷键说明

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