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

📄 transformgroupretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		if (localToVworldKeys != null) {		    for(int j=0; j<localToVworldKeys.length; j++) {			if (perPathData[j].markedDirty) {			    updateChildLocalToVworld(localToVworldKeys[j], j,						     dirtyTransformGroups, 						     keySet, targets,						     blUsers);			} else {			    //System.err.println("tg.procChild markedDiry skip");			}		    }		}	    } else {		if (perPathData != null && perPathData[0].markedDirty) {		    updateChildLocalToVworld(dirtyTransformGroups, keySet,						     targets, blUsers);		} else {		    //System.err.println("tg.procChild markedDiry skip");		} 	    }	}    }        // for shared case    void updateChildLocalToVworld(HashKey key, int index,				  ArrayList dirtyTransformGroups,				  ArrayList keySet,				  UpdateTargets targets,				  ArrayList blUsers) {		int i, j;	Object obj;	Transform3D lToVw, childLToVw;	TransformGroupRetained tg;	LinkRetained ln;	CachedTargets ct;		synchronized(this) { // sync with setLive/clearLive	    	    if (localToVworld != null) { 		perPathData[index].markedDirty = false;		// update immediate child's localToVworld	    		if (perPathData[index].switchState.currentSwitchOn ) {		    lToVw = getCurrentLocalToVworld(index);		    childLToVw = getUpdateChildLocalToVworld(index);		    childLToVw.mul(lToVw, currentTransform);		    dirtyTransformGroups.add(this);		    keySet.add(key);                    ct = j3dCTs[index];                    if (ct != null) {                        targets.addCachedTargets(ct);                        if (ct.targetArr[Targets.BLN_TARGETS] != null) {                            gatherBlUsers(blUsers, 					ct.targetArr[Targets.BLN_TARGETS]);                        }                    }		} else {		    perPathData[index].switchDirty = true;		    //System.err.println("tg.updateChild skip");		}		// update child's localToVworld of its children		// transformLink may contain link nodes		synchronized(childTransformLinks) {		    for (i=0; i<childTransformLinks.size(); i++) {			obj = childTransformLinks.get(i);		    			if (obj instanceof TransformGroupRetained) {			    tg = (TransformGroupRetained)obj;			    tg.updateChildLocalToVworld(					tg.localToVworldKeys[index], 					index, dirtyTransformGroups, keySet,					targets, blUsers);			} else { // LinkRetained			    ln = (LinkRetained)obj;			    currentKey.set(localToVworldKeys[index]);			    currentKey.append(LinkRetained.plus).append(ln.nodeId);			    if ((ln.sharedGroup != null) && 				(ln.sharedGroup.localToVworldKeys != null)) {				j = currentKey.equals(ln.sharedGroup.localToVworldKeys,0,						      ln.sharedGroup.localToVworldKeys.length);				if(j < 0) {				    System.err.					println("TransformGroupRetained : Can't find hashKey"); 				}			    				if (j < ln.sharedGroup.localToVworldKeys.length) {				    ln.sharedGroup.					updateChildLocalToVworld(ln.sharedGroup.						 localToVworldKeys[j], j,						dirtyTransformGroups, keySet,						targets, blUsers);				}			    }			}		    }		}	    }	}    }    // for non-shared case    void updateChildLocalToVworld(ArrayList dirtyTransformGroups,                                  ArrayList keySet,				  UpdateTargets targets,				  ArrayList blUsers) {	int i, j;	Object obj;	Transform3D lToVw, childLToVw;	TransformGroupRetained tg;        LinkRetained ln;	CachedTargets ct;		synchronized(this) { // sync with setLive/clearLive	    	    if (localToVworld != null) { 		perPathData[0].markedDirty = false;		// update immediate child's localToVworld		if (perPathData[0].switchState.currentSwitchOn ) {		    lToVw = getCurrentLocalToVworld(0);		    childLToVw = getUpdateChildLocalToVworld(0);		    childLToVw.mul(lToVw, currentTransform);		    dirtyTransformGroups.add(this);                    ct = j3dCTs[0];		    if (ct != null) {		        targets.addCachedTargets(ct);		        if (ct.targetArr[Targets.BLN_TARGETS] != null) {                            gatherBlUsers(blUsers, 					ct.targetArr[Targets.BLN_TARGETS]);		        }		    }		} else {		    perPathData[0].switchDirty = true;		    //System.err.println("tg.updateChild skip");		} 				// update child's localToVworld of its children		// transformLink contains top level transform group nodes		// and link nodes		synchronized(childTransformLinks) {		    for (i=0; i<childTransformLinks.size(); i++) {			obj = childTransformLinks.get(i);						if (obj instanceof TransformGroupRetained) {			    tg = (TransformGroupRetained)obj;			    tg.updateChildLocalToVworld(dirtyTransformGroups, 						keySet, targets, blUsers);			    			} else { // LinkRetained			    ln = (LinkRetained)obj;			    currentKey.reset();			    currentKey.append(locale.nodeId);			    currentKey.append(LinkRetained.plus).append(ln.nodeId);			    if ((ln.sharedGroup != null) &&				(ln.sharedGroup.localToVworldKeys != null)) {				j = currentKey.equals(ln.sharedGroup.localToVworldKeys,0,						      ln.sharedGroup.localToVworldKeys.length);				if(j < 0) {				    System.err.					println("TransformGroupRetained : Can't find hashKey"); 				}								if (j<ln.sharedGroup.localToVworldKeys.length) {				    ln.sharedGroup.					updateChildLocalToVworld(						ln.sharedGroup.							localToVworldKeys[j], 						j, dirtyTransformGroups,						keySet, targets, blUsers);				}			    }			}		    }		}	    }	}    }    /**     * Transform the input bound by the current LocalToVWorld, this     * one overwrite the one defined in NodeRetained since for     * TransformGroup, it has to use currentChildLocalToVworld     * instead of currentLocalToVworld     */    void transformBounds(SceneGraphPath path, Bounds bound) {	if (!((NodeRetained) path.item.retained).inSharedGroup) {	    bound.transform(getCurrentChildLocalToVworld());	} else {	    HashKey key = new HashKey("");	    path.getHashKey(key);	    	    bound.transform(getCurrentChildLocalToVworld(key));	}    }    /**     * get the to be updated child localToVworld     */    Transform3D getUpdateChildLocalToVworld(int index) {	int currentIndex = childLocalToVworldIndex[index][NodeRetained.CURRENT_LOCAL_TO_VWORLD];	if (currentIndex == childLocalToVworldIndex[index][NodeRetained.LAST_LOCAL_TO_VWORLD]) {	    currentIndex = currentIndex ^ 1;	    childLocalToVworldIndex[index][NodeRetained.CURRENT_LOCAL_TO_VWORLD] = currentIndex;	}	return childLocalToVworld[index][currentIndex];    }    /**     * Get the current child localToVworld transform for a node     */    Transform3D getCurrentChildLocalToVworld() {	return getCurrentChildLocalToVworld(0);    }    Transform3D getCurrentChildLocalToVworld(int index) {        return childLocalToVworld[index][childLocalToVworldIndex[index][NodeRetained.CURRENT_LOCAL_TO_VWORLD]];    }    Transform3D getCurrentChildLocalToVworld(HashKey key) {	if (!inSharedGroup) {            return childLocalToVworld[0][childLocalToVworldIndex[0][NodeRetained.CURRENT_LOCAL_TO_VWORLD]];        } else {	    int i = key.equals(localToVworldKeys, 0, localToVworldKeys.length); 	    if(i>= 0) {		return childLocalToVworld[i]		    [childLocalToVworldIndex[i][NodeRetained.CURRENT_LOCAL_TO_VWORLD]];	    }	}        return new Transform3D();    }    /**     * Get the last child localToVworld transform for a node     */    Transform3D getLastChildLocalToVworld(HashKey key) {	        if (!inSharedGroup) {            return childLocalToVworld[0][childLocalToVworldIndex[0][NodeRetained.LAST_LOCAL_TO_VWORLD]];        } else {	    int i = key.equals(localToVworldKeys, 0, localToVworldKeys.length); 	    if(i>= 0) {		return childLocalToVworld[i]		    [childLocalToVworldIndex[i][NodeRetained.LAST_LOCAL_TO_VWORLD]];            }        }        return new Transform3D();    }    // ****************************    // TargetsInterface methods    // ****************************    public int getTargetThreads(int type) {        // type is ignored here, only need for SharedGroup        if (type == TargetsInterface.TRANSFORM_TARGETS) {	    return targetThreads;	} else {	    System.err.println("getTargetsThreads: wrong arguments");	    return -1;	}     }    public CachedTargets getCachedTargets(int type, int index, int child) {        // type is ignored here, only need for SharedGroup        // child is ignored here        if (type == TargetsInterface.TRANSFORM_TARGETS) {	    return cachedTargets[index];	} else {	    System.err.println("getCachedTargets: wrong arguments");	    return null;	}    }    TargetsInterface getClosestTargetsInterface(int type) {        return (type == TargetsInterface.TRANSFORM_TARGETS)?                (TargetsInterface)this:                (TargetsInterface)parentSwitchLink;    }    // re-evalute localTargetThreads using newCachedTargets and    // re-evaluate targetThreads    public void computeTargetThreads(int type, 				CachedTargets[] newCachedTargets) {        // type is ignored here, only need for SharedGroup        if (type == TargetsInterface.TRANSFORM_TARGETS) {            localTargetThreads = J3dThread.UPDATE_TRANSFORM;	    for(int i=0; i<newCachedTargets.length; i++) {	        if (newCachedTargets[i] != null) {		    localTargetThreads |= newCachedTargets[i].computeTargetThreads();		}	    }	    targetThreads = localTargetThreads;            int numLinks = childTransformLinks.size();            TargetsInterface childLink; 	    NodeRetained node;            for(int i=0; i<numLinks; i++) {	                    node = (NodeRetained)childTransformLinks.get(i);    	        if (node.nodeType == NodeRetained.LINK) {		    childLink = (TargetsInterface) 				((LinkRetained)node).sharedGroup;	        } else {		    childLink = (TargetsInterface) node;	        }		if (childLink != null) {                    targetThreads |= 			childLink.getTargetThreads(TargetsInterface.TRANSFORM_TARGETS);		}	    }        } else {	    System.err.println("computeTargetsThreads: wrong arguments");        }	    }    // re-compute localTargetThread, targetThreads and    // propagate changes to ancestors    public void updateTargetThreads(int type, 				CachedTargets[] newCachedTargets) {        // type is ignored here, only need for SharedGroup        if (type == TargetsInterface.TRANSFORM_TARGETS) {            computeTargetThreads(type, newCachedTargets);            if (parentTransformLink != null) {                TargetsInterface pti = (TargetsInterface)parentTransformLink;                pti.propagateTargetThreads(TargetsInterface.TRANSFORM_TARGETS,                                        targetThreads);            }        } else {            System.err.println("updateTargetThreads: wrong arguments");        }    }    // re-evaluate targetThreads using childTargetThreads and     // propagate changes to ancestors    public void propagateTargetThreads(int type, int childTargetThreads) {        // type is ignored here, only need for SharedGroup	        if (type == TargetsInterface.TRANSFORM_TARGETS) {	    // XXXX : For now we'll OR more than exact.	    //targetThreads = localTargetThreads | childTargetThreads;	    targetThreads = targetThreads | childTargetThreads;            if (parentTransformLink != null) {                TargetsInterface pti = (TargetsInterface)parentTransformLink;                pti.propagateTargetThreads(TargetsInterface.TRANSFORM_TARGETS,                                        targetThreads);            }        } else {            System.err.println("propagateTargetThreads: wrong arguments");        }    }    public void updateCachedTargets(int type, CachedTargets[] newCt) {        // type is ignored here, only need for SharedGroup        if (type == TargetsInterface.TRANSFORM_TARGETS) {	    j3dCTs = newCt;        } else {	    System.err.println("updateCachedTargets: wrong arguments");	}    }    public void copyCachedTargets(int type, CachedTargets[] newCt) {        // type is ignored here, only need for SharedGroup        if (type == TargetsInterface.TRANSFORM_TARGETS) {	    int size = cachedTargets.length;	    for (int i=0; i<size; i++) {	        newCt[i] = cachedTargets[i];            }        } else {	    System.err.println("copyCachedTargets: wrong arguments");        }    }    public void resetCachedTargets(int type, 				CachedTargets[] newCtArr, int child) {        // type is ignored here, only need for SharedGroup        // child is ignored here        if (type == TargetsInterface.TRANSFORM_TARGETS) {            cachedTargets = newCtArr;	} else {	    System.err.println("resetCachedTargets: wrong arguments");	}    }    public ArrayList getTargetsData(int type, int index) {        // not used	return null;    }    void childCheckSetLive(NodeRetained child, int childIndex,                                SetLiveState s, NodeRetained linkNode) {        s.currentTransforms = childLocalToVworld;        s.currentTransformsIndex = childLocalToVworldIndex;        s.parentTransformLink = this;        s.childTransformLinks = childTransformLinks;        s.localToVworld = s.currentTransforms;        s.localToVworldIndex = s.currentTransformsIndex;        child.setLive(s);    }}

⌨️ 快捷键说明

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