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

📄 morph.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: Morph.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:10 $ * $State: Exp $ */package javax.media.j3d;import java.util.Hashtable;import javax.vecmath.*;/** * The Morph leaf node permits an application to morph between * multiple GeometryArrays.  The Morph node contains a single * Appearance node, an array of GeometryArray objects, and an array of * corresponding weights. The Morph node combines these GeometryArrays * into an aggregate shape based on each GeometryArray's corresponding * weight. Typically, Behavior nodes will modify the weights to * achieve various morphing effects. * * <p> * The following restrictions apply to each GeometryArray object * in the specified array of GeometryArray objects: * * <ul> * <li> * All <i>N</i> geometry arrays must be of the * same type (that is, the same subclass of GeometryArray). * </li> * * <p> * <li> * The vertexFormat, texCoordSetCount, and validVertexCount must be * the same for all <i>N</i> geometry arrays. * </li> * * <p> * <li> * The texCoordSetMap array must be identical (element-by-element) for * all <i>N</i> geometry arrays. * </li> * * <p> * <li> * For IndexedGeometryArray objects, the validIndexCount must be the same * for all <i>N</i> geometry arrays. * </li> * * <p> * <li> * For GeometryStripArray objects, the stripVertexCounts array must * be identical (element-by-element) for all <i>N</i> geometry arrays. * </li> * * <p> * <li> * For IndexedGeometryStripArray objects, the stripIndexCounts array must * be identical (element-by-element) for all <i>N</i> geometry arrays. * </li> * * <p> * <li> * For indexed geometry by-reference, the array lengths of each * enabled vertex component (coord, color, normal, texcoord) * must be the same for all <i>N</i> geometry arrays. * </li> * </ul> * * <p> * For IndexedGeometryArray objects, the vertex arrays are morphed * <i>before</i> the indexes are applied.  Only the indexes in the * first geometry array (geometry[0]) are used when rendering the * geometry. * * @deprecated As of Java 3D version 1.4. */public class Morph extends Leaf {    /**     * Specifies that the node allows read access to its geometry information.     */    public static final int    ALLOW_GEOMETRY_ARRAY_READ = CapabilityBits.MORPH_ALLOW_GEOMETRY_ARRAY_READ;    /**     * Specifies that the node allows write access to its geometry information.     */    public static final int    ALLOW_GEOMETRY_ARRAY_WRITE = CapabilityBits.MORPH_ALLOW_GEOMETRY_ARRAY_WRITE;    /**     * Specifies that the node allows read access to its appearance information.     */    public static final int    ALLOW_APPEARANCE_READ = CapabilityBits.MORPH_ALLOW_APPEARANCE_READ;    /**     * Specifies that the node allows write access to its appearance information.     */    public static final int    ALLOW_APPEARANCE_WRITE = CapabilityBits.MORPH_ALLOW_APPEARANCE_WRITE;    /**     * Specifies that the node allows read access to its morph     * weight vector.     */    public static final int    ALLOW_WEIGHTS_READ = CapabilityBits.MORPH_ALLOW_WEIGHTS_READ;    /**     * Specifies that the node allows write access to its morph     * weight vector.     */    public static final int    ALLOW_WEIGHTS_WRITE = CapabilityBits.MORPH_ALLOW_WEIGHTS_WRITE;    /**     * Specifies that the node allows reading its collision Bounds.     */    public static final int    ALLOW_COLLISION_BOUNDS_READ = CapabilityBits.MORPH_ALLOW_COLLISION_BOUNDS_READ;    /**     * Specifies the node allows writing its collision Bounds.     */    public static final int    ALLOW_COLLISION_BOUNDS_WRITE = CapabilityBits.MORPH_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.MORPH_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.MORPH_ALLOW_APPEARANCE_OVERRIDE_WRITE;   // Array for setting default read capabilities    private static final int[] readCapabilities = {        ALLOW_GEOMETRY_ARRAY_READ,        ALLOW_APPEARANCE_READ,        ALLOW_WEIGHTS_READ,                ALLOW_COLLISION_BOUNDS_READ,        ALLOW_APPEARANCE_OVERRIDE_READ    };                    // non public default constructor    Morph() {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);            }    /**     * Constructs and initializes a Morph node with the specified array     * of GeometryArray objects.  Default values are used for all other     * parameters as follows:     * <ul>     * appearance : null<br>     * weights : [1, 0, 0, 0, ...]<br>     * collision bounds : null<br>     * appearance override enable : false<br>     * </ul><P>     * A null appearance object specifies that default values are used     * for all appearance attributes.     *     * @param geometryArrays the geometry components of the morph;     * a null or zero-length array of GeometryArray objects is     * permitted, and specifies that no geometry is drawn.  In this case,     * the array of weights is initialized to a zero-length array.     *     * @exception IllegalArgumentException if any of the specified     * geometry array objects differ from each other in any of the     * following ways:     * <ul>     * <li>Type of geometry array object (subclass of GeometryArray)</li>     * <li>vertexFormat</li>     * <li>texCoordSetCount</li>     * <li>texCoordSetMap</li>     * <li>validVertexCount</li>     * <li>validIndexCount, for IndexedGeometryArray objects</li>     * <li>stripVertexCounts array, for GeometryStripArray objects</li>     * <li>stripIndexCounts array, for IndexedGeometryStripArray objects</li>     * <li>the array lengths of each enabled vertex component     * (coord, color, normal, texcoord),     * for indexed geometry by-reference</li>     * </ul>     *     * @exception UnsupportedOperationException if the specified     * geometry arrays contain vertex attributes (that is, if their     * vertexFormat includes the <code>VERTEX_ATTRIBUTES</code> flag).     */    public Morph(GeometryArray geometryArrays[]) {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);        	((MorphRetained)retained).setGeometryArrays(geometryArrays);    }    /**     * Constructs and initializes a Morph node with the specified array     * of GeometryArray objects and the specified appearance object.     *     * @param geometryArrays the geometry components of the Morph node     * a null or zero-length array of GeometryArray objects is     * permitted, and specifies that no geometry is drawn.  In this case,     * the array of weights is initialized to a zero-length array.     * @param appearance the appearance component of the Morph node     *     * @exception IllegalArgumentException if any of the specified     * geometry array objects differ from each other in any of the     * following ways:     * <ul>     * <li>Type of geometry array object (subclass of GeometryArray)</li>     * <li>vertexFormat</li>     * <li>texCoordSetCount</li>     * <li>texCoordSetMap</li>     * <li>validVertexCount</li>     * <li>validIndexCount, for IndexedGeometryArray objects</li>     * <li>stripVertexCounts array, for GeometryStripArray objects</li>     * <li>stripIndexCounts array, for IndexedGeometryStripArray objects</li>     * <li>the array lengths of each enabled vertex component     * (coord, color, normal, texcoord),     * for indexed geometry by-reference</li>     * </ul>     *     * @exception UnsupportedOperationException if the specified     * geometry arrays contain vertex attributes (that is, if their     * vertexFormat includes the <code>VERTEX_ATTRIBUTES</code> flag).     */    public Morph(GeometryArray geometryArrays[], Appearance appearance) {        // set default read capabilities        setDefaultReadCapabilities(readCapabilities);        ((MorphRetained)retained).setGeometryArrays(geometryArrays);	((MorphRetained)this.retained).setAppearance(appearance);    }    /**     * Creates the retained mode MorphRetained object that this     * Morph object will point to.     */    void createRetained() {	retained = new MorphRetained();	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("Morph0"));		((MorphRetained)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("Morph1"));		return ((MorphRetained)this.retained).getCollisionBounds();    }     /**     * Sets the geometryArrays component of the Morph node.     *     * If the current array of GeometryArrays in this Morph object is     * non-null with a length greater than 0, the specified array of     * GeometryArrays must be the same length as the current array.     * If the current array of GeometryArrays in this Morph object is     * null or has a length of 0, and the specified array of     * GeometryArrays is non-null with a length greater than 0, the     * length of the incoming array defines the number of the geometry     * objects that will be morphed.  In this case, the weights array     * is allocated to be of the same length as the geometry array;     * the first element (weights[0]) is initialized to 1.0 and all of     * the other weights are initialized to 0.0.     *     * @param geometryArrays the new geometryArrays component     * for the Morph node.     *     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     * <p>     *     * @exception IllegalArgumentException if the length of the     * specified array of geometry arrays is not equal to the length     * of this Morph node's current array of geometry arrays (and the     * current array's length is non-zero), or if any of the specified     * geometry array objects differ from each other in any of the     * following ways:     * <ul>     * <li>Type of geometry array object (subclass of GeometryArray)</li>     * <li>vertexFormat</li>     * <li>texCoordSetCount</li>     * <li>texCoordSetMap</li>     * <li>validVertexCount</li>     * <li>validIndexCount, for IndexedGeometryArray objects</li>     * <li>stripVertexCounts array, for GeometryStripArray objects</li>     * <li>stripIndexCounts array, for IndexedGeometryStripArray objects</li>     * <li>the array lengths of each enabled vertex component     * (coord, color, normal, texcoord),     * for indexed geometry by-reference</li>     * </ul>     *     * @exception UnsupportedOperationException if the specified     * geometry arrays contain vertex attributes (that is, if their     * vertexFormat includes the <code>VERTEX_ATTRIBUTES</code> flag).     */    public void setGeometryArrays(GeometryArray geometryArrays[]) {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_GEOMETRY_ARRAY_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Morph2"));	

⌨️ 快捷键说明

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