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

📄 renderingattributesretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**     * Initialize the raster op value     */    final void initRasterOp(int op) {	rasterOp = op;    }    /**     * Set the raster op value     */    final void setRasterOp(int op) {	initRasterOp(op);	sendMessage(RASTER_OP_VALUE, new Integer(op));    }    /**     * Retrieves the current raster op value.     */    final int getRasterOp() {	return rasterOp;    }    // Stencil operations     /**     * Initialize the stencil enable state     */    final void initStencilEnable(boolean state) {	stencilEnable = state;    }    /**     * Set the stencil enable state     */    final void setStencilEnable(boolean state) {	initStencilEnable(state);	sendMessage(STENCIL_ENABLE, new Boolean(state));    }    /**     * Retrieves the current stencil enable state.     */    final boolean getStencilEnable() {	return stencilEnable;    }    /**     * Initialize the stencil op. value     */    final void initStencilOp(int failOp, int zFailOp, int zPassOp) {	stencilFailOp = failOp;	stencilZFailOp = zFailOp;	stencilZPassOp = zPassOp;    }    /**     * Set the stencil op. value     */    final void setStencilOp(int failOp, int zFailOp, int zPassOp) {	initStencilOp(failOp, zFailOp, zPassOp);		ArrayList arrList = new ArrayList(3);	arrList.add(new Integer(failOp));	arrList.add(new Integer(zFailOp));	arrList.add(new Integer(zPassOp));	sendMessage(STENCIL_OP_VALUES, arrList);    }    /**     * Retrieves the current stencil op. value     */    final void getStencilOp(int[] stencilOps) {	stencilOps[0] = stencilFailOp;	stencilOps[1] = stencilZFailOp;	stencilOps[2] = stencilZPassOp;    }    /**     * Initialize the stencil function value     */    final void initStencilFunction(int function, int refValue, int compareMask) {	stencilFunction = function;	stencilReferenceValue = refValue;	stencilCompareMask = compareMask;    }    /**     * Set the stencil function value     */    final void setStencilFunction(int function, int refValue, int compareMask) {	initStencilOp(function, refValue, compareMask);		ArrayList arrList = new ArrayList(3);	arrList.add(new Integer(function));	arrList.add(new Integer(refValue));	arrList.add(new Integer(compareMask));	sendMessage(STENCIL_FUNC, arrList);    }    /**     * Retrieves the current stencil op. value     */    final void getStencilFunction(int[] params) {	params[0] = stencilFunction;	params[1] = stencilReferenceValue;	params[2] = stencilCompareMask;    }    /**     * Initialize the stencil write mask     */    final void initStencilWriteMask(int mask) {	stencilWriteMask = mask;    }    /**     * Set the stencil write mask     */    final void setStencilWriteMask(int mask) {	initStencilWriteMask(mask);		sendMessage(STENCIL_WRITE_MASK, new Integer(mask));    }    /**     * Retrieves the current stencil write mask     */    final int getStencilWriteMask() {	return stencilWriteMask;    }        /**     * Updates the native context.     */    /**     * Updates the native context.     */    void updateNative(Canvas3D c3d,		      boolean depthBufferWriteEnableOverride,                      boolean depthBufferEnableOverride) {	Pipeline.getPipeline().updateRenderingAttributes(c3d.ctx, 		     depthBufferWriteEnableOverride, depthBufferEnableOverride,		     depthBufferEnable, depthBufferWriteEnable,  depthTestFunction,                     alphaTestValue, alphaTestFunction, ignoreVertexColors,		     rasterOpEnable, rasterOp, c3d.userStencilAvailable, stencilEnable, 		     stencilFailOp, stencilZFailOp, stencilZPassOp,		     stencilFunction, stencilReferenceValue, stencilCompareMask,		     stencilWriteMask  );    }   /**    * 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 {		RenderingAttributesRetained mirrorRa  		    = new RenderingAttributesRetained();		mirrorRa.set(this);                mirrorRa.source = source;		mirror = mirrorRa;	    }	} else {	    ((RenderingAttributesRetained) mirror).set(this);	    	}    }   /**    * Initializes a mirror object, point the mirror object to the retained    * object if the object is not editable    */    synchronized void initMirrorObject() {	((RenderingAttributesRetained)mirror).set(this);    }    /**     * Update the "component" field of the mirror object with the      *  given "value"     */    synchronized void updateMirrorObject(int component, Object value) {	RenderingAttributesRetained mirrorRa = (RenderingAttributesRetained)mirror;      	if ((component & DEPTH_ENABLE) != 0) {	    mirrorRa.depthBufferEnable = ((Boolean)value).booleanValue();	}	else if ((component & DEPTH_WRITE_ENABLE) != 0) {	    mirrorRa.depthBufferWriteEnable = ((Boolean)value).booleanValue();	}	else if ((component & DEPTH_TEST_FUNC) != 0) {	    mirrorRa.depthTestFunction = ((Integer)value).intValue();	}	else if ((component & ALPHA_TEST_VALUE) != 0) {	    mirrorRa.alphaTestValue = ((Float)value).floatValue();	}	else if ((component & ALPHA_TEST_FUNC) != 0) {	    mirrorRa.alphaTestFunction = ((Integer)value).intValue();	}	else if ((component & VISIBLE) != 0) {	    mirrorRa.visible = (((Boolean)value).booleanValue());	}	else if ((component & IGNORE_VCOLOR) != 0) {	    mirrorRa.ignoreVertexColors = (((Boolean)value).booleanValue());	}		else if ((component & RASTER_OP_ENABLE) != 0) {	    mirrorRa.rasterOpEnable = (((Boolean)value).booleanValue());	}		else if ((component & RASTER_OP_VALUE) != 0) {	    mirrorRa.rasterOp = (((Integer)value).intValue());	}	else if ((component & STENCIL_ENABLE) != 0) {	    mirrorRa.stencilEnable = (((Boolean)value).booleanValue());	}	else if ((component & STENCIL_OP_VALUES) != 0) {	    ArrayList arrlist = (ArrayList) value;	    mirrorRa.stencilFailOp = (((Integer)arrlist.get(0)).intValue());	    mirrorRa.stencilZFailOp = (((Integer)arrlist.get(1)).intValue());	    mirrorRa.stencilZPassOp = (((Integer)arrlist.get(2)).intValue());	}	else if ((component & STENCIL_FUNC) != 0) {	    ArrayList arrlist = (ArrayList) value;	    mirrorRa.stencilFunction = (((Integer)arrlist.get(0)).intValue());	    mirrorRa.stencilReferenceValue = (((Integer)arrlist.get(1)).intValue());	    mirrorRa.stencilCompareMask = (((Integer)arrlist.get(2)).intValue());	}	else if ((component & STENCIL_WRITE_MASK) != 0) {	    mirrorRa.stencilWriteMask = (((Integer)value).intValue());	}    }    boolean equivalent(RenderingAttributesRetained rr) {	return (this == rr) ||	       ((rr != null) &&		(rr.depthBufferEnable  == depthBufferEnable) &&		(rr.depthBufferWriteEnable == depthBufferWriteEnable) && 		(rr.alphaTestValue == alphaTestValue) &&		(rr.alphaTestFunction == alphaTestFunction) &&		(rr.visible == visible) &&		(rr.ignoreVertexColors == ignoreVertexColors) &&		(rr.rasterOpEnable == rasterOpEnable) &&		(rr.rasterOp == rasterOp) &&		(rr.depthTestFunction == depthTestFunction) &&		(rr.stencilEnable == stencilEnable) &&		(rr.stencilFailOp == stencilFailOp) &&		(rr.stencilZFailOp == stencilZFailOp) &&		(rr.stencilZPassOp == stencilZPassOp) &&		(rr.stencilFunction == stencilFunction) &&		(rr.stencilReferenceValue == stencilReferenceValue) &&		(rr.stencilCompareMask == stencilCompareMask) &&		(rr.stencilWriteMask == stencilWriteMask));    }    protected void set(RenderingAttributesRetained ra) {	super.set(ra);	depthBufferEnable  = ra.depthBufferEnable;	depthBufferWriteEnable = ra.depthBufferWriteEnable;	alphaTestValue = ra.alphaTestValue;	alphaTestFunction = ra.alphaTestFunction;	depthTestFunction = ra.depthTestFunction;	visible = ra.visible;	ignoreVertexColors = ra.ignoreVertexColors;	rasterOpEnable = ra.rasterOpEnable;	rasterOp = ra.rasterOp;	stencilEnable = ra.stencilEnable;	stencilFailOp = ra.stencilFailOp;	stencilZFailOp = ra.stencilZFailOp;	stencilZPassOp = ra.stencilZPassOp;	stencilFunction = ra.stencilFunction;	stencilReferenceValue = ra.stencilReferenceValue;	stencilCompareMask = ra.stencilCompareMask;	stencilWriteMask = ra.stencilWriteMask;    }        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.RENDERINGATTRIBUTES_CHANGED;	createMessage.universe = null;	createMessage.args[0] = this;	createMessage.args[1]= new Integer(attrMask);	createMessage.args[2] = attr;	//	System.err.println("changedFreqent1 = "+changedFrequent);	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;	    if (attrMask == VISIBLE)	        createMessage.threads |= J3dThread.UPDATE_GEOMETRY;	    createMessage.type = J3dMessage.RENDERINGATTRIBUTES_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);	}    }    // TODO : Need to handle stencil operation -- Chien    void handleFrequencyChange(int bit) {	int mask = 0;		if (bit == RenderingAttributes.ALLOW_ALPHA_TEST_VALUE_WRITE)	    mask = ALPHA_TEST_VALUE;	if( bit == RenderingAttributes.ALLOW_ALPHA_TEST_FUNCTION_WRITE)	    mask = ALPHA_TEST_FUNC;	if(bit == RenderingAttributes.ALLOW_VISIBLE_WRITE)	    mask = VISIBLE;	if (bit == RenderingAttributes.ALLOW_IGNORE_VERTEX_COLORS_WRITE)	    mask = IGNORE_VCOLOR;	if(bit == RenderingAttributes.ALLOW_RASTER_OP_WRITE)	    mask = RASTER_OP_ENABLE;	if(bit == RenderingAttributes.ALLOW_DEPTH_ENABLE_WRITE)	    mask = DEPTH_WRITE_ENABLE;	if( bit == RenderingAttributes.ALLOW_DEPTH_TEST_FUNCTION_WRITE)	    mask = DEPTH_TEST_FUNC;	if( bit == RenderingAttributes.ALLOW_STENCIL_ATTRIBUTES_WRITE)	    mask = DEPTH_TEST_FUNC;	if( bit == RenderingAttributes.ALLOW_DEPTH_TEST_FUNCTION_WRITE)	    mask = STENCIL_ENABLE | STENCIL_OP_VALUES | STENCIL_FUNC | 		STENCIL_WRITE_MASK;	if (mask != 0)	    setFrequencyChangeMask(bit, mask);	//	System.err.println("changedFreqent2 = "+changedFrequent);    }    }

⌨️ 快捷键说明

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