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

📄 shape3dretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                                    bounds.combine((Bounds)bbox);                                } else {                                    bounds.combine((Bounds)geometry.geoBounds);                                }                            }                        }                    }                } else {                    if (cachedBounds==null) {                        cachedBounds = new BoundingBox((BoundingBox) null);                        for(int i=0; i<geometryList.size(); i++) {                            geometry = (GeometryRetained) geometryList.get(i);                            if ((geometry != null) &&                                    (geometry.geoType != GeometryRetained.GEO_TYPE_NONE)) {                                geometry.computeBoundingBox();                                // Should this be lock too ? ( MT safe  ? )                                synchronized(geometry.geoBounds) {                                    if (staticTransform != null) {                                        bbox.set(geometry.geoBounds);                                        bbox.transform(staticTransform.transform);                                        cachedBounds.combine((Bounds)bbox);                                    } else {                                        cachedBounds.combine((Bounds)geometry.geoBounds);                                    }                                }                            }                        }                    }                    bounds.combine(cachedBounds);                }            }        } else {                        // Should this be lock too ? ( MT safe  ? )            synchronized(localBounds) {                bounds.combine((Bounds) localBounds);            }        }    }  /**   * assign a name to this node when it is made live.   */    void setLive(SetLiveState s) {	doSetLive(s);	markAsLive();    }        void doSetLive(SetLiveState s) {	// System.err.println("S3DRetained : setLive " + s);	Shape3DRetained shape;	GeometryRetained geometry;	int i, j, k, gaCnt;	ArrayList msList = new ArrayList();		super.doSetLive(s);		nodeId = universe.getNodeId();		if (inSharedGroup) {	    for (i=0; i<s.keys.length; i++) {                if (this instanceof OrientedShape3DRetained) {                    shape = new OrientedShape3DRetained();                } else {                    shape = new Shape3DRetained();                }		shape.key = s.keys[i];		shape.localToVworld = new Transform3D[1][];		shape.localToVworldIndex = new int[1][];		j = s.keys[i].equals(localToVworldKeys, 0,				     localToVworldKeys.length);		/*		    System.err.print("s.keys[i] = "+s.keys[i]+" j = "+j);		    if(j < 0) {		    System.err.println("Shape3dRetained : Can't find hashKey"); 		    }		*/		shape.localToVworld[0] = localToVworld[j];		shape.localToVworldIndex[0] = localToVworldIndex[j];		shape.branchGroupPath = (BranchGroupRetained []) branchGroupPaths.get(j);		shape.isPickable = s.pickable[i];		shape.isCollidable = s.collidable[i];				initMirrorShape3D(s, shape, j);                if (s.switchTargets != null &&                        s.switchTargets[i] != null) {		    s.switchTargets[i].addNode(shape, Targets.GEO_TARGETS);                    shape.closestSwitchParent = s.closestSwitchParents[i];                    shape.closestSwitchIndex = s.closestSwitchIndices[i];                }        	shape.switchState = (SwitchState)s.switchStates.get(j);		// Add any scoped lights to the mirror shape		if (s.lights != null) {		    ArrayList l = (ArrayList)s.lights.get(j);		    if (l != null) {			for (int m = 0; m < l.size(); m++) {			    shape.addLight((LightRetained)l.get(m));			}		    }		}				// Add any scoped fog		if (s.fogs != null) {		    ArrayList l = (ArrayList)s.fogs.get(j);		    if (l != null) {			for (int m = 0; m < l.size(); m++) {			    shape.addFog((FogRetained)l.get(m));			}		    }		}		// Add any scoped modelClip		if (s.modelClips != null) {		    ArrayList l = (ArrayList)s.modelClips.get(j);		    if (l != null) {			for (int m = 0; m < l.size(); m++) {			    shape.addModelClip((ModelClipRetained)l.get(m));			}		    }		}		    		// Add any scoped alt app		if (s.altAppearances != null) {		    ArrayList l = (ArrayList)s.altAppearances.get(j);		    if (l != null) {			for (int m = 0; m < l.size(); m++) {			    shape.addAltApp((AlternateAppearanceRetained)l.get(m));			}		    }		}		synchronized(mirrorShape3D) {		    mirrorShape3D.add(j,shape);		}		msList.add(shape);		if (s.viewLists != null) {		    shape.viewList = (ArrayList)s.viewLists.get(j);		} else {		    shape.viewList = null;		}	    }	} else {            if (this instanceof OrientedShape3DRetained) {                shape = new OrientedShape3DRetained();            } else {                shape = new Shape3DRetained();            }	    shape.localToVworld = new Transform3D[1][];	    shape.localToVworldIndex = new int[1][];	    shape.localToVworld[0] = localToVworld[0];	    shape.localToVworldIndex[0] = localToVworldIndex[0];	    shape.branchGroupPath = (BranchGroupRetained []) branchGroupPaths.get(0);	    shape.isPickable = s.pickable[0];	    shape.isCollidable = s.collidable[0];	    initMirrorShape3D(s, shape, 0);	    	    // Add any scoped lights to the mirror shape	    if (s.lights != null) {		ArrayList l = (ArrayList)s.lights.get(0);		for (i = 0; i < l.size(); i++) {		    shape.addLight((LightRetained)l.get(i));		}	    }	    	    // Add any scoped fog	    if (s.fogs != null) {		ArrayList l = (ArrayList)s.fogs.get(0);		for (i = 0; i < l.size(); i++) {		    shape.addFog((FogRetained)l.get(i));		}	    }	    	    // Add any scoped modelClip	    if (s.modelClips != null) {		ArrayList l = (ArrayList)s.modelClips.get(0);		for (i = 0; i < l.size(); i++) {		    shape.addModelClip((ModelClipRetained)l.get(i));		}	    }	    	    // Add any scoped alt app	    if (s.altAppearances != null) {		ArrayList l = (ArrayList)s.altAppearances.get(0);		for (i = 0; i < l.size(); i++) {		    shape.addAltApp((AlternateAppearanceRetained)l.get(i));		}	    }	    synchronized(mirrorShape3D) {		mirrorShape3D.add(shape);	    }	    msList.add(shape);	    if (s.viewLists != null)		shape.viewList = (ArrayList)s.viewLists.get(0);	    else		shape.viewList = null;	                if (s.switchTargets != null &&                        s.switchTargets[0] != null) {		s.switchTargets[0].addNode(shape, Targets.GEO_TARGETS);                shape.closestSwitchParent = s.closestSwitchParents[0];                shape.closestSwitchIndex = s.closestSwitchIndices[0];            }            shape.switchState = (SwitchState)s.switchStates.get(0);	}	for (k = 0; k < msList.size(); k++) {	    Shape3DRetained sh = (Shape3DRetained)msList.get(k);	    if (appearance != null) {		synchronized(appearance.liveStateLock) {		    if (k == 0) { // Do only first time 			appearance.setLive(inBackgroundGroup, s.refCount);			appearance.initMirrorObject();			if (appearance.renderingAttributes != null)			    visible = appearance.renderingAttributes.visible;		    }		    sh.appearance = (AppearanceRetained)appearance.mirror;		    appearance.addAMirrorUser(sh);		}	    }	    else {		sh.appearance = null;	    }	    if (geometryList != null) {		for(gaCnt=0; gaCnt<geometryList.size(); gaCnt++) {		    geometry = (GeometryRetained) geometryList.get(gaCnt);		    if(geometry != null) {			synchronized(geometry.liveStateLock) {			    if (k == 0) { // Do only first time 				geometry.setLive(inBackgroundGroup, s.refCount);			    }			    geometry.addUser(sh);			}		    }		}	    }	    // after the geometry has been setLived and bounds computed	    if (k== 0 && boundsAutoCompute) { // Do only once 		// user may call setBounds with a bounds other than boundingBox		if (! (localBounds instanceof BoundingBox)) {		    localBounds = new BoundingBox((BoundingBox) null);		}		getCombineBounds((BoundingBox)localBounds);		    	    }	    // Assign GAtom and set the bounds if we are not using switch	    initializeGAtom(sh);            GeometryAtom ga = getGeomAtom(sh);			    // Add the geometry atom for this shape to the nodeList	    s.nodeList.add(ga);		            if (s.transformTargets != null &&            		s.transformTargets[k] != null) {		// Add the geometry atom for this shape to the transformTargets		s.transformTargets[k].addNode(ga, Targets.GEO_TARGETS);	    }	}		s.notifyThreads |= (J3dThread.UPDATE_GEOMETRY | 			    J3dThread.UPDATE_TRANSFORM |			    J3dThread.UPDATE_RENDER |			    J3dThread.UPDATE_RENDERING_ENVIRONMENT);    }     /**     * This clears all references in a mirror shape     */    // This is call in RenderingEnvironmentStructure.removeNode() because that is the    // last point that will reference this ms.    // called on the mirror shape ..    void clearMirrorShape() {	int i;	source = null;	sourceNode = null;	parent = null;	if (otherAppearance != null) {	    otherAppearance.sgApp.removeAMirrorUser(this);	    otherAppearance = null;        }	appearance = null;	branchGroupPath = null;	isPickable = true;	isCollidable = true;	branchGroupPath = null;	// No locking needed. Owner, s3dR, has already been destory.	// DO NOT clear geometryList, ie. geometryList.clear().	// It is referred by the source s3DRetained.	 geometryList = null;	// Clear the mirror scoping info	// Remove all the fogs	for (i = 0; i <  numfogs; i++)	     fogs[i] = null;	 numfogs = 0;	    	// Remove all the modelClips	for (i = 0; i <  numModelClips; i++)	     modelClips[i] = null;	 numModelClips = 0;	    	// Remove all the lights	for (i = 0; i < numlights; i++)	     lights[i] = null;	 numlights = 0;	    	// Remove all the al app	for (i = 0; i <  numAltApps; i++)	     altApps[i] = null;	numAltApps = 0;		viewList = null;	    }    /**     * assign a name to this node when it is made live.     */    void clearLive(SetLiveState s) {	//System.err.println("S3DRetained : clearLive " + s);	int i, j, gaCnt;	Shape3DRetained shape;	GeometryRetained geometry;	Object[] shapes;	ArrayList msList = new ArrayList();		super.clearLive(s);			if (inSharedGroup) {	    synchronized(mirrorShape3D) {		shapes = mirrorShape3D.toArray();		for (i=0; i<s.keys.length; i++) {		    for (j=0; j<shapes.length; j++) {			shape = (Shape3DRetained)shapes[j];			if (shape.key.equals(s.keys[i])) {			    mirrorShape3D.remove(mirrorShape3D.indexOf(shape));            		    if (s.switchTargets != null &&                        		s.switchTargets[i] != null) {                		s.switchTargets[i].addNode(						shape, Targets.GEO_TARGETS);			    }			    msList.add(shape);                            GeometryAtom ga = getGeomAtom(shape);			    // Add the geometry atom for this shape to the nodeList			    s.nodeList.add(ga);            		    if (s.transformTargets != null &&                        		s.transformTargets[i] != null) {                                s.transformTargets[i].addNode(ga, Targets.GEO_TARGETS);                            }			}		    }		}	    }	} else {	    // Only entry 0 is valid	    shape = (Shape3DRetained)mirrorShape3D.get(0);	    synchronized(mirrorShape3D) {		mirrorShape3D.remove(0);	    }            if (s.switchTargets != null &&                        s.switchTargets[0] != null) {                s.switchTargets[0].addNode(shape, Targets.GEO_TARGETS);            }	    msList.add(shape);            GeometryAtom ga = getGeomAtom(shape);	    	    // Add the geometry atom for this shape to the nodeList	    s.nodeList.add(ga);            if (s.transformTargets != null &&		s.transformTargets[0] != null) {                s.transformTargets[0].addNode(ga, Targets.GEO_TARGETS);            }	}	for (int k = 0; k < msList.size(); k++) {	    Shape3DRetained sh = (Shape3DRetained)msList.get(k); 	    if (appearance != null) {		synchronized(appearance.liveStateLock) {		    if (k == 0) {			appearance.clearLive(s.refCount);		    }		    appearance.removeAMirrorUser(sh);		}	    }	    if (geometryList != null) {		for(gaCnt=0; gaCnt<geometryList.size(); gaCnt++) {		    geometry = (GeometryRetained) geometryList.get(gaCnt);		    if(geometry != null) {			synchronized(geometry.liveStateLock) {			    if (k == 0) {				geometry.clearLive(s.refCount);			    }			    geometry.removeUser(sh);			}		    }		}	    }	}	s.notifyThreads |= (J3dThread.UPDATE_GEOMETRY |			    J3dThread.UPDATE_TRANSFORM |			    // This is used to clear the scope info			    // of all the mirror shapes			    J3dThread.UPDATE_RENDERING_ENVIRONMENT | 			    J3dThread.UPDATE_RENDER);	if (!source.isLive()) {	    // Clear the mirror scoping info	    // Remove all the fogs	    for (i = 0; i < numfogs; i++)		fogs[i] = null;	    numfogs = 0;	    	    // Remove all the modelClips	    for (i = 0; i < numModelClips; i++)		modelClips[i] = null;	    numModelClips = 0;	    	    // Remove all the lights	    for (i = 0; i < numlights; i++)		lights[i] = null;	    numlights = 0;

⌨️ 快捷键说明

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