📄 morph.java
字号:
((MorphRetained)this.retained).setGeometryArrays(geometryArrays); } /** * Retrieves the geometryArray component of this Morph node. * @param index the index of GeometryArray to be returned * @return the geometryArray component of this Morph node * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public GeometryArray getGeometryArray(int index) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_GEOMETRY_ARRAY_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Morph3")); return ((MorphRetained)this.retained).getGeometryArray(index); } /** * Sets the appearance component of this Morph node. A null * appearance component specifies that default values are used for all * appearance attributes. * @param appearance the new appearance component for this Morph node * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setAppearance(Appearance appearance) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_APPEARANCE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Morph4")); ((MorphRetained)this.retained).setAppearance(appearance); } /** * Retrieves the appearance component of this morph node. * @return the appearance component of this morph node * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public Appearance getAppearance() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_APPEARANCE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Morph5")); return ((MorphRetained)this.retained).getAppearance(); } /** * Checks whether the geometry in this morph node intersects with * the specified pickShape. * * @param path the SceneGraphPath to this morph node * @param pickShape the PickShape to be intersected * * @return true if the pick shape intersects this node; false * otherwise. * * @exception IllegalArgumentException if pickShape is a PickPoint. * Java 3D doesn't have spatial information of the surface. * Use PickBounds with BoundingSphere and a small radius, instead. * * @exception CapabilityNotSetException if the Geometry.ALLOW_INTERSECT * capability bit is not set in all of the Geometry objects * referred to by this morph node. */ public boolean intersect(SceneGraphPath path, PickShape pickShape) { return intersect(path, pickShape, null); } /** * Checks whether the geometry in this morph node intersects with * the specified pickRay. * * @param path the SceneGraphPath to this morph node * @param pickRay the PickRay to be intersected * @param dist the closest distance of the intersection * * @return true if the pick shape intersects this node; false * otherwise. If true, dist contains the closest distance of * intersection. * * @exception CapabilityNotSetException if the Geometry.ALLOW_INTERSECT * capability bit is not set in all of the Geometry objects * referred to by this morph node. */ public boolean intersect(SceneGraphPath path, PickRay pickRay, double[] dist) { if (isLiveOrCompiled()) { checkForAllowIntersect(); } return ((MorphRetained)this.retained).intersect(path, pickRay, dist); } /** * Checks whether the geometry in this morph node intersects with * the specified pickShape. * * @param path the SceneGraphPath to this morph node * @param pickShape the PickShape to be intersected * @param dist the closest distance of the intersection * * @return true if the pick shape intersects this node; false * otherwise. If true, dist contains the closest distance of * intersection. * * @exception IllegalArgumentException if pickShape is a PickPoint. * Java 3D doesn't have spatial information of the surface. * Use PickBounds with BoundingSphere and a small radius, instead. * * @exception CapabilityNotSetException if the Geometry.ALLOW_INTERSECT * capability bit is not set in all of the Geometry objects * referred to by this morph node. * * @since Java 3D 1.3 */ public boolean intersect(SceneGraphPath path, PickShape pickShape, double[] dist) { if (isLiveOrCompiled()) { checkForAllowIntersect(); } if (pickShape instanceof PickPoint) { throw new IllegalArgumentException(J3dI18N.getString("Morph10")); } return ((MorphRetained)this.retained).intersect(path, pickShape, dist); } /** * Sets this Morph node's morph weight vector. The Morph node "weights" * the corresponding GeometryArray by the amount specified. * The weights apply a morph weight vector component that creates * the desired morphing effect. * The length * of the <code>weights</code> parameter must be equal to the length * of the array with which this Morph node was created, otherwise * an IllegalArgumentException is thown. * @param weights the morph weight vector that the morph node will * use in combining the node's geometryArrays. The morph node will "weight" * the corresponding GeometryArray by the amount specified. * N.B.: the sum of the weights should equal 1.0 * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if sum of all 'weights' is * NOT 1.0 or number of weights is NOT exqual to number of GeometryArrays. */ public void setWeights(double weights[]) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_WEIGHTS_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Morph8")); ((MorphRetained)this.retained).setWeights(weights); } /** * Retrieves the Morph node's morph weight vector. * @return the morph weight vector component of this morph node * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public double[] getWeights() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_WEIGHTS_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Morph9")); return ((MorphRetained)this.retained).getWeights(); } /** * Sets a flag that indicates whether this node's appearance can * be overridden. If the flag is true, this node's * appearance may be overridden by an AlternateAppearance leaf * node, regardless of the value of the ALLOW_APPEARANCE_WRITE * capability bit. * The default value is false. * * @param flag the apperance override enable flag * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @see AlternateAppearance * * @since Java 3D 1.2 */ public void setAppearanceOverrideEnable(boolean flag) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_APPEARANCE_OVERRIDE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Morph11")); ((MorphRetained)this.retained).setAppearanceOverrideEnable(flag); } /** * Retrieves the appearanceOverrideEnable flag for this node. * @return true if the appearance can be overridden; false * otherwise. * @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 boolean getAppearanceOverrideEnable() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_APPEARANCE_OVERRIDE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Morph12")); return ((MorphRetained)this.retained).getAppearanceOverrideEnable(); } /** * Creates a new instance of the node. This routine is called * by <code>cloneTree</code> to duplicate the current node. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @see Node#cloneTree * @see Node#cloneNode * @see Node#duplicateNode * @see NodeComponent#setDuplicateOnCloneTree */ public Node cloneNode(boolean forceDuplicate) { Morph m = new Morph(); m.duplicateNode(this, forceDuplicate); return m; } /** * Copies all node information from <code>originalNode</code> into * the current node. This method is called from the * <code>cloneNode</code> method which is, in turn, called by the * <code>cloneTree</code> method. * <P> * For any <code>NodeComponent</code> objects * contained by the object being duplicated, each <code>NodeComponent</code> * object's <code>duplicateOnCloneTree</code> value is used to determine * whether the <code>NodeComponent</code> should be duplicated in the new node * or if just a reference to the current node should be placed in the * new node. This flag can be overridden by setting the * <code>forceDuplicate</code> parameter in the <code>cloneTree</code> * method to <code>true</code>. * <br> * NOTE: Applications should <i>not</i> call this method directly. * It should only be called by the cloneNode method. * * @param originalNode the original node to duplicate. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * @exception ClassCastException if originalNode is not an instance of * <code>Morph</code> * * @see Node#cloneTree * @see Node#cloneNode * @see NodeComponent#setDuplicateOnCloneTree */ public void duplicateNode(Node originalNode, boolean forceDuplicate) { checkDuplicateNode(originalNode, forceDuplicate); } /** * Copies all Morph information from * <code>originalNode</code> into * the current node. This method is called from the * <code>cloneNode</code> method which is, in turn, called by the * <code>cloneTree</code> method.<P> * * @param originalNode the original node to duplicate. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @exception RestrictedAccessException if this object is part of a live * or compiled scenegraph. * * @see Node#duplicateNode * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(Node originalNode, boolean forceDuplicate) { super.duplicateAttributes(originalNode, forceDuplicate); MorphRetained attr = (MorphRetained) originalNode.retained; MorphRetained rt = (MorphRetained) retained; Hashtable hashtable = originalNode.nodeHashtable; double weights[] = attr.getWeights(); rt.setCollisionBounds(attr.getCollisionBounds()); rt.setAppearance((Appearance) getNodeComponent( attr.getAppearance(), forceDuplicate, hashtable)); GeometryArray ga[] = new GeometryArray[weights.length]; for (int i=weights.length-1; i>=0; i--) { ga[i] = (GeometryArray) getNodeComponent( attr.getGeometryArray(i), forceDuplicate, hashtable); } rt.setGeometryArrays(ga); rt.setWeights(weights); } // Method to check whether all geometries have allow intersect // capability bit set; it will throw an exception if any don't // have the bit set. private void checkForAllowIntersect() { MorphRetained morphR = ((MorphRetained)this.retained); int numGeometryArrays = morphR.getNumGeometryArrays(); for (int i = 0; i < numGeometryArrays; i++) { if (!morphR.geometryArrays[i].source. getCapability(Geometry.ALLOW_INTERSECT)) { throw new CapabilityNotSetException(J3dI18N.getString("Morph6")); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -