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

📄 rendermolecule.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        useAlpha = alphaBlend || alphaTest || textureBlend;	if( !oldUseAlpha && useAlpha) {	    GeometryArrayRetained geo = null;	    if(vertexArrayRenderAtomList != null)		geo = (GeometryArrayRetained)vertexArrayRenderAtomList.geometry();	    if(geo != null) {		if (!(geo instanceof IndexedGeometryArrayRetained) ||		    ((geo.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0)) {		    renderBin.addGeometryToLockList(geo);		    // Add the geometry to the dirty list only if the geometry is by		    // reference and there is color and we need to use alpha		    // Issue 113 - ignore multiScreen		    if ((( geo.vertexFormat & GeometryArray.BY_REFERENCE)!=0) &&			(geo.c4fAllocated == 0) && 			((geo.vertexFormat & GeometryArray.COLOR) != 0) &&			useAlpha) {			renderBin.addDirtyReferenceGeometry(geo);		    }		}	    }	}    }    final boolean isSwitchOn() { 	// The switchOn status of the entire RM can be determined	// by the switchOn status of any renderAtoms below.        // This is possible because renderAtoms generated from a common        // switch branch are placed in the same renderMolecule	if (primaryRenderAtomList != null) {	    return primaryRenderAtomList.renderAtom.geometryAtom.		source.switchState.lastSwitchOn;	} 		if (vertexArrayRenderAtomList != null) {	    return vertexArrayRenderAtomList.renderAtom.geometryAtom.		source.switchState.lastSwitchOn;	    	} 	if (separateDlistRenderAtomList != null) {	    return separateDlistRenderAtomList.renderAtom.geometryAtom.		source.switchState.lastSwitchOn;	}	return false;    }    /**     * Renders this RenderMolecule     */    boolean render(Canvas3D cv, int pass, int dirtyBits) {        assert pass < 0;		boolean isVisible = isSwitchOn();		if (!isVisible) {		    return false;	}	isVisible = false;        // include this LightBin to the to-be-updated list in Canvas        cv.setStateToUpdate(Canvas3D.RENDERMOLECULE_BIT, this);	boolean modeSupportDL = true;	isNonUniformScale = !trans[localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD]].isCongruent();	    	// We have to dynamically switch between using displaymode	// mode or not instead of decide in canBeInDisplayList(), 	// since polygonAttribute can be change by editable Appearance	// or editable polygonAttribute which mode we can't take	// advantage of display list mode in many cases just because	// there are three special cases to handle.	// Another case for punting to vertex array is if pass specifies	// something other than -1. That means, we are in the	// multi-texturing multi-pass case. Then we'll use vertex array	// instead. Or the length of the texCoordSetMap is greater than	// the number of texture units supported by the Canvas, then	// we'll have to punt to vertex array as well.	if ((pass != TextureBin.USE_DISPLAYLIST) ||		    (texCoordSetMapLen > cv.maxTexCoordSets) ||	    (VirtualUniverse.mc.isD3D() &&	      (((definingPolygonAttributes != null) &&		((isQuadGeometryArray &&		  (definingPolygonAttributes.polygonMode ==		   PolygonAttributes.POLYGON_LINE))||		 (isTriGeometryArray &&		  (definingPolygonAttributes.polygonMode ==		   PolygonAttributes.POLYGON_POINT)))) || 	       cv.texLinearMode))) {	    modeSupportDL = false;	}	/*	System.err.println("texCoord " + texCoordSetMapLen + " " +			   cv.maxTexCoordSets + " " + modeSupportDL);	System.err.println("primaryMoleculeType = "+primaryMoleculeType+" primaryRenderAtomList ="+primaryRenderAtomList+" separateDlistRenderAtomList ="+separateDlistRenderAtomList+" vertexArrayRenderAtomList ="+vertexArrayRenderAtomList);	*/	// Send down the model view only once, if its not of type text	if ((primaryMoleculeType & (TEXT3D_MOLECULE| ORIENTEDSHAPE3D_MOLECULE)) == 0) {	    if (primaryRenderAtomList != null) {		if ((primaryRenderMethod != VirtualUniverse.mc.getDisplayListRenderMethod()) ||		    modeSupportDL) {		    if (primaryMoleculeType != SEPARATE_DLIST_PER_RINFO_MOLECULE) {			if (primaryRenderMethod.render(this, cv, primaryRenderAtomList,dirtyBits))			    isVisible = true;		    }		    else {			if (renderBin.dlistRenderMethod.renderSeparateDlistPerRinfo(this, cv, primaryRenderAtomList,dirtyBits))			    isVisible = true;					    }		} else { 		    if(cachedVertexArrayRenderMethod.render(this, cv,							    primaryRenderAtomList, 							    dirtyBits)) {			isVisible = true;		    }		}	    }	}	else {	// TEXT3D or ORIENTEDSHAPE3D    	    if (primaryRenderAtomList != null) {		if(primaryRenderMethod.render(this, cv, primaryRenderAtomList,					      dirtyBits)) {		    isVisible = true;		}	    }	}		if (separateDlistRenderAtomList != null) {            if (modeSupportDL) {                if(renderBin.dlistRenderMethod.renderSeparateDlists(this, cv,                        separateDlistRenderAtomList,                        dirtyBits)) {                    isVisible = true;                }			    } else {		if(cachedVertexArrayRenderMethod.render(this, cv, 							separateDlistRenderAtomList,							dirtyBits)) {		    isVisible = true;		}	    }	    	}		// XXXX: In the case of independent primitives such as quads,	// it would still be better to call multi draw arrays	if (vertexArrayRenderAtomList != null) {	    if(cachedVertexArrayRenderMethod.render(this, cv, 						    vertexArrayRenderAtomList,						    dirtyBits)) {		isVisible = true;	    }	}	return isVisible;    }        void updateAttributes(Canvas3D cv, int dirtyBits) {	boolean setTransparency = false; 	// If this is a beginning of a frame OR diff. geometryType 	// then reload everything for the first rendermolecule	//	System.err.println("updateAttributes");	int bitMask = geometryType | Canvas3D.MATERIAL_DIRTY|	    Canvas3D.COLORINGATTRS_DIRTY|	    Canvas3D.TRANSPARENCYATTRS_DIRTY;		// If beginning of a frame then reload all the attributes	if ((cv.canvasDirty & bitMask) != 0) {	    if ((geometryType & SURFACE) != 0) {		if (definingPolygonAttributes == null) {		    cv.resetPolygonAttributes(cv.ctx);		} else {		    definingPolygonAttributes.updateNative(cv.ctx);		}	    		cv.polygonAttributes = polygonAttributes;	    } 	    if ((geometryType & LINE) != 0) {		if (definingLineAttributes == null) {		    cv.resetLineAttributes(cv.ctx);		} else {		    definingLineAttributes.updateNative(cv.ctx);		}		cv.lineAttributes = lineAttributes;	    } 	    if ((geometryType & POINT) != 0) {		if (definingPointAttributes == null) {		    cv.resetPointAttributes(cv.ctx);		} else {		    definingPointAttributes.updateNative(cv.ctx);		}		cv.pointAttributes = pointAttributes;	    }	    if (definingTransparency == null) {		cv.resetTransparency(cv.ctx, geometryType,				     polygonMode, lineAA, pointAA);	    } else {		definingTransparency.updateNative(cv.ctx,						  alpha, geometryType,						  polygonMode, lineAA, 						  pointAA);	    }	    cv.transparency = transparency;	    	    if (definingMaterial == null) {		cv.updateMaterial(cv.ctx, red, green, blue, alpha);	    } else {		definingMaterial.updateNative(cv.ctx,					      red, green, blue, alpha, 					      enableLighting);	    }	    cv.material = material;	    cv.enableLighting = enableLighting;	    if (definingColoringAttributes == null) {		cv.resetColoringAttributes(cv.ctx, red, green, blue, 					   alpha, enableLighting);	    } else {		definingColoringAttributes.updateNative(cv.ctx,							dRed,							dBlue,							dGreen,alpha, 							enableLighting);	    }	    cv.coloringAttributes = coloringAttributes;            // Use Object instead of AppearanceRetained class for            // state caching optimation for memory performance            cv.appHandle = appHandle;	}        // assuming neighbor dirty bits ORing is implemented        // note that we need to set it to ALL_DIRTY at the        // begining of textureBin first and only do the ORing        // whenever encounter a non-visible rm	else if (cv.renderMolecule != this && (dirtyBits != 0)) {	    	    // no need to download states if appHandle is the same	    if (cv.appHandle != appHandle) {				// Check if the attribute bundle in the canvas is the same		// as the attribute bundle in this renderMolecule				if (cv.transparency != transparency && 		    (dirtyBits & TRANSPARENCY_DIRTY) != 0) {		    setTransparency = true;		    if (definingTransparency == null) {						cv.resetTransparency(cv.ctx, geometryType,					     polygonMode, lineAA, pointAA);		    } else {		      			definingTransparency.updateNative(cv.ctx, alpha, 							  geometryType, polygonMode, 							  lineAA, pointAA);		    }		    cv.transparency = transparency;		}	    				if (setTransparency || ((cv.enableLighting != enableLighting) || 					(cv.material != material) && 					(dirtyBits & MATERIAL_DIRTY) != 0)){ 		    if (definingMaterial == null) {						cv.updateMaterial(cv.ctx, red, green, blue, alpha);		    } else {						definingMaterial.updateNative(cv.ctx, red, green, 						      blue, alpha, 						      enableLighting);		    }		    cv.material = material;		    cv.enableLighting = enableLighting;		}				 				if (((geometryType & SURFACE) != 0) &&		    cv.polygonAttributes != polygonAttributes &&		    (dirtyBits & POLYGONATTRS_DIRTY) != 0) {		    		    if (definingPolygonAttributes == null) {			cv.resetPolygonAttributes(cv.ctx);		    } else {			definingPolygonAttributes.updateNative(cv.ctx);		    }		    cv.polygonAttributes = polygonAttributes;		}				if (((geometryType & LINE) != 0) &&		    cv.lineAttributes != lineAttributes &&		    (dirtyBits & LINEATTRS_DIRTY) != 0) {		    		    if (definingLineAttributes == null) {			cv.resetLineAttributes(cv.ctx);		    } else {			definingLineAttributes.updateNative(cv.ctx);		    }		    cv.lineAttributes = lineAttributes;		}				if (((geometryType & POINT) != 0) &&		    cv.pointAttributes != pointAttributes &&		    (dirtyBits & POINTATTRS_DIRTY) != 0) {		    		    if (definingPointAttributes == null) {			cv.resetPointAttributes(cv.ctx);		    } else {			definingPointAttributes.updateNative(cv.ctx);		    }		    cv.pointAttributes = pointAttributes;		}				// Use Object instead of AppearanceRetained class for		// state caching optimation for memory performance		cv.appHandle = appHandle;	    }	    // no state caching for color attrs, which can also be 	    // changed by primitive with colors	    if(setTransparency || ((dirtyBits & COLORINGATTRS_DIRTY) != 0)) {				if (definingColoringAttributes == null) {		    cv.resetColoringAttributes(cv.ctx,					       red, green, blue, alpha,					       enableLighting);		} else {		    definingColoringAttributes.updateNative(cv.ctx,							    dRed,							    dBlue, 							    dGreen,alpha, 							    enableLighting);		    		}                cv.coloringAttributes = coloringAttributes;	    }	    	    	}		if ((primaryMoleculeType & (TEXT3D_MOLECULE| ORIENTEDSHAPE3D_MOLECULE)) == 0) {	    /* System.err.println("updateAttributes  setModelViewMatrix (1)"); */	    Transform3D modelMatrix =	        trans[localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD]];	    	    if (cv.modelMatrix != modelMatrix) {		/* System.err.println("updateAttributes  setModelViewMatrix (2)"); */		cv.setModelViewMatrix(cv.ctx, cv.vworldToEc.mat, 				      modelMatrix);	    }	}		cv.canvasDirty &= ~bitMask;	cv.renderMolecule = this;    }	    void transparentSortRender(Canvas3D cv, int pass, TransparentRenderingInfo tinfo) {        assert pass < 0;	Transform3D modelMatrix =	    trans[localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD]];        // include this LightBin to the to-be-updated list in Canvas        cv.setStateToUpdate(Canvas3D.RENDERMOLECULE_BIT, this);			boolean modeSupportDL = true;	    	// We have to dynamically switch between using displaymode	// mode or not instead of decide in canBeInDisplayList(), 	// since polygonAttribute can be change by editable Appearance	// or editable polygonAttribute which mode we can't take	// advantage of display list mode in many cases just because	// there are three special cases to handle.        // Another case for punting to vertex array is if pass specifies        // something other than -1. That means, we are in the        // multi-texturing multi-pass case. Then we'll use vertex array        // instead.	if ((pass != TextureBin.USE_DISPLAYLIST) ||	    (texCoordSetMapLen > cv.maxTexCoordSets) ||                       	     (VirtualUniverse.mc.isD3D() &&			     (((definingPolygonAttributes != null) &&			       ((isQuadGeometryArray &&				 (definingPolygonAttributes.polygonMode ==				  PolygonAttributes.POLYGON_LINE)) ||				(isTriGeometryArray &&				 (definingPolygonAttributes.polygonMode ==				  PolygonAttributes.POLYGON_POINT))))			      || 			      cv.texLinearMode))) {	    modeSupportDL = false;	}	//	System.err.println("r.isOpaque = "+isOpaque+" rinfo = "+tinfo.rInfo+" groupType = "+tinfo.rInfo.groupType);	// Only support individual dlist or varray	// If this rInfo is a part of a bigger dlist, render as VA	// XXXX: What to do with Text3D, Raster, CG?	if ((tinfo.rInfo.groupType & RenderAtom.SEPARATE_DLIST_PER_RINFO) != 0) {	    RenderAtomListInfo save= tinfo.rInfo.next;	    // Render only one geometry	    tinfo.rInfo.next = null;	    //	    System.err.println("cachedVertexArrayRenderMethod = "+cachedVertexArrayRenderMethod);	    //	    System.err.println("tinfo.rInfo = "+tinfo.rInfo);	    if (modeSupportDL) {		renderBin.dlistRenderMethod.renderSeparateDlistPerRinfo(this, cv,									tinfo.rInfo,									ALL_DIRTY_BITS);	    }	    else {		cachedVertexArrayRenderMethod.render(this, cv, tinfo.rInfo,ALL_DIRTY_BITS);	    }	    tinfo.rInfo.next = save;	}	else if ((tinfo.rInfo.groupType & (RenderAtom.VARRAY| RenderAtom.DLIST)) != 0) {	    RenderAtomListInfo save= tinfo.rInfo.next;	    // Render only one geometry	    tinfo.rInfo.next = null;	    //	    System.err.println("cachedVertexArrayRenderMethod = "+cachedVertexArrayRenderM

⌨️ 快捷键说明

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