📄 appearance.java
字号:
* numbered from <code>0</code> through * <code>stateArray.length-1</code>. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @exception IllegalStateException if the specified array is * non-null and any of the texture object, textureAttributes * object, or texCoordGeneration object in this appearance object * is already non-null. * * @exception IllegalSharingException if this Appearance is live and * any of the specified textures refers to an ImageComponent2D that is * being used by a Canvas3D as an off-screen buffer. * * @exception IllegalSharingException if this Appearance is * being used by an immediate mode context and * any of the specified textures refers to an ImageComponent2D that is * being used by a Canvas3D as an off-screen buffer. * * @since Java 3D 1.2 */ public void setTextureUnitState(TextureUnitState[] stateArray) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Appearance20")); // Do illegal sharing check if (stateArray != null) { for(int j=0; j<stateArray.length; j++) { if(stateArray[j] != null) { TextureRetained texRetained = ((TextureUnitStateRetained)stateArray[j].retained).texture; if(texRetained != null) { ImageComponent[] images = texRetained.getImages(); if(images != null) { for(int i=0; i<images.length; i++) { validateImageIllegalSharing(images[i]); } } } } } } ((AppearanceRetained)this.retained).setTextureUnitState(stateArray); } /** * Sets the texture unit state object at the specified index * within the texture unit state array to the specified object. * If the specified object is null, the corresponding texture unit * is disabled. The index must be within the range * <code>[0, stateArray.length-1]</code>. * * @param index the array index of the object to be set * * @param state new texture unit state object * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception NullPointerException if the texture unit state array is * null. * @exception ArrayIndexOutOfBoundsException if <code>index >= * stateArray.length</code>. * * @exception IllegalSharingException if this Appearance is live and * the specified texture refers to an ImageComponent2D that is being used * by a Canvas3D as an off-screen buffer. * * @exception IllegalSharingException if this Appearance is * being used by an immediate mode context and * the specified texture refers to an ImageComponent2D that is being used * by a Canvas3D as an off-screen buffer. * * @since Java 3D 1.2 */ public void setTextureUnitState(int index, TextureUnitState state) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Appearance20")); // Do illegal sharing check if (state != null) { TextureRetained texRetained = ((TextureUnitStateRetained)state.retained).texture; if(texRetained != null) { ImageComponent[] images = texRetained.getImages(); if(images != null) { for(int i=0; i<images.length; i++) { validateImageIllegalSharing(images[i]); } } } } ((AppearanceRetained)this.retained).setTextureUnitState(index, state); } /** * Retrieves the array of texture unit state objects from this * Appearance object. A shallow copy of the array of references to * the TextureUnitState objects is returned. * * @return the array of texture unit state objects * * @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 TextureUnitState[] getTextureUnitState() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Appearance21")); return ((AppearanceRetained)this.retained).getTextureUnitState(); } /** * Retrieves the texture unit state object at the specified * index within the texture unit state array. The index must be * within the range <code>[0, stateArray.length-1]</code>. * * @param index the array index of the object to be retrieved * * @return the texture unit state object 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 TextureUnitState getTextureUnitState(int index) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Appearance21")); return ((AppearanceRetained)this.retained).getTextureUnitState(index); } /** * Retrieves the length of the texture unit state array from * this appearance object. The length of this array specifies the * maximum number of texture units that will be used by this * appearance object. If the array is null, a count of 0 is * returned. * * @return the length of the texture unit state array * * @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 int getTextureUnitCount() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Appearance21")); return ((AppearanceRetained)this.retained).getTextureUnitCount(); } /** * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { Appearance a = new Appearance(); a.duplicateNodeComponent(this); return a; } /** * NOTE: Applications should <i>not</i> call this method directly. * It should only be called by the cloneNode method. * * @deprecated replaced with duplicateNodeComponent( * NodeComponent originalNodeComponent, boolean forceDuplicate) */ public void duplicateNodeComponent(NodeComponent originalNodeComponent) { checkDuplicateNodeComponent(originalNodeComponent); } /** * Copies all Appearance information from * <code>originalNodeComponent</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 originalNodeComponent 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#cloneTree * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(NodeComponent originalNodeComponent, boolean forceDuplicate) { super.duplicateAttributes(originalNodeComponent, forceDuplicate); Hashtable hashtable = originalNodeComponent.nodeHashtable; AppearanceRetained app = (AppearanceRetained) originalNodeComponent.retained; AppearanceRetained rt = (AppearanceRetained) retained; rt.setMaterial((Material) getNodeComponent(app.getMaterial(), forceDuplicate, hashtable)); rt.setColoringAttributes((ColoringAttributes) getNodeComponent( app.getColoringAttributes(), forceDuplicate, hashtable)); rt.setTransparencyAttributes((TransparencyAttributes) getNodeComponent( app.getTransparencyAttributes(), forceDuplicate, hashtable)); rt.setRenderingAttributes((RenderingAttributes) getNodeComponent( app.getRenderingAttributes(), forceDuplicate, hashtable)); rt.setPolygonAttributes((PolygonAttributes) getNodeComponent( app.getPolygonAttributes(), forceDuplicate, hashtable)); rt.setLineAttributes((LineAttributes) getNodeComponent( app.getLineAttributes(), forceDuplicate, hashtable)); rt.setPointAttributes((PointAttributes) getNodeComponent( app.getPointAttributes(), forceDuplicate, hashtable)); rt.setTexture((Texture) getNodeComponent(app.getTexture(), forceDuplicate, hashtable)); rt.setTextureAttributes((TextureAttributes) getNodeComponent( app.getTextureAttributes(), forceDuplicate, hashtable)); rt.setTexCoordGeneration((TexCoordGeneration) getNodeComponent( app.getTexCoordGeneration(), forceDuplicate, hashtable)); TextureUnitState state[] = app.getTextureUnitState(); if (state != null) { rt.setTextureUnitState(state); for (int i=0; i < state.length; i++) { rt.setTextureUnitState(i, (TextureUnitState) getNodeComponent(state[i], forceDuplicate, hashtable)); } } } /** * This function is called from getNodeComponent() to see if any of * the sub-NodeComponents duplicateOnCloneTree flag is true. * If it is the case, current NodeComponent needs to * duplicate also even though current duplicateOnCloneTree flag is false. * This should be overwrite by NodeComponent which contains sub-NodeComponent. */ boolean duplicateChild() { if (getDuplicateOnCloneTree()) return true; AppearanceRetained rt = (AppearanceRetained) retained; NodeComponent nc; nc = rt.getMaterial(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getColoringAttributes(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getTransparencyAttributes(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getPolygonAttributes(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getLineAttributes(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getPointAttributes(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getTexture(); if ((nc != null) && nc.duplicateChild()) return true; nc = rt.getTextureAttributes(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; nc = rt.getTexCoordGeneration(); if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; // XXXX: TextureUnitState return false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -