📄 appearanceretained.java
字号:
/* * $RCSfile: AppearanceRetained.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.10 $ * $Date: 2007/04/12 17:34:03 $ * $State: Exp $ */package javax.media.j3d;import java.util.Vector;import java.util.BitSet;import java.util.ArrayList;/** * The Appearance object defines all rendering state that can be set * as a component object of a Shape3D node. */class AppearanceRetained extends NodeComponentRetained { // // State variables: these should all be initialized to approproate // Java 3D defaults. // // Material object used when lighting is enabled MaterialRetained material = null; // Texture object used to apply a texture map to an object TextureRetained texture = null; // Texture coordinate generation object TexCoordGenerationRetained texCoordGeneration = null; // Texture Attributes bundle object TextureAttributesRetained textureAttributes = null; TextureUnitStateRetained texUnitState[] = null; // Coloring Attributes bundle object ColoringAttributesRetained coloringAttributes = null; // Transparency Attributes bundle object TransparencyAttributesRetained transparencyAttributes = null; // Rendering Attributes bundle object RenderingAttributesRetained renderingAttributes = null; // Polygon Attributes bundle object PolygonAttributesRetained polygonAttributes = null; // Line Attributes bundle object LineAttributesRetained lineAttributes = null; // Point Attributes bundle object PointAttributesRetained pointAttributes = null; // Lock used for synchronization of live state Object liveStateLock = new Object(); // NOTE: Consider grouping random state into common objects // Cache used during compilation. If map == compState, then // mapAppearance can be used for this appearance CompileState map = null; AppearanceRetained mapAppearance = null; static final int MATERIAL = 0x0001; static final int TEXTURE = 0x0002; static final int TEXCOORD_GEN = 0x0004; static final int TEXTURE_ATTR = 0x0008; static final int COLOR = 0x0010; static final int TRANSPARENCY = 0x0020; static final int RENDERING = 0x0040; static final int POLYGON = 0x0080; static final int LINE = 0x0100; static final int POINT = 0x0200; static final int TEXTURE_UNIT_STATE = 0x0400; static final int ALL_SOLE_USERS = 0; // A pointer to the scene graph appearance object AppearanceRetained sgApp = null; // The object level hashcode for this appearance // int objHashCode = super.hashCode(); /** * Set the material object to the specified object. * @param material object that specifies the desired material * @exception IllegalSharingException * properties */ void setMaterial(Material material) { synchronized(liveStateLock) { if (source.isLive()) { if (this.material != null) { this.material.clearLive(refCount); this.material.removeMirrorUsers(this); } if (material != null) { ((MaterialRetained)material.retained).setLive(inBackgroundGroup, refCount); // If appearance is live, then copy all the users of this // appaearance as users of this material ((MaterialRetained)material.retained).copyMirrorUsers(this); } sendMessage(MATERIAL, (material != null ? ((MaterialRetained)material.retained).mirror : null), true); } if (material == null) { this.material = null; } else { this.material = (MaterialRetained)material.retained; } } } /** * Retrieve the current material object. * @return the material object */ Material getMaterial() { return (material == null ? null : (Material)material.source); } /** * Sets the texture object to the specified object. * @param texture object that specifies the desired texture * map and texture parameters */ void setTexture(Texture texture) { synchronized(liveStateLock) { if (source.isLive()) { if (this.texture != null) { this.texture.clearLive(refCount); this.texture.removeMirrorUsers(this); } if (texture != null) { ((TextureRetained)texture.retained).setLive(inBackgroundGroup, refCount); ((TextureRetained)texture.retained).copyMirrorUsers(this); } sendMessage(TEXTURE, (texture != null ? ((TextureRetained)texture.retained).mirror : null), true); } if (texture == null) { this.texture = null; } else { this.texture = (TextureRetained)texture.retained; } } } /** * Retrieves the current texture object. * @return the texture object */ Texture getTexture() { return (texture == null ? null : (Texture)texture.source); } /** * Sets the textureAttrbutes object to the specified object. * @param textureAttributes object that specifies the desired texture * attributes */ void setTextureAttributes(TextureAttributes textureAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.textureAttributes != null) { this.textureAttributes.clearLive(refCount); this.textureAttributes.removeMirrorUsers(this); } if (textureAttributes != null) { ((TextureAttributesRetained)textureAttributes.retained).setLive(inBackgroundGroup, refCount); ((TextureAttributesRetained)textureAttributes.retained).copyMirrorUsers(this); } sendMessage(TEXTURE_ATTR, (textureAttributes != null ? ((TextureAttributesRetained)textureAttributes.retained).mirror: null), true); } if (textureAttributes == null) { this.textureAttributes = null; } else { this.textureAttributes = (TextureAttributesRetained)textureAttributes.retained; } } } /** * Retrieves the current textureAttributes object. * @return the textureAttributes object */ TextureAttributes getTextureAttributes() { return (textureAttributes == null ? null : (TextureAttributes)textureAttributes.source); } /** * Sets the coloringAttrbutes object to the specified object. * @param coloringAttributes object that specifies the desired texture * attributes */ void setColoringAttributes(ColoringAttributes coloringAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.coloringAttributes != null) { this.coloringAttributes.clearLive(refCount); this.coloringAttributes.removeMirrorUsers(this); } if (coloringAttributes != null) { ((ColoringAttributesRetained)coloringAttributes.retained).setLive(inBackgroundGroup, refCount); ((ColoringAttributesRetained)coloringAttributes.retained).copyMirrorUsers(this); } sendMessage(COLOR, (coloringAttributes != null ? ((ColoringAttributesRetained)coloringAttributes.retained).mirror: null), true); } if (coloringAttributes == null) { this.coloringAttributes = null; } else { this.coloringAttributes = (ColoringAttributesRetained)coloringAttributes.retained; } } } /** * Retrieves the current coloringAttributes object. * @return the coloringAttributes object */ ColoringAttributes getColoringAttributes() { return (coloringAttributes == null ? null : (ColoringAttributes)coloringAttributes.source); } /** * Sets the transparencyAttrbutes object to the specified object. * @param transparencyAttributes object that specifies the desired texture * attributes */ void setTransparencyAttributes(TransparencyAttributes transparencyAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.transparencyAttributes != null) { this.transparencyAttributes.clearLive(refCount); this.transparencyAttributes.removeMirrorUsers(this); } if (transparencyAttributes != null) { ((TransparencyAttributesRetained)transparencyAttributes.retained).setLive(inBackgroundGroup, refCount); ((TransparencyAttributesRetained)transparencyAttributes.retained).copyMirrorUsers(this); } sendMessage(TRANSPARENCY, (transparencyAttributes != null ? ((TransparencyAttributesRetained)transparencyAttributes.retained).mirror: null), true); } if (transparencyAttributes == null) { this.transparencyAttributes = null; } else { this.transparencyAttributes = (TransparencyAttributesRetained)transparencyAttributes.retained; } } } /** * Retrieves the current transparencyAttributes object. * @return the transparencyAttributes object */ TransparencyAttributes getTransparencyAttributes() { return (transparencyAttributes == null ? null : (TransparencyAttributes)transparencyAttributes.source); } /** * Sets the renderingAttrbutes object to the specified object. * @param renderingAttributes object that specifies the desired texture * attributes */ void setRenderingAttributes(RenderingAttributes renderingAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.renderingAttributes != null) { this.renderingAttributes.clearLive(refCount); this.renderingAttributes.removeMirrorUsers(this); } if (renderingAttributes != null) { ((RenderingAttributesRetained)renderingAttributes.retained).setLive(inBackgroundGroup, refCount); ((RenderingAttributesRetained)renderingAttributes.retained).copyMirrorUsers(this); } Object m = null; boolean v = true; if (renderingAttributes != null) { m = ((RenderingAttributesRetained)renderingAttributes.retained).mirror; v = ((RenderingAttributesRetained)renderingAttributes.retained).visible; } sendMessage(RENDERING,m, v); // Also need to send a message to GeometryStructure. sendRenderingAttributesChangedMessage( v); } if (renderingAttributes == null) { this.renderingAttributes = null; } else { this.renderingAttributes = (RenderingAttributesRetained)renderingAttributes.retained; } } } /** * Retrieves the current renderingAttributes object. * @return the renderingAttributes object */ RenderingAttributes getRenderingAttributes() { if (renderingAttributes == null) return null; return (RenderingAttributes)renderingAttributes.source; } /** * Sets the polygonAttrbutes object to the specified object. * @param polygonAttributes object that specifies the desired texture * attributes */ void setPolygonAttributes(PolygonAttributes polygonAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.polygonAttributes != null) { this.polygonAttributes.clearLive(refCount); this.polygonAttributes.removeMirrorUsers(this); } if (polygonAttributes != null) { ((PolygonAttributesRetained)polygonAttributes.retained).setLive(inBackgroundGroup, refCount); ((PolygonAttributesRetained)polygonAttributes.retained).copyMirrorUsers(this); } sendMessage(POLYGON, (polygonAttributes != null ? ((PolygonAttributesRetained)polygonAttributes.retained).mirror : null), true); } if (polygonAttributes == null) { this.polygonAttributes = null; } else { this.polygonAttributes = (PolygonAttributesRetained)polygonAttributes.retained; } } } /** * Retrieves the current polygonAttributes object. * @return the polygonAttributes object */ PolygonAttributes getPolygonAttributes() { return (polygonAttributes == null ? null: (PolygonAttributes)polygonAttributes.source); } /** * Sets the lineAttrbutes object to the specified object. * @param lineAttributes object that specifies the desired texture * attributes */ void setLineAttributes(LineAttributes lineAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.lineAttributes != null) { this.lineAttributes.clearLive(refCount); this.lineAttributes.removeMirrorUsers(this); } if (lineAttributes != null) { ((LineAttributesRetained)lineAttributes.retained).setLive(inBackgroundGroup, refCount); ((LineAttributesRetained)lineAttributes.retained).copyMirrorUsers(this); } sendMessage(LINE, (lineAttributes != null ? ((LineAttributesRetained)lineAttributes.retained).mirror: null), true); } if (lineAttributes == null) { this.lineAttributes = null; } else { this.lineAttributes = (LineAttributesRetained)lineAttributes.retained; } } } /** * Retrieves the current lineAttributes object. * @return the lineAttributes object */ LineAttributes getLineAttributes() { return (lineAttributes == null ? null : (LineAttributes)lineAttributes.source); } /** * Sets the pointAttrbutes object to the specified object. * @param pointAttributes object that specifies the desired texture * attributes */ void setPointAttributes(PointAttributes pointAttributes) { synchronized(liveStateLock) { if (source.isLive()) { if (this.pointAttributes != null) { this.pointAttributes.clearLive(refCount); this.pointAttributes.removeMirrorUsers(this); } if (pointAttributes != null) { ((PointAttributesRetained)pointAttributes.retained).setLive(inBackgroundGroup, refCount); ((PointAttributesRetained)pointAttributes.retained).copyMirrorUsers(this); } sendMessage(POINT, (pointAttributes != null ? ((PointAttributesRetained)pointAttributes.retained).mirror: null), true); } if (pointAttributes == null) { this.pointAttributes = null; } else { this.pointAttributes = (PointAttributesRetained)pointAttributes.retained;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -