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

📄 geometryarrayretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
						for (i = initialColorIndex; i < validVertexCount; i++) {			    floatBufferRefColors.get(mirrorFloatRefColors[0], dstIndex, 3);			    mirrorFloatRefColors[0][dstIndex+3] = 1.0f;			    dstIndex += 4;			}		    }		    else {			srcIndex = initialColorIndex * 4;			dstIndex = initialColorIndex * 4;			floatBufferRefColors.position(srcIndex);			for (i = initialColorIndex; i < validVertexCount; i++) {			    floatBufferRefColors.get(mirrorFloatRefColors[0], dstIndex, 4); 			    dstIndex+= 4;			}		    }		}	    } else if ( byteBufferRefColors != null) {		vertexType |= CUB;		vertexType &= ~CF;		if (c4fAllocated == 0 && !force) {		    // NOTE: make sure mirrorUnsignedByteRefColors[0] is set right		    mirrorUnsignedByteRefColors[0] = null;		    mirrorColorAllocated &= ~CUB;;		}		else {		    if ((mirrorColorAllocated & CUB) == 0) {			mirrorUnsignedByteRefColors[0] = new byte[4 * vertexCount];			mirrorColorAllocated |= CUB;		    }		    		    byteBufferRefColors.rewind();		    if ((vertexFormat & GeometryArray.WITH_ALPHA) == 0) {			srcIndex = initialColorIndex * 3;			dstIndex = initialColorIndex * 4;			byteBufferRefColors.position(srcIndex);			for (i = initialColorIndex; i < validVertexCount; i++) {			    byteBufferRefColors.get(mirrorUnsignedByteRefColors[0],						    dstIndex, 3);			    mirrorUnsignedByteRefColors[0][dstIndex+3] = (byte)(255.0);			    dstIndex += 4;			}		    }		    else {			srcIndex = initialColorIndex * 4;			dstIndex = initialColorIndex * 4;			byteBufferRefColors.position(srcIndex);			for (i = initialColorIndex; i < validVertexCount; i++) {			    byteBufferRefColors.get(mirrorUnsignedByteRefColors[0], dstIndex, 4);			    dstIndex+= 4;			}		    }		} // end of else 	    }//end of else if ( byteBufferRefColors != null)	}//end of NIO BUFFER case		colorChanged = 0xffff;    }    void setupMirrorNormalPointer(int ntype) {	int i, index;	switch (ntype) { 	case NF: 	    if (floatRefNormals == null) {		if ((vertexType & NORMAL_DEFINED) == NF) {		    vertexType &= ~NF;		    mirrorFloatRefNormals = null;		    mirrorNormalAllocated = false;		}	    }	    else {		vertexType |= NF;		mirrorFloatRefNormals = floatRefNormals;		mirrorNormalAllocated = false;	    }	    break;	case N3F:	    if (v3fRefNormals == null) {		if ((vertexType & NORMAL_DEFINED) == N3F) {		    vertexType &= ~N3F;		}		return;	    }	    else {		vertexType |= N3F;	    }	    if (!mirrorNormalAllocated) { 		mirrorFloatRefNormals = new float[vertexCount * 3];		mirrorNormalAllocated = true;	    }	    	    index = initialNormalIndex * 3;	    for (i = initialNormalIndex; i < validVertexCount; i++) {		mirrorFloatRefNormals[index++] = v3fRefNormals[i].x;		mirrorFloatRefNormals[index++] = v3fRefNormals[i].y;		mirrorFloatRefNormals[index++] = v3fRefNormals[i].z;	    }	    break;	default:	    break;	}    }    void setupMirrorTexCoordPointer(int type) {	for (int i = 0; i < texCoordSetCount; i++) {	     doSetupMirrorTexCoordPointer(i, type);	}        validateTexCoordPointerType();    }        void setupMirrorTexCoordPointer(int texCoordSet, int type) {        doSetupMirrorTexCoordPointer(texCoordSet, type);        validateTexCoordPointerType();    }    // If all texCoord pointers are set to a non-null value, then set the    // texcoord type in the vertexType flag word, else clear the texcoord type    private void validateTexCoordPointerType() {        boolean allNonNull = true;        boolean allNull = true;        for (int i = 0; i < texCoordSetCount; i++) {            if (refTexCoords[i] == null) {                allNonNull = false;            } else {                allNull = false;            }        }        // Reset texCoordType if all references are null        if (allNull) {            texCoordType = 0;        }        // Copy texCoordType to vertexType if all references are non-null        vertexType &= ~TEXCOORD_DEFINED;        if (allNonNull) {            vertexType |= texCoordType;        }    }        private void doSetupMirrorTexCoordPointer(int texCoordSet, int type) {	int i, index;        switch (type) { 	case TF:            texCoordType = TF;            mirrorRefTexCoords[texCoordSet] = refTexCoords[texCoordSet];	    break;        case T2F:            texCoordType = T2F;	    t2fRefTexCoords = (TexCoord2f[])refTexCoords[texCoordSet];	    if (t2fRefTexCoords == null) {                mirrorRefTexCoords[texCoordSet] = null;		break;	    }            mirrorFloatRefTexCoords = (float[])mirrorRefTexCoords[texCoordSet];            if (mirrorFloatRefTexCoords != null) {                if (mirrorFloatRefTexCoords.length < (vertexCount * 2))                    mirrorRefTexCoords[texCoordSet] =                        mirrorFloatRefTexCoords = new float[vertexCount * 2];            }            else {                mirrorRefTexCoords[texCoordSet] =                        mirrorFloatRefTexCoords = new float[vertexCount * 2];            }	    	    index = initialTexCoordIndex[texCoordSet] * 2;	    	    for (i = initialTexCoordIndex[texCoordSet]; i < validVertexCount; i++) {		mirrorFloatRefTexCoords[index++] = t2fRefTexCoords[i].x;		mirrorFloatRefTexCoords[index++] = t2fRefTexCoords[i].y;	    }	    break;	case T3F:            texCoordType = T3F;	    t3fRefTexCoords = (TexCoord3f[])refTexCoords[texCoordSet];            if (t3fRefTexCoords == null) {                mirrorRefTexCoords[texCoordSet] = null;		break;	    }            mirrorFloatRefTexCoords = (float[])mirrorRefTexCoords[texCoordSet];            if (mirrorFloatRefTexCoords != null) {                if (mirrorFloatRefTexCoords.length < (vertexCount * 3))                    mirrorRefTexCoords[texCoordSet] =                        mirrorFloatRefTexCoords = new float[vertexCount * 3];            }            else {                mirrorRefTexCoords[texCoordSet] =                    mirrorFloatRefTexCoords = new float[vertexCount * 3];            }	    index =  initialTexCoordIndex[texCoordSet] * 3;	    for (i = initialTexCoordIndex[texCoordSet]; i < validVertexCount; i++) {		mirrorFloatRefTexCoords[index++] = t3fRefTexCoords[i].x;		mirrorFloatRefTexCoords[index++] = t3fRefTexCoords[i].y;		mirrorFloatRefTexCoords[index++] = t3fRefTexCoords[i].z;	    }	    break;	default:	    break;	}    }    void setupMirrorVertexAttrPointer(int type) {        for (int i = 0; i < vertexAttrCount; i++) {            doSetupMirrorVertexAttrPointer(i, type);        }        validateVertexAttrPointerType();    }        void setupMirrorVertexAttrPointer(int vertexAttrNum, int type) {        doSetupMirrorVertexAttrPointer(vertexAttrNum, type);        validateVertexAttrPointerType();    }        // If all vertex attr pointers are set to a non-null value, then set the    // vertex attr type in the vertexType flag word, else clear the    // vertex attr type    private void validateVertexAttrPointerType() {        boolean allNonNull = true;        boolean allNull = true;        if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) == 0) {            for (int i = 0; i < vertexAttrCount; i++) {                if (floatRefVertexAttrs[i] == null) {                    allNonNull = false;                } else {                    allNull = false;                }            }        } else {            for (int i = 0; i < vertexAttrCount; i++) {                if (nioFloatBufferRefVertexAttrs[i] == null) {                    allNonNull = false;                } else {                    allNull = false;                }            }        }        // Reset vertexAttrType if all references are null        if (allNull) {            vertexAttrType = 0;        }        // Copy vertexAttrType to vertexType if all references are non-null        vertexType &= ~VATTR_DEFINED;        if (allNonNull) {            vertexType |= vertexAttrType;        }    }    private void doSetupMirrorVertexAttrPointer(int vertexAttrNum, int type) {        switch (type) {        case AF:            vertexAttrType = AF;            mirrorFloatRefVertexAttrs[vertexAttrNum] =                floatRefVertexAttrs[vertexAttrNum];            break;        default:            break;        }    }    void createGeometryArrayData(int vertexCount, int vertexFormat) {	if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {	    createGeometryArrayData(vertexCount, vertexFormat, 1, 				    defaultTexCoordSetMap);	} else {	    createGeometryArrayData(vertexCount, vertexFormat, 0, null);	}    }    void createGeometryArrayData(int vertexCount, int vertexFormat,				 int texCoordSetCount, int[] texCoordSetMap) {	createGeometryArrayData(vertexCount, vertexFormat,				texCoordSetCount, texCoordSetMap,				0, null);    }    void createGeometryArrayData(int vertexCount, int vertexFormat,				 int texCoordSetCount, int[] texCoordSetMap,				 int vertexAttrCount, int[] vertexAttrSizes) {	this.vertexFormat = vertexFormat;	this.vertexCount = vertexCount;	this.validVertexCount = vertexCount;	this.texCoordSetCount = texCoordSetCount;	if (texCoordSetMap == null) {	    this.texCoordSetMap = null;	}	else {	    this.texCoordSetMap = (int[])texCoordSetMap.clone();	}        this.vertexAttrCount = vertexAttrCount;	if (vertexAttrSizes == null) {	    this.vertexAttrSizes = null;	}	else {	    this.vertexAttrSizes = (int[])vertexAttrSizes.clone();	}        this.vertexAttrStride = this.vertexAttrStride();	this.stride = this.stride();	this.vertexAttrOffsets = this.vertexAttrOffsets();	this.texCoordSetMapOffset = this.texCoordSetMapOffset();	this.textureOffset = this.textureOffset();	this.colorOffset = this.colorOffset();	this.normalOffset = this.normalOffset();	this.coordinateOffset = this.coordinateOffset();	if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) {	    this.vertexData = new float[this.vertexCount * this.stride];	}	else { // By reference geometry	    this.vertexData = null;            if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {                this.mirrorRefTexCoords = new Object[texCoordSetCount];                this.refTexCoords = new Object[texCoordSetCount]; // keep J3DBufferImp object in nio buffer case		if((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0 )		    this.refTexCoordsBuffer = new Object[texCoordSetCount]; // keep J3DBuffer object	    }            if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {                this.floatRefVertexAttrs = new float[vertexAttrCount][];                this.mirrorFloatRefVertexAttrs = new float[vertexAttrCount][];		if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) {		    this.vertexAttrsRefBuffer = new J3DBuffer[vertexAttrCount];                    this.floatBufferRefVertexAttrs = new FloatBufferWrapper[vertexAttrCount];                    this.nioFloatBufferRefVertexAttrs = new Object[vertexAttrCount];                }	    }	}        if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) {            this.initialTexCoordIndex = new int[texCoordSetCount];        }        if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {            this.initialVertexAttrIndex = new int[vertexAttrCount];        }	noAlpha = ((vertexFormat & GeometryArray.WITH_ALPHA) == 0);	lastAlpha[0] = 1.0f;    }    void setVertexFormat(boolean useAlpha, boolean ignoreVC, Context ctx) {	Pipeline.getPipeline().setVertexFormat(ctx,                this, vertexFormat, useAlpha, ignoreVC);    }        void disableGlobalAlpha(Context ctx, boolean useAlpha, boolean ignoreVC) {	// If global alpha was turned on, then disable it	Pipeline.getPipeline().disableGlobalAlpha(ctx,                this, vertexFormat, useAlpha, ignoreVC);    }    float[] updateAlphaInFloatRefColors(Canvas3D cv, int screen, float alpha) {	//System.err.println("updateAlphaInFloatRefColors  screen = " + screen +	//		   " alpha " + alpha );		// no need to update alpha values if canvas supports global alpha	if (cv.supportGlobalAlpha()) {	    cv.setGlobalAlpha(cv.ctx, alpha);	    return mirrorFloatRefColors[0];	}	// update alpha only if vertex format includes alpha	if (((vertexFormat | c4fAllocated) & GeometryArray.WITH_ALPHA) == 0)	    return mirrorFloatRefColors[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 mirrorFloatRefColors != null;        assert mirrorFloatRefColors.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;	}	//System.err.println("updateAlphaInFloatRefColors screen is " + screen 	//		     + " mirrorFloatRefColors.length " + 	//		     mirrorFloatRefColors.length);	// allocate a copy of the color data for the screen if needed.	// this piece of code is only for multi-screens case	if (mirrorFloatRefColors.length <= screen) {	    float[][] cfData = new float[screen + 1][];	    for (int i = 0; i < mirrorFloatRefColors.length; i++) {		cfData[i] = mirrorFloatRefColors[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 = mirrorFloatRefColors.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];            }            mirrorFloatRefColors = cfData;            // Issue 113 - since we copied the data from screen 0, we don't need            // to do any further special processing.

⌨️ 快捷键说明

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