⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textureattributesretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   /**    * Creates and initializes a mirror object, point the mirror object     * to the retained object if the object is not editable    */    synchronized void createMirrorObject() {	if (mirror == null) {	    // Check the capability bits and let the mirror object	    // point to itself if is not editable	    if (isStatic()) {		mirror = this;	    } else {		TextureAttributesRetained mirrorTa  = new TextureAttributesRetained();		mirrorTa.source = source;		mirrorTa.set(this);		mirror = mirrorTa;	    }	}  else {	    ((TextureAttributesRetained)mirror).set(this);	}    }   /**    * Initializes a mirror object    */    synchronized void initMirrorObject() {	((TextureAttributesRetained)mirror).set(this);    }    /**     * Update the "component" field of the mirror object with the      *  given "value"     */    synchronized void updateMirrorObject(int component, Object value, 						Object value2) {	TextureAttributesRetained mirrorTa = (TextureAttributesRetained)mirror;	mirrorTa.mirrorCompDirty = true;	if ((component & TRANSFORM_CHANGED) != 0) {	    mirrorTa.transform.set((Transform3D)value);	}	else if ((component & MODE_CHANGED) != 0) {	    mirrorTa.textureMode = ((Integer)value).intValue();	    if ((mirrorTa.textureMode == TextureAttributes.COMBINE) &&			(mirrorTa.combineRgbSrc == null)) {		initCombineMode(mirrorTa);	    }	}	else if ((component & COLOR_CHANGED) != 0) {	    mirrorTa.textureBlendColor.set((Color4f)value);	}	else if ((component & CORRECTION_CHANGED) != 0) {	    mirrorTa.perspCorrectionMode = ((Integer)value).intValue();	} 	else if ((component & TEXTURE_COLOR_TABLE_CHANGED) != 0) {	    if (value == null) {		mirrorTa.textureColorTable = null;		mirrorTa.numTextureColorTableComponents = 0;		mirrorTa.textureColorTableSize = 0;	    } else {		Object args[] = (Object[])value;	        mirrorTa.textureColorTable = (int[])args[2];		mirrorTa.numTextureColorTableComponents = 			((Integer)args[0]).intValue();		mirrorTa.textureColorTableSize = 			((Integer)args[1]).intValue();	    }	}	else if ((component & COMBINE_RGB_MODE_CHANGED) != 0) {	    mirrorTa.combineRgbMode = ((Integer)value).intValue();	}        else if ((component & COMBINE_ALPHA_MODE_CHANGED) != 0) {            mirrorTa.combineAlphaMode = ((Integer)value).intValue();        }        else if ((component & COMBINE_RGB_SRC_CHANGED) != 0) {            if (mirrorTa.combineRgbSrc == null) {                //initialize the memory for combine mode                initCombineMode(mirrorTa);            }	    int index = ((Integer)value).intValue();            mirrorTa.combineRgbSrc[index] = ((Integer)value2).intValue();        }        else if ((component & COMBINE_ALPHA_SRC_CHANGED) != 0) {            if (mirrorTa.combineRgbSrc == null) {                //initialize the memory for combine mode                initCombineMode(mirrorTa);            }	    int index = ((Integer)value).intValue();            mirrorTa.combineAlphaSrc[index] = ((Integer)value2).intValue();        }        else if ((component & COMBINE_RGB_FCN_CHANGED) != 0) {            if (mirrorTa.combineRgbSrc == null) {                //initialize the memory for combine mode                initCombineMode(mirrorTa);            }	    int index = ((Integer)value).intValue();            mirrorTa.combineRgbFcn[index] = ((Integer)value2).intValue();        }        else if ((component & COMBINE_ALPHA_FCN_CHANGED) != 0) {            if (mirrorTa.combineRgbSrc == null) {                //initialize the memory for combine mode                initCombineMode(mirrorTa);            }	    int index = ((Integer)value).intValue();            mirrorTa.combineAlphaFcn[index] = ((Integer)value2).intValue();        }        else if ((component & COMBINE_RGB_SCALE_CHANGED) != 0) {            mirrorTa.combineRgbScale = ((Integer)value).intValue();        }        else if ((component & COMBINE_ALPHA_SCALE_CHANGED) != 0) {            mirrorTa.combineAlphaScale = ((Integer)value).intValue();        }    }    boolean equivalent(TextureAttributesRetained tr) {	if (tr == null) {	    return (false);	} else if ((this.changedFrequent != 0) || (tr.changedFrequent != 0)) {	    return (this == tr);	}	if (!(tr.transform.equals(transform) &&	        tr.textureBlendColor.equals(textureBlendColor) &&	        (tr.textureMode == textureMode) &&	        (tr.perspCorrectionMode == perspCorrectionMode))) {	    return false;	}	// now check for combine mode attributes if textureMode specifies        // COMBINE	if (textureMode == TextureAttributes.COMBINE) {	    if ((tr.combineRgbMode != combineRgbMode) ||		(tr.combineAlphaMode != combineAlphaMode) ||		(tr.combineRgbScale != combineRgbScale) ||		(tr.combineAlphaScale != combineAlphaScale)) {		return false;	    }	    // now check if the operands for the combine equations are	    // equivalent	    int nOpNeeded = 0;	    if (combineRgbMode == TextureAttributes.COMBINE_REPLACE) {		nOpNeeded = 1;	    } else if (combineRgbMode == TextureAttributes.COMBINE_INTERPOLATE) {		nOpNeeded = 3;	    } else {		nOpNeeded = 2;	    }	    for (int i = 0; i < nOpNeeded; i++) {		if ((tr.combineRgbSrc[i] != combineRgbSrc[i]) ||		    (tr.combineAlphaSrc[i] != combineAlphaSrc[i]) ||		    (tr.combineRgbFcn[i] != combineRgbFcn[i]) ||		    (tr.combineAlphaFcn[i] != combineAlphaFcn[i])) {		    return false;		}	    }	}	// now check for texture color table	if (tr.textureColorTable == null) {	    if (this.textureColorTable == null)		return true;	    else		return false;	} else if (this.textureColorTable == null) {	    // tr.textureColorTable != null            return false;        } else {	    if (tr.textureColorTable.length != this.textureColorTable.length) 		return false;	    for (int i = 0; i < this.textureColorTable.length; i++) {		 if (this.textureColorTable[i] != tr.textureColorTable[i])		     return false;	    }	    return true;	}    }    protected Object clone() {	TextureAttributesRetained tr = (TextureAttributesRetained)super.clone();	tr.transform = new Transform3D(transform);	tr.textureBlendColor = new Color4f(textureBlendColor);	if (textureColorTable != null) {	    tr.textureColorTable = new int[textureColorTable.length];	    System.arraycopy(textureColorTable, 0, tr.textureColorTable, 0,				textureColorTable.length);	} else {	    tr.textureColorTable = null;	}	// clone the combine mode attributes	if (combineRgbSrc != null) {            tr.combineRgbSrc   = new int[3];            tr.combineAlphaSrc = new int[3];            tr.combineRgbFcn   = new int[3];            tr.combineAlphaFcn = new int[3];	    for (int i = 0; i < 3; i++) {		 tr.combineRgbSrc[i] = combineRgbSrc[i];		 tr.combineAlphaSrc[i] = combineAlphaSrc[i];		 tr.combineRgbFcn[i] = combineRgbFcn[i];		 tr.combineAlphaFcn[i] = combineAlphaFcn[i];	    }	}	   	// other attributes are copied in super.clone()	return tr;    }    protected void set(TextureAttributesRetained tr) {	super.set(tr);        transform.set(tr.transform);	textureBlendColor.set(tr.textureBlendColor);	textureMode = tr.textureMode;	perspCorrectionMode = tr.perspCorrectionMode;	// set texture color table	if (tr.textureColorTable != null) {	    if (textureColorTable == null ||		    textureColorTable.length != tr.textureColorTable.length) {	        textureColorTable = new int[tr.textureColorTable.length];	    }	    System.arraycopy(tr.textureColorTable, 0, textureColorTable, 0,					tr.textureColorTable.length);	} else {	    textureColorTable = null;	}	numTextureColorTableComponents = tr.numTextureColorTableComponents;	textureColorTableSize = tr.textureColorTableSize; 	// set the combine mode attributes	combineRgbMode = tr.combineRgbMode;	combineAlphaMode = tr.combineAlphaMode;	combineRgbScale = tr.combineRgbScale;	combineAlphaScale = tr.combineAlphaScale;	if (tr.combineRgbSrc != null) {	    if (combineRgbSrc == null) {                combineRgbSrc   = new int[3];                combineAlphaSrc = new int[3];                combineRgbFcn   = new int[3];                combineAlphaFcn = new int[3];	    }	    for (int i = 0; i < 3; i++) {		 combineRgbSrc[i] = tr.combineRgbSrc[i];		 combineAlphaSrc[i] = tr.combineAlphaSrc[i];		 combineRgbFcn[i] = tr.combineRgbFcn[i];		 combineAlphaFcn[i] = tr.combineAlphaFcn[i];	    }	}    }    final void sendMessage(int attrMask, Object attr1, Object attr2) {       	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.TEXTUREATTRIBUTES_CHANGED;	createMessage.universe = null;	createMessage.args[0] = this;	createMessage.args[1] = new Integer(attrMask);	createMessage.args[2] = attr1;	createMessage.args[3] = attr2;        createMessage.args[4] = 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.TEXTUREATTRIBUTES_CHANGED;			    createMessage.universe = (VirtualUniverse) univList.get(i);	    createMessage.args[0] = this;	    createMessage.args[1] = new Integer(attrMask);	    createMessage.args[2] = attr1;	    ArrayList gL = (ArrayList) gaList.get(i);	    GeometryAtom[] gaArr = new GeometryAtom[gL.size()];	    gL.toArray(gaArr);	    createMessage.args[3] = gaArr;	    	    VirtualUniverse.mc.processMessage(createMessage);	}    }    void handleFrequencyChange(int bit) {	switch (bit) {	case TextureAttributes.ALLOW_MODE_WRITE:	case TextureAttributes.ALLOW_BLEND_COLOR_WRITE:	case TextureAttributes.ALLOW_TRANSFORM_WRITE:	case TextureAttributes.ALLOW_COLOR_TABLE_WRITE:	case TextureAttributes.ALLOW_COMBINE_WRITE: {            setFrequencyChangeMask(bit, bit);        }	default:	    break;	}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -