📄 textureunitstateretained.java
字号:
if (this.texGen != null) mirrorTus.texGen = (TexCoordGenerationRetained)this.texGen.mirror; else mirrorTus.texGen = null; } /** Update the "component" field of the mirror object with the * given "value" */ synchronized void updateMirrorObject(int component, Object value) { TextureUnitStateRetained mirrorTus = (TextureUnitStateRetained)mirror; if ((component & TEXTURE_CHANGED) != 0) { mirrorTus.texture = (TextureRetained)value; } else if ((component & TEXTURE_ATTRS_CHANGED) != 0) { mirrorTus.texAttrs = (TextureAttributesRetained)value; } else if ((component & TEXCOORD_GEN_CHANGED) != 0) { mirrorTus.texGen = (TexCoordGenerationRetained)value; } else if ((component & ALL_STATE_CHANGED) != 0) { Object [] args = (Object []) value; mirrorTus.texture = (TextureRetained)args[0]; mirrorTus.texAttrs = (TextureAttributesRetained)args[1]; mirrorTus.texGen = (TexCoordGenerationRetained)args[2]; } } boolean equivalent(TextureUnitStateRetained tr) { if (tr == null) { return (false); } else if ((this.changedFrequent != 0) || (tr.changedFrequent != 0)) { return (this.mirror == tr); } else { if (this.texture != tr.texture) { return false; } if (this.texAttrs != null && !this.texAttrs.equivalent(tr.texAttrs)) { return false; } if (this.texGen != null && !this.texGen.equivalent(tr.texGen)) { return false; } } return true; } protected Object clone() { TextureUnitStateRetained tr = (TextureUnitStateRetained)super.clone(); // the cloned object is used for RenderBin only. // In most cases, it will duplicate all attributes in the RenderBin // so that updating a mirror object in one level will not affect the // entire structure of the RenderBin, but will affect only those bins // that got affected by the modified mirror object if (this.texAttrs != null) tr.texAttrs = (TextureAttributesRetained)this.texAttrs.clone(); if (this.texGen != null) tr.texGen = (TexCoordGenerationRetained)this.texGen.clone(); return tr; } /** * set the texture unit state according to the specified texture * unit state */ protected void set(TextureUnitStateRetained tr) { super.set(tr); this.texture = tr.texture; if (tr.texAttrs == null) { this.texAttrs = null; } else { if (this.texAttrs == null) { this.texAttrs = (TextureAttributesRetained)tr.texAttrs.clone(); } else { this.texAttrs.set(tr.texAttrs); } } if (tr.texGen == null) { this.texGen = null; } else { if (this.texGen == null) { this.texGen = (TexCoordGenerationRetained)tr.texGen.clone(); } else { this.texGen.set(tr.texGen); } } } protected void set(TextureRetained texture, TextureAttributesRetained texAttrs, TexCoordGenerationRetained texGen) { this.texture = texture; this.texAttrs = texAttrs; this.texGen = texGen; } synchronized void addAMirrorUser(Shape3DRetained shape) { super.addAMirrorUser(shape); if (texture != null) texture.addAMirrorUser(shape); if (texAttrs != null) texAttrs.addAMirrorUser(shape); if (texGen != null) texGen.addAMirrorUser(shape); } synchronized void removeAMirrorUser(Shape3DRetained shape) { super.removeAMirrorUser(shape); if (texture != null) texture.removeAMirrorUser(shape); if (texAttrs != null) texAttrs.removeAMirrorUser(shape); if (texGen != null) texGen.removeAMirrorUser(shape); } synchronized void removeMirrorUsers(NodeComponentRetained node) { super.removeMirrorUsers(node); if (texture != null) texture.removeMirrorUsers(node); if (texAttrs != null) texAttrs.removeMirrorUsers(node); if (texGen != null) texGen.removeMirrorUsers(node); } synchronized void copyMirrorUsers(NodeComponentRetained node) { super.copyMirrorUsers(node); if (texture != null) texture.copyMirrorUsers(node); if (texAttrs != null) texAttrs.copyMirrorUsers(node); if (texGen != null) texGen.copyMirrorUsers(node); } void setLive(boolean backgroundGroup, int refCount) { if (texture != null) texture.setLive(backgroundGroup, refCount); if (texAttrs != null) texAttrs.setLive(backgroundGroup, refCount); if (texGen != null) texGen.setLive(backgroundGroup, refCount); // Increment the reference count and initialize the textureUnitState // mirror object super.doSetLive(backgroundGroup, refCount); super.markAsLive(); } void clearLive(int refCount) { super.clearLive(refCount); if (texture != null) texture.clearLive(refCount); if (texAttrs != null) texAttrs.clearLive(refCount); if (texGen != null) texGen.clearLive(refCount); } boolean isStatic() { return (source.capabilityBitsEmpty() && ((texture == null) || (texture.isStatic())) && ((texAttrs == null) || (texAttrs.isStatic())) && ((texGen == null) || (texGen.isStatic()))); } // Issue 209 - enable this method (was previously commented out) // Simply pass along to the NodeComponent void compile (CompileState compState) { setCompiled(); if (texture != null) texture.compile(compState); if (texAttrs != null) texAttrs.compile(compState); if (texGen != null) texGen.compile(compState); } boolean equals(TextureUnitStateRetained ts) { return ((ts == this) || (ts != null) && ((texture == ts.texture) || ((texture != null) && (texture.equals(ts.texture)))) && ((texAttrs == ts.texAttrs) || ((texAttrs != null) && (texAttrs.equals(ts.texAttrs)))) && ((texGen == ts.texGen) || ((texGen != null) && (texGen.equals(ts.texGen))))); } void setInImmCtx(boolean flag) { super.setInImmCtx(flag); if (texture != null) texture.setInImmCtx(flag); if (texAttrs != null) texAttrs.setInImmCtx(flag); if (texGen != null) texGen.setInImmCtx(flag); } boolean getInImmCtx() { return (super.getInImmCtx() || ((texture != null) && (texture.getInImmCtx())) || ((texAttrs != null) && (texAttrs.getInImmCtx())) || ((texGen != null) && (texGen.getInImmCtx()))); } boolean isLive() { return (source.isLive() || ((texture != null) && (texture.source.isLive())) || ((texAttrs != null) && (texAttrs.source.isLive())) || ((texGen != null) && (texGen.source.isLive()))); } final void sendMessage(int attrMask, Object attr) { 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.TEXTURE_UNIT_STATE_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.TEXTURE_UNIT_STATE_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; VirtualUniverse.mc.processMessage(createMessage); } } boolean isTextureEnabled() { // Check the internal enable , instead of userSpecifiedEnable return (texture != null && texture.enable); } void handleFrequencyChange(int bit) { switch (bit) { case TextureUnitState.ALLOW_STATE_WRITE: { setFrequencyChangeMask(bit, bit); } default: break; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -