📄 appearanceretained.java
字号:
} if (pointAttributes != null) { pointAttributes.setLive(backgroundGroup, refCount); } // Increment the reference count and initialize the appearance // mirror object super.doSetLive(backgroundGroup, refCount); } /** * This method calls the clearLive method of all appearance bundle * objects. */ void clearLive(int refCount) { super.clearLive(refCount); if (texture != null) { texture.clearLive(refCount); } if (texCoordGeneration != null) { texCoordGeneration.clearLive(refCount); } if (textureAttributes != null) { textureAttributes.clearLive(refCount); } if (texUnitState != null) { for (int i = 0; i < texUnitState.length; i++) { if (texUnitState[i] != null) texUnitState[i].clearLive(refCount); } } if (coloringAttributes != null) { coloringAttributes.clearLive(refCount); } if (transparencyAttributes != null) { transparencyAttributes.clearLive(refCount); } if (renderingAttributes != null) { renderingAttributes.clearLive(refCount); } if (polygonAttributes != null) { polygonAttributes.clearLive(refCount); } if (lineAttributes != null) { lineAttributes.clearLive(refCount); } if (pointAttributes != null) { pointAttributes.clearLive(refCount); } if (material != null) { material.clearLive(refCount); } } boolean isStatic() { boolean flag; flag = (source.capabilityBitsEmpty() && ((texture == null) || texture.source.capabilityBitsEmpty()) && ((texCoordGeneration == null) || texCoordGeneration.source.capabilityBitsEmpty()) && ((textureAttributes == null) || textureAttributes.source.capabilityBitsEmpty()) && ((coloringAttributes == null) || coloringAttributes.source.capabilityBitsEmpty()) && ((transparencyAttributes == null) || transparencyAttributes.source.capabilityBitsEmpty()) && ((renderingAttributes == null) || renderingAttributes.source.capabilityBitsEmpty()) && ((polygonAttributes == null) || polygonAttributes.source.capabilityBitsEmpty()) && ((lineAttributes == null) || lineAttributes.source.capabilityBitsEmpty()) && ((pointAttributes == null) || pointAttributes.source.capabilityBitsEmpty()) && ((material == null) || material.source.capabilityBitsEmpty())); if (!flag) return flag; if (texUnitState != null) { for (int i = 0; i < texUnitState.length && flag; i++) { if (texUnitState[i] != null) { flag = flag && texUnitState[i].isStatic(); } } } return flag; } // Issue 209 - enable this method (was previously commented out) // Simply pass along to the NodeComponents void compile(CompileState compState) { setCompiled(); if (texture != null) { texture.compile(compState); } if (texCoordGeneration != null) { texCoordGeneration.compile(compState); } if (textureAttributes != null) { textureAttributes.compile(compState); } if (texUnitState != null) { for (int i = 0; i < texUnitState.length; i++) { if (texUnitState[i] != null) texUnitState[i].compile(compState); } } if (coloringAttributes != null) { coloringAttributes.compile(compState); } if (transparencyAttributes != null) { transparencyAttributes.compile(compState); } if (renderingAttributes != null) { renderingAttributes.compile(compState); } if (polygonAttributes != null) { polygonAttributes.compile(compState); } if (lineAttributes != null) { lineAttributes.compile(compState); } if (pointAttributes != null) { pointAttributes.compile(compState); } if (material != null) { material.compile(compState); } } /** * Returns the hashcode for this object. * hashcode should be constant for object but same for two objects * if .equals() is true. For an appearance (where .equals() is going * to use the values in the appearance), the only way to have a * constant value is for all appearances to have the same hashcode, so * we use the hashcode of the class obj. * * Since hashCode is only used by AppearanceMap (at present) we may be * able to improve efficency by calcing a hashCode from the values. */ public int hashCode() { return getClass().hashCode(); } public boolean equals(Object obj) { return ((obj instanceof AppearanceRetained) && equals((AppearanceRetained) obj)); } boolean equals(AppearanceRetained app) { boolean flag; flag = (app == this) || ((app != null) && (((material == app.material) || ((material != null) && material.equivalent(app.material))) && ((texture == app.texture) || ((texture != null) && texture.equals(app.texture))) && ((renderingAttributes == app.renderingAttributes) || ((renderingAttributes != null) && renderingAttributes.equivalent( app.renderingAttributes))) && ((polygonAttributes == app.polygonAttributes) || ((polygonAttributes != null) && polygonAttributes.equivalent(app.polygonAttributes))) && ((texCoordGeneration == app.texCoordGeneration) || ((texCoordGeneration != null) && texCoordGeneration.equivalent(app.texCoordGeneration))) && ((textureAttributes == app.textureAttributes) || ((textureAttributes != null) && textureAttributes.equivalent(app.textureAttributes))) && ((coloringAttributes == app.coloringAttributes) || ((coloringAttributes != null) && coloringAttributes.equivalent(app.coloringAttributes))) && ((transparencyAttributes == app.transparencyAttributes) || ((transparencyAttributes != null) && transparencyAttributes.equivalent( app.transparencyAttributes))) && ((lineAttributes == app.lineAttributes) || ((lineAttributes != null) && lineAttributes.equivalent(app.lineAttributes))) && ((pointAttributes == app.pointAttributes) || ((pointAttributes != null) && pointAttributes.equivalent(app.pointAttributes))))); if (!flag) return (flag); if (texUnitState == app.texUnitState) return (flag); if (texUnitState == null || app.texUnitState == null || texUnitState.length != app.texUnitState.length) return (false); for (int i = 0; i < texUnitState.length; i++) { if (texUnitState[i] == app.texUnitState[i]) continue; if (texUnitState[i] == null || app.texUnitState[i] == null || !texUnitState[i].equals(app.texUnitState[i])) return (false); } return (true); } synchronized void addAMirrorUser(Shape3DRetained shape) { super.addAMirrorUser(shape); if (material != null) material.addAMirrorUser(shape); if (texture != null) texture.addAMirrorUser(shape); if (texCoordGeneration != null) texCoordGeneration.addAMirrorUser(shape); if (textureAttributes != null) textureAttributes.addAMirrorUser(shape); if (texUnitState != null) { for (int i = 0; i < texUnitState.length; i++) { if (texUnitState[i] != null) texUnitState[i].addAMirrorUser(shape); } } if (coloringAttributes != null) coloringAttributes.addAMirrorUser(shape); if (transparencyAttributes != null) transparencyAttributes.addAMirrorUser(shape); if (renderingAttributes != null) renderingAttributes.addAMirrorUser(shape); if (polygonAttributes != null) polygonAttributes.addAMirrorUser(shape); if (lineAttributes != null) lineAttributes.addAMirrorUser(shape); if (pointAttributes != null) pointAttributes.addAMirrorUser(shape); } synchronized void removeAMirrorUser(Shape3DRetained shape) { super.removeAMirrorUser(shape); if (material != null) material.removeAMirrorUser(shape); if (texture != null) texture.removeAMirrorUser(shape); if (texCoordGeneration != null) texCoordGeneration.removeAMirrorUser(shape); if (textureAttributes != null) textureAttributes.removeAMirrorUser(shape); if (texUnitState != null) { for (int i = 0; i < texUnitState.length; i++) { if (texUnitState[i] != null) texUnitState[i].removeAMirrorUser(shape); } } if (coloringAttributes != null) coloringAttributes.removeAMirrorUser(shape); if (transparencyAttributes != null) transparencyAttributes.removeAMirrorUser(shape); if (renderingAttributes != null) renderingAttributes.removeAMirrorUser(shape); if (polygonAttributes != null) polygonAttributes.removeAMirrorUser(shape); if (lineAttributes != null) lineAttributes.removeAMirrorUser(shape); if (pointAttributes != null) pointAttributes.removeAMirrorUser(shape); } // 3rd argument used only when Rendering Attr comp changes final void sendMessage(int attrMask, Object attr, boolean visible) { ArrayList univList = new ArrayList(); ArrayList gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList); // Send to rendering attribute structure, regardless of // whether there are users or not (alternate appearance case ..) J3dMessage createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES; createMessage.type = J3dMessage.APPEARANCE_CHANGED; createMessage.universe = null; createMessage.args[0] = this; createMessage.args[1]= new Integer(attrMask); createMessage.args[2] = attr; createMessage.args[3] = new Integer(changedFrequent); VirtualUniverse.mc.processMessage(createMessage); // System.err.println("univList.size is " + univList.size()); for(int i=0; i<univList.size(); i++) { createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_RENDER; createMessage.type = J3dMessage.APPEARANCE_CHANGED; createMessage.universe = (VirtualUniverse) univList.get(i); createMessage.args[0] = this; createMessage.args[1]= new Integer(attrMask); createMessage.args[2] = attr; ArrayList gL = (ArrayList) gaList.get(i); GeometryAtom[] gaArr = new GeometryAtom[gL.size()]; gL.toArray(gaArr); createMessage.args[3] = gaArr; // Send the value itself, since Geometry Structure cannot rely on the // mirror (which may be updated lazily) if (attrMask == RENDERING) { if (attr != null) { createMessage.args[4] = visible?Boolean.TRUE:Boolean.FALSE; } else { createMessage.args[4] = Boolean.TRUE; } } VirtualUniverse.mc.processMessage(createMessage); } } final void sendRenderingAttributesChangedMessage(boolean visible) { ArrayList univList = new ArrayList(); ArrayList gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList); // System.err.println("univList.size is " + univList.size()); for(int i=0; i<univList.size(); i++) { J3dMessage createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_GEOMETRY; createMessage.type = J3dMessage.RENDERINGATTRIBUTES_CHANGED; createMessage.universe = (VirtualUniverse) univList.get(i); createMessage.args[0] = this; createMessage.args[1] = null; // Sync with RenderingAttrRetained sendMessage createMessage.args[2]= visible?Boolean.TRUE:Boolean.FALSE; ArrayList gL = (ArrayList) gaList.get(i); GeometryAtom[] gaArr = new GeometryAtom[gL.size()]; gL.toArray(gaArr); createMessage.args[3] = gaArr; VirtualUniverse.mc.processMessage(createMessage); } } boolean isOpaque(int geoType) { TransparencyAttributesRetained ta; int i; ta = transparencyAttributes; if (ta != null && ta.transparencyMode != TransparencyAttributes.NONE && (VirtualUniverse.mc.isD3D() || (!VirtualUniverse.mc.isD3D() && (ta.transparencyMode != TransparencyAttributes.SCREEN_DOOR)))) { return(false); } switch (geoType) { case GeometryRetained.GEO_TYPE_POINT_SET: case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET: if ((pointAttributes != null) && pointAttributes.pointAntialiasing) { return (false); } break; case GeometryRetained.GEO_TYPE_LINE_SET: case GeometryRetained.GEO_TYPE_LINE_STRIP_SET: case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET: case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET: if ((lineAttributes != null) && lineAttributes.lineAntialiasing) { return (false); } break; case GeometryRetained.GEO_TYPE_RASTER: case GeometryRetained.GEO_TYPE_COMPRESSED: break; default: if (polygonAttributes != null) { if((polygonAttributes.polygonMode == PolygonAttributes.POLYGON_POINT) && (pointAttributes != null) && pointAttributes.pointAntialiasing) { return (false); } else if ((polygonAttributes.polygonMode == PolygonAttributes.POLYGON_LINE) && (lineAttributes != null) && lineAttributes.lineAntialiasing) { return (false); } } break; } return(true); } void handleFrequencyChange(int bit) { int mask = 0; if (bit == Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE) mask = COLOR; else if(bit == Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE) mask = TRANSPARENCY; else if(bit == Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE) mask = RENDERING; else if (bit == Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE) mask = POLYGON; else if (bit == Appearance.ALLOW_LINE_ATTRIBUTES_WRITE) mask = LINE; else if (bit == Appearance.ALLOW_POINT_ATTRIBUTES_WRITE) mask = POINT; else if (bit == Appearance.ALLOW_MATERIAL_WRITE) mask = MATERIAL; else if (bit == Appearance.ALLOW_TEXTURE_WRITE) mask = TEXTURE; else if (bit == Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE) mask = TEXTURE_ATTR; else if (bit == Appearance.ALLOW_TEXGEN_WRITE) mask = TEXCOORD_GEN; else if (bit == Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE) mask = TEXTURE_UNIT_STATE; if (mask != 0) setFrequencyChangeMask(bit, mask); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -