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

📄 geometryarrayretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	}        assert lastAlpha[screen] >= 0.0;	/*	  System.err.println("updateAlphaInFloatRefColors ** : lastAlpha[screen] " +			     lastAlpha[screen]);	  	  System.err.println("((colorChanged & (1<<screen)) == 0) " +			     ((colorChanged & (1<<screen)) == 0));	*/	if ((colorChanged & (1<<screen)) == 0) {	    // color data is not modified	    if (Math.abs(lastAlpha[screen] - alpha) <= EPSILON) {		// and if alpha is the same as the last one,		// just return the data		//System.err.println("updateAlphaInFloatRefColors 0 : alpha is the same as the last one " + alpha);	        return mirrorFloatRefColors[screen];	    } else {			// if alpha is different, update the alpha values		//System.err.println("updateAlphaInFloatRefColors 1 : alpha is different, update the alpha values " + alpha);		float m = alpha / lastAlpha[screen];		float[] cdata = mirrorFloatRefColors[screen];				// We've to traverse the whole due to BugId : 4676483		for (int i = 0, j = 0; i < vertexCount; i++, j+=4) {	    	    cdata[j+3] = cdata[j+3] * m;		}	    }	} else {	    // color data is modified	    if (screen == 0) {				// just update alpha values since screen 0 data is		// already updated in setupMirrorColorPointer				//System.err.println("updateAlphaInFloatRefColors 2 : just update alpha = " + alpha);				float[] cdata = mirrorFloatRefColors[screen];				// This part is also incorrect due to BugId : 4676483		// But traversing the whole array doesn't help either, as there		// isn't a mechanism to indicate the the alpha component has		// not changed by user.		int j = initialColorIndex * 4;		for (int i = initialColorIndex; i < validVertexCount; i++, j+=4) {	    	    cdata[j+3] = cdata[j+3] * alpha;		}	    } else {		// update color values from screen 0 data		//System.err.println("updateAlphaInFloatRefColors 3 : update color values from screen 0 data " + alpha);		float m;		if ((colorChanged & 1) == 0) {		    // alpha is up to date in screen 0		    m = alpha / lastAlpha[0];		} else {		    m = alpha;		}		float[] sdata = mirrorFloatRefColors[0];		float[] cdata = mirrorFloatRefColors[screen];		int j = initialColorIndex * 4;		for (int i = initialColorIndex; i < validVertexCount; i++) {		    cdata[j] = sdata[j++];		    cdata[j] = sdata[j++];		    cdata[j] = sdata[j++];		    cdata[j] = sdata[j++] * m;		}	    }	}	lastAlpha[screen] = alpha;	colorChanged &= ~(1 << screen);	dirtyFlag |= COLOR_CHANGED;	return mirrorFloatRefColors[screen];    }    byte[] updateAlphaInByteRefColors(Canvas3D cv, int screen, float alpha) {	/*	  System.err.println("updateAlphaInByteRefColors  screen = " + screen +	  " alpha " + alpha );	*/	// no need to update alpha values if canvas supports global alpha		if (cv.supportGlobalAlpha()) { 	    cv.setGlobalAlpha(cv.ctx, alpha);	    return mirrorUnsignedByteRefColors[0];	}	// update alpha only if vertex format includes alpha	if (((vertexFormat | c4fAllocated) & GeometryArray.WITH_ALPHA) == 0)	    return mirrorUnsignedByteRefColors[0];	// if alpha is smaller than EPSILON, set it to EPSILON, so that	// even if alpha is equal to 0, we will not completely lose	// the original alpha value	if (alpha <= EPSILON) {	    alpha = (float)EPSILON;	}        assert lastAlpha != null;        assert mirrorUnsignedByteRefColors != null;        assert mirrorUnsignedByteRefColors.length == lastAlpha.length;	// Issue 113 - reallocate lastAlpha array if needed, but no need to        // update the values here	if (lastAlpha.length <= screen) {	    float[] la = new float[screen + 1];	    for (int i = 0; i < lastAlpha.length; i++) {		la[i] = lastAlpha[i];	    }	    lastAlpha = la;	}	// allocate a copy of the color data for the screen if needed.	// this piece of code is only for multi-screens case	if (mirrorUnsignedByteRefColors.length <= screen) {	    byte[][] cbData = new byte[screen + 1][];	    for (int i = 0; i < mirrorUnsignedByteRefColors.length; i++) {		cbData[i] = mirrorUnsignedByteRefColors[i];	    }            // Issue 113 - allocate entries for [oldSize..screen];            // copy cbData[0] to cbData[oldsize..screen-1] and            // lastAlpha[0] to lastAlpha[oldsize..screen-1].            for (int i = mirrorUnsignedByteRefColors.length; i < screen+1; i++) {                cbData[i] = new byte[4 * vertexCount];                System.arraycopy(cbData[0], 0, cbData[i], 0, 4 * vertexCount);                lastAlpha[i] = lastAlpha[0];            }            mirrorUnsignedByteRefColors = cbData;            // Issue 113 - since we copied the data from screen 0, we don't need            // to do any further special processing.	}        assert lastAlpha[screen] >= 0.0;        /*	System.err.println("updateAlphaInByteRefColors ## : lastAlpha[screen] " +			   lastAlpha[screen]);		System.err.println("((colorChanged & (1<<screen)) == 0) " +			   ((colorChanged & (1<<screen)) == 0));	*/        if ((colorChanged & (1<<screen)) == 0) {	                // color data is not modified            if (Math.abs(lastAlpha[screen] - alpha) <= EPSILON) {                // and if alpha is the same as the last one,                // just return the data		//System.err.println("updateAlphaInByteRefColors 0 : alpha is the same as the last one " + alpha);                return mirrorUnsignedByteRefColors[screen];            } else {                // if alpha is different, update the alpha values		//System.err.println("updateAlphaInByteRefColors 1 : alpha is different, update the alpha values " + alpha);		                float m = alpha / lastAlpha[screen];                byte[] cdata = mirrorUnsignedByteRefColors[screen];		// We've to traverse the whole due to BugId : 4676483		for (int i = 0, j = 0; i < vertexCount; i++, j+=4) {                    cdata[j+3] = (byte)( ((int)cdata[j+3] & 0xff) * m);                }            }        } else {            // color data is modified            if (screen == 0) {		//System.err.println("updateAlphaInByteRefColors 2 : just update alpha =" + alpha);		                // just update alpha values since screen 0 data is                // already updated in setupMirrorColorPointer                byte[] cdata = mirrorUnsignedByteRefColors[screen];				// This part is also incorrect due to BugId : 4676483		// But traversing the whole array doesn't help either, as there		// isn't a mechanism to indicate the the alpha component has		// not changed by user.		int j = initialColorIndex * 4;		for (int i = initialColorIndex; i < validVertexCount; i++, j+=4) {                    cdata[j+3] = (byte)(((int)cdata[j+3] & 0xff) * alpha);                }            } else {                // update color values from screen 0 data                float m;		//System.err.println("updateAlphaInByteRefColors 3 : update color values from screen 0 data " + alpha);                if ((colorChanged & 1) == 0) {                    // alpha is up to date in screen 0                    m = alpha / lastAlpha[0];                } else {                    m = alpha;                }		                byte[] sdata = mirrorUnsignedByteRefColors[0];                byte[] cdata = mirrorUnsignedByteRefColors[screen];		int j = initialColorIndex * 4;		for (int i = initialColorIndex; i < validVertexCount; i++) {		    cdata[j] = sdata[j++];		    cdata[j] = sdata[j++];		    cdata[j] = sdata[j++];		    cdata[j] = (byte)(((int)sdata[j++]& 0xff) * m);                }            }        }        lastAlpha[screen] = alpha;        colorChanged &= ~(1 << screen);	dirtyFlag |= COLOR_CHANGED;        return mirrorUnsignedByteRefColors[screen];    }    Object[] updateAlphaInVertexData(Canvas3D cv, int screen, float alpha) {	Object[] retVal = new Object[2];	retVal[0] = Boolean.FALSE;	// no need to update alpha values if canvas supports global alpha	if (cv.supportGlobalAlpha()) {	    cv.setGlobalAlpha(cv.ctx, alpha);	    retVal[1] = vertexData;	    return retVal;	}	// update alpha only if vertex format includes alpha	if ((vertexFormat & GeometryArray.COLOR) == 0) {	    retVal[1] = vertexData;	    return retVal;	}	// if alpha is smaller than EPSILON, set it to EPSILON, so that	// even if alpha is equal to 0, we will not completely lose	// the original alpha value	if (alpha <= EPSILON) {	    alpha = (float)EPSILON;	}	retVal[0] = Boolean.TRUE;        assert lastAlpha != null;        assert mvertexData == null || mvertexData.length == lastAlpha.length;	// Issue 113 - reallocate lastAlpha array if needed, but no need to        // update the values here	if (lastAlpha.length <= screen) {	    float[] la = new float[screen + 1];	    for (int i = 0; i < lastAlpha.length; i++) {		la[i] = lastAlpha[i];	    }	    lastAlpha = la;	}	// allocate a copy of the vertex data for the screen if needed.	// Note that a copy operation only happens in the multi-screens case.        // We always use the existing vertexData for screen 0.	if (mvertexData == null || mvertexData.length <= screen) {	    float[][] cfData = new float[screen + 1][];            int oldSize = 1;	    if (mvertexData != null) {                oldSize = mvertexData.length;	        for (int i = 0; i < mvertexData.length; i++) {		    cfData[i] = mvertexData[i];		}	    }	    if (cfData[0] == null)  {		cfData[0] = vertexData;	    }            // Issue 113 - allocate entries for [oldSize..screen];            // copy cfData[0] to cfData[oldsize..screen-1] and            // lastAlpha[0] to lastAlpha[oldsize..screen-1].            if (screen > 0) {                for (int i = oldSize; i < screen+1; i++) {                    cfData[i] = new float[stride * vertexCount];                    System.arraycopy(cfData[0], 0, cfData[i], 0,                            stride * vertexCount);                    lastAlpha[i] = lastAlpha[0];                }            }            mvertexData = cfData;            // Issue 113 - since we copied the data from screen 0, we don't need            // to do any further special processing.	}                assert lastAlpha[screen] >= 0.0;	if ((colorChanged & (1<<screen)) == 0) {	    // color data is not modified	    if (Math.abs(lastAlpha[screen] - alpha) <= EPSILON) {		// and if alpha is the same as the last one,		// just return the data		retVal[1] = mvertexData[screen];	        return retVal;	    } else {		// if alpha is different, update the alpha values		float m = alpha / lastAlpha[screen];		float[] cdata = mvertexData[screen];		for (int i = 0, j = colorOffset; i < vertexCount; 					i++, j+=stride) {	    	    cdata[j+3] *= m;		}	    }	} else {	    // color data is modified	    if (screen == 0) {		// just update alpha values since screen 0 data is		// already updated in setupMirrorColorPointer		float[] cdata = mvertexData[screen];		double m = alpha / lastAlpha[0];	       		for (int i = 0, j = colorOffset; i < vertexCount; 					i++, j+=stride) {	    	    cdata[j+3] *= m;		}	    } else {		// update color values from screen 0 data		float m = alpha / lastAlpha[0];		float[] sdata = mvertexData[0];		float[] cdata = mvertexData[screen];		for (int i = 0, j = colorOffset; i < vertexCount; 					i++, j+=stride) {		    System.arraycopy(sdata, j, cdata, j, 3);		    cdata[j+3] = sdata[j+3] * m;		}	    }	}	lastAlpha[screen] = alpha;	colorChanged &= ~(1 << screen);	dirtyFlag |= COLOR_CHANGED;	retVal[1] = mvertexData[screen];	return retVal;    }    Object[] updateAlphaInInterLeavedData(Canvas3D cv, int screen, float alpha) {	Object[] retVal = new Object[2];	retVal[0] = Boolean.FALSE;	// no need to update alpha values if canvas supports global alpha	if (cv.supportGlobalAlpha()) {	    cv.setGlobalAlpha(cv.ctx, alpha);	    retVal[1] = null;	    return retVal;	}	// update alpha only if vertex format includes alpha	if (((vertexFormat | c4fAllocated) & GeometryArray.WITH_ALPHA) == 0) {	    retVal[1] = mirrorInterleavedColorPointer[0];	    return retVal;	}        int coffset = initialColorIndex << 2; // Each color is 4 floats	// if alpha is smaller than EPSILON, set it to EPSILON, so that	// even if alpha is equal to 0, we will not completely lose	// the original alpha value	if (alpha <= EPSILON) {	    alpha = (float)EPSILON;	}	retVal[0] = Boolean.TRUE;        assert lastAlpha != null;        assert mirrorInterleavedColorPointer != null;        assert mirrorInterleavedColorPointer.length == lastAlpha.length;	// Issue 113 - reallocate lastAlpha array if needed, but no need to        // update the values here	if (lastAlpha.length <= screen) {	    float[] la = new float[screen + 1];	    for (int i = 0; i < lastAlpha.length; i++) {		la[i] = lastAlpha[i];	    }	    lastAlpha = la;	}	// allocate a copy of the vertex data for the screen if needed.	// this piece of code is only for multi-screens case	if (mirrorInterleavedColorPointer.length <= screen) {	    float[][] cfData = new float[screen + 1][];	    for (int i = 0; i < mirrorInterleavedColorPointer.length; i++) {		cfData[i] = mirrorInterleavedColorPointer[i];	    }            // Issue 113 - allocate entries for [oldSize..screen];            // copy cfData[0] to cfData[oldsize..screen-1] and            // lastAlpha[0] to lastAlpha[oldsize..screen-1].            for (int i = mirrorInterleavedColorPointer.length; i < screen+1; i++) {                cfData[i] = new float[4 * vertexCount];                System.arraycopy(cfData[0], 0, cfData[i], 0, 4 * vertexCount);                lastAlpha[i] = lastAlpha[0];            }	    mirrorInterleavedColorPointer = cfData;            // Issue 113 - since we copied the data from screen 0, we don't need            // to do any further special processing.	}        assert lastAlpha[screen] >= 0.0; 

⌨️ 快捷键说明

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