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

📄 transformstructure.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	    	    // XXXX: This is a hack, should be fixed after EA	    // Null pointer checking should be removed!	    // should call trans = tg.getCurrentChildLocalToVworld(key);	    synchronized(tg) {		if (tg.childLocalToVworld != null) {		    if (tg.inSharedGroup) {			key = (HashKey) keySet.get(k++);			for (j=0; j<tg.localToVworldKeys.length; j++) {			    if (tg.localToVworldKeys[j].equals(key)) {				break;			    }			}		  			if (j < tg.localToVworldKeys.length) {			    // last index = current index			    tg.childLocalToVworldIndex[j][NodeRetained.LAST_LOCAL_TO_VWORLD] = 				tg.childLocalToVworldIndex[j][NodeRetained.CURRENT_LOCAL_TO_VWORLD];			}		    }		    else {			// last index = current index			tg.childLocalToVworldIndex[0][NodeRetained.LAST_LOCAL_TO_VWORLD] = 			    tg.childLocalToVworldIndex[0][NodeRetained.CURRENT_LOCAL_TO_VWORLD];		    }		}			    }	}	dirtyTransformGroups.clear();	keySet.clear();	    }    void processGeometryAtomVwcBounds() {        Shape3DRetained ms;	GeometryAtom ga;	//int num_locales = universe.listOfLocales.size();	int oSize = objectList.size();	for (int i = 0; i < oSize; i++) {	    Object[] nodes = (Object[]) objectList.get(i);	    if (J3dDebug.devPhase && J3dDebug.debug) {		J3dDebug.doDebug(J3dDebug.transformStructure, J3dDebug.LEVEL_5,				 "vwcBounds computed this frame = " + nodes.length + "\n");	    }	    	    for (int j = 0; j < nodes.length; j++) {		// If the list has geometry atoms, update the vwc bounds		synchronized(nodes[j]) {		    if (nodes[j] instanceof GeometryAtom) {			ga = (GeometryAtom) nodes[j];                         ms = ga.source;                        // update mirrorShape's vwcBounds if in use                        // shape with multiple geometries only needed to be                        // updated once                        synchronized(ms.bounds) {                            ms.vwcBounds.transform(ms.bounds,                                          ms.getCurrentLocalToVworld(0));                        }                        if (ms.collisionBound != null) {                            ms.collisionVwcBound.transform(                                          ms.collisionBound,                                          ms.getCurrentLocalToVworld(0));			}			ga.centroidIsDirty = true;		    }  else if (nodes[j] instanceof GroupRetained) {			// Update collisionVwcBounds of mirror GroupRetained			GroupRetained g =  (GroupRetained) nodes[j];			Bounds bound = (g.sourceNode.collisionBound != null ?                                       g.sourceNode.collisionBound :                                       g.sourceNode.getEffectiveBounds());			g.collisionVwcBounds.transform(bound, 					g.getCurrentLocalToVworld());		    }		}	    }	}	// process collision bounds only update 	for (int i = 0; i < collisionObjectList.size(); i++) {	    Object[] nodes = (Object[]) collisionObjectList.get(i);	    for (int j = 0; j < nodes.length; j++) {		synchronized(nodes[j]) {		    if (nodes[j] instanceof GeometryAtom) {		        ga = (GeometryAtom) nodes[j];                         ms = ga.source;                        if (ms.collisionVwcBound != null) {                            ms.collisionVwcBound.transform(                                       ms.collisionBound,                                       ms.getCurrentLocalToVworld(0));                        }		    } 		}            }        }	collisionObjectList.clear();    }    void processVwcBounds() {        int size;        int i,j;	GeometryAtom ga;        Shape3DRetained ms;        Object nodes[], nodesArr[];        UnorderList arrList = targets.targetList[Targets.GEO_TARGETS];        if (arrList != null) {            size = arrList.size();	    nodesArr = arrList.toArray(false);            for (i = 0; i<size; i++) {                nodes = (Object[])nodesArr[i];                for (j = 0; j < nodes.length; j++) {                    synchronized(nodes[j]) {                        ga = (GeometryAtom) nodes[j];                        ms = ga.source;                        synchronized(ms.bounds) {                            ms.vwcBounds.transform(ms.bounds,                                          ms.getCurrentLocalToVworld(0));                        }                        if (ms.collisionBound != null) {                            ms.collisionVwcBound.transform(                                          ms.collisionBound,                                          ms.getCurrentLocalToVworld(0));                        }                        ga.centroidIsDirty = true;		    }	        }	    }	}        arrList = targets.targetList[Targets.GRP_TARGETS];        if (arrList != null) {            size = arrList.size();	    nodesArr = arrList.toArray(false);            for (i = 0; i<size; i++) {                nodes = (Object[])nodesArr[i];                for (j = 0; j < nodes.length; j++) {                    // Update collisionVwcBounds of mirror GroupRetained                    GroupRetained g = (GroupRetained)nodes[j];                    Bounds bound = (g.sourceNode.collisionBound != null ?                                       g.sourceNode.collisionBound :                                       g.sourceNode.getEffectiveBounds());                    g.collisionVwcBounds.transform(bound,                                        g.getCurrentLocalToVworld()); 	        } 	    } 	}	// process collision bounds only update 	for (i = 0; i < collisionObjectList.size(); i++) {	    nodes = (Object[]) collisionObjectList.get(i);	    for (j = 0; j < nodes.length; j++) {		synchronized(nodes[j]) {		    if (nodes[j] instanceof GeometryAtom) {		        ga = (GeometryAtom) nodes[j];                         ms = ga.source;                        if (ms.collisionVwcBound != null) {                            ms.collisionVwcBound.transform(                                       ms.collisionBound,                                       ms.getCurrentLocalToVworld(0));                        }		    } 		}            }        }	collisionObjectList.clear();    }    void processRegionBoundChanged(J3dMessage m) {        // need to update mirrorShape's bounds        processBoundsChanged((Object[]) m.args[0], (Bounds)m.args[1]);    }    void processBoundsChanged(Object[] gaArray, Bounds updateBounds) {	int i;        GeometryAtom ga;	Shape3DRetained ms;	for (i=0; i<gaArray.length; i++) {            ga = (GeometryAtom)gaArray[i];            ms = ga.source;            // update mirrorShape's bound objects            // since boundsAutoCompute is false and user specified a bound            ms.bounds = updateBounds;            if (ms.collisionBound == null) {                ms.collisionVwcBound = ms.vwcBounds;            } 	}	objectList.add(gaArray);    }    void processCollisionBoundChanged(J3dMessage m) {	int i;        Shape3DRetained ms;        Bounds collisionBound = (Bounds)m.args[1];		if (m.args[0] instanceof GroupRetained) {            GroupRetained g = (GroupRetained) m.args[0];            if (g.mirrorGroup != null) {                objectList.add(g.mirrorGroup);            }        } else {	    Object[] gaArray = (Object[]) m.args[0];             GeometryAtom ga;            for (i=0; i<gaArray.length; i++) {                ga = (GeometryAtom)gaArray[i];                ms = ga.source;                ms.collisionBound = collisionBound;                if (ms.collisionBound != null) {                    // may be previously points to ms.vwcBounds, therefore                    // needs to create one                    ms.collisionVwcBound = (Bounds)ms.collisionBound.clone();                } else {                    ms.collisionVwcBound = ms.vwcBounds;                }            }	    collisionObjectList.add(gaArray);	}    }    void processBoundsAutoComputeChanged(J3dMessage m) {        // need to update mirrorShape's bounds        processBoundsChanged((Object[]) m.args[0], (Bounds) m.args[1]);    }    void processSwitchChanged(J3dMessage m) {        ArrayList switchList = (ArrayList)m.args[2];        int size = switchList.size();	if (size > 0) {	    // update SwitchState's CurrentSwitchOn flag            SwitchState switchState;            for (int j=0; j<size; j++) {                switchState = (SwitchState)switchList.get(j);                switchState.updateCurrentSwitchOn();            }            // process switch dirty TranformGroups            UpdateTargets targets = (UpdateTargets)m.args[0];            UnorderList arrList = targets.targetList[Targets.GRP_TARGETS];            if (arrList != null) {                Object[] nodes;            	Object[] nodesArr = arrList.toArray(false);                int aSize = arrList.size();		int nPaths;		boolean added;                TransformGroupRetained tg;		TransformGroupData data;                for (int j=0; j<aSize; j++) {		    nodes = (Object[])nodesArr[j];                    for (int i=0; i<nodes.length; i++) {			added = false;                        tg = (TransformGroupRetained)nodes[i];                        synchronized(tg) { // synchronized with tg.set/clearLive			if (tg.perPathData != null) {                            nPaths = tg.perPathData.length;                            for (int k=0; k<nPaths; k++) {                                data = tg.perPathData[k];                                if (data.switchState.currentSwitchOn &&					data.switchDirty) {				    if (!added) {				        // only needed to add once                                        switchDirtyTgList.add(tg);                                        added = true;				    }                                    data.switchDirty = false;                                    data.markedDirty = true;                                }                            }                        }                        }                    }                }	    }            // gather a list of SwitchState for lastSwitchOn update            switchChangedList.addAll(switchList);	    if (!inUpdateObjectList) {                VirtualUniverse.mc.addMirrorObject(this);	        inUpdateObjectList = true;	    }	}    }    UpdateTargets getTargetList() {	return targets;    }    ArrayList getBlUsers() { 	return blUsers;    }    boolean getLazyUpdate() { 	return lazyUpdate;    }    void removeNodes(J3dMessage m) {	if (m.args[1] != null) {	    TargetsInterface ti = (TargetsInterface)m.args[1];	    ti.updateCachedTargets(				   TargetsInterface.TRANSFORM_TARGETS,				   (CachedTargets[])m.args[2]);	}    }    void cleanup() {}    // Wrapper for a (TransformGroupRetained, Transform3D) pair    // TransformGroupRetained is effectively used as the key in the    // HashSet    private class TransformData {        private TransformGroupRetained transformGroupRetained;        private Transform3D transform3D;        TransformData( TransformGroupRetained tgr, Transform3D t3d )  {            transformGroupRetained = tgr;            transform3D = t3d;        }        // Hashcode and equals test only evaluate TransformGroupRetained        @Override        public int hashCode() {            return transformGroupRetained.hashCode();        }        // Hashcode and equals test only evaluate TransformGroupRetained        @Override        public boolean equals(Object o) {            if (!(o instanceof TransformData)) {                return false;            }            return transformGroupRetained.equals(((TransformData)o).getTransformGroupRetained());        }        TransformGroupRetained getTransformGroupRetained() {            return transformGroupRetained;        }        Transform3D getTransform3D() {            return transform3D;        }    }}

⌨️ 快捷键说明

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