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

📄 groupretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    }      /**     * Returns an enumeration object of the children.     * @return an enumeration object of the children     */      Enumeration getAllChildren() {        Vector userChildren=new Vector(children.size());	SceneGraphObjectRetained sgo;		for(int i=0; i<children.size(); i++) {	    sgo = (SceneGraphObjectRetained)children.get(i);	    if(sgo != null)		userChildren.add(sgo.source);	    else		userChildren.add(null);	}	        return userChildren.elements();    }    void checkValidChild(Node child, String s) {	if ((child != null) &&            (((child instanceof BranchGroup) && 	      (((BranchGroupRetained) child.retained).attachedToLocale)) ||	     (((NodeRetained)child.retained).parent != null))) {		throw new MultipleParentException(J3dI18N.getString(s));	}    }    /**     * Appends the specified child to this node's list of children.     * @param child the child to add to this node's list of children     */    void addChild(Node child) {	checkValidChild(child, "GroupRetained2"); 	if (this.source.isLive()) {	    universe.resetWaitMCFlag();	    synchronized (universe.sceneGraphLock) {                universe.notifyStructureChangeListeners(true, this.source, (BranchGroup)child);	        doAddChild(child, null, 0);		universe.setLiveState.clear();		    }	    universe.waitForMC();	} else {	    doAddChild(child, null, 0);	    if (universe != null) {		synchronized (universe.sceneGraphLock) {		    universe.setLiveState.clear();			}			    }	}        dirtyBoundsCache();    }        // The method that does the work once the lock is acquired.    void doAddChild(Node child, J3dMessage messages[], int messageIndex) {	appendChildrenData();	if(child == null) { 	    children.add(null);	    return;	}	    	NodeRetained childr = (NodeRetained) child.retained;	childr.setParent(this);	children.add(childr);	checkSetLive(childr, children.size()-1, messages, messageIndex, null);	if (this.source.isLive()) {	    ((BranchGroupRetained)childr).isNew = true;	}    }        void moveTo(BranchGroup bg) {        if (bg != null) {            ((GroupRetained)bg.retained).dirtyBoundsCache();        }	if (this.source.isLive()) {	    universe.resetWaitMCFlag();	    synchronized (universe.sceneGraphLock) {                GroupRetained oldParent = (GroupRetained)((BranchGroupRetained)bg.retained).parent;	        doMoveTo(bg);		universe.setLiveState.clear();	                if (oldParent==null)                    universe.notifyStructureChangeListeners(((BranchGroupRetained)bg.retained).locale, this.source, bg);                else                    universe.notifyStructureChangeListeners(oldParent.source, this.source, bg);	    }	    universe.waitForMC();	} else {	    doMoveTo(bg);	    if (universe != null) {		synchronized (universe.sceneGraphLock) {		    universe.setLiveState.clear();			}			    }	}        dirtyBoundsCache();    }        // The method that does the work once the lock is acquired.    void doMoveTo(BranchGroup branchGroup) {	J3dMessage messages[] = null;	int numMessages = 0;	int detachStartIndex = 0;	int attachStartIndex = 0;	    	if(branchGroup != null) {	    BranchGroupRetained bg = (BranchGroupRetained) branchGroup.retained;	    GroupRetained g = (GroupRetained)bg.parent;	    // Find out how many messages to be created	    // Note that g can be NULL if branchGroup parent is	    // a Locale, in this case the following condition 	    // will fail.	    // Figure out the number of messages based on whether the group	    // from which its moving from is live and group to which its	    // moving to is live	    if (g != null) {		if (g.source.isLive()) {		    numMessages = 3; // REMOVE_NODES, ORDERED_GROUP_REMOVED,VIEWSPECIFICGROUP_CLEAR		    attachStartIndex = 3;		}		else {		    numMessages = 0;		    attachStartIndex = 0;		}		    	    }	    else { // Attached to locale		numMessages = 3; // REMOVE_NODES, ORDERED_GROUP_REMOVED, VIEWSPECIFICGROUP_CLEAR		attachStartIndex = 3;	    }	    // Now, do the evaluation for the group that its going to be	    // attached to ..	    if (this.source.isLive()) {		numMessages+=4;		// INSERT_NODES, BEHAVIOR_ACTIVATE		                        // ORDERED_GROUP_INSERTED, VIEWSPECIFICGROUP_INIT	    }			    messages = new J3dMessage[numMessages];	    for (int i=0; i<numMessages; i++) {		messages[i] = new J3dMessage();		messages[i].type = J3dMessage.INVALID_TYPE;	    }	    // Remove it from it's parents state	    if (g == null) {		if (bg.locale != null) {		    bg.locale.doRemoveBranchGraph(branchGroup, 						  messages, detachStartIndex);		}	    } else {		g.doRemoveChild(g.children.indexOf(bg),				messages, 				detachStartIndex);	    }	}		// Add it to it's new parent	doAddChild(branchGroup, messages, attachStartIndex);	if (numMessages > 0) {	    int count = 0;	    for (int i=0; i < numMessages; i++) {		if (messages[i].type != J3dMessage.INVALID_TYPE) {		    count++;		}	    }	    if (count == numMessages) {		// in most cases		VirtualUniverse.mc.processMessage(messages);	    } else {		J3dMessage ms[] = null;		if (count > 0) {		    ms = new J3dMessage[count];		}		 		int k=0;		for (int i=0; i < numMessages; i++) {		    if (messages[i].type != J3dMessage.INVALID_TYPE) {			ms[k++] = messages[i];		    }  		}				if (ms != null) {		    VirtualUniverse.mc.processMessage(ms);		}	    }	}    }    /**     * Returns a count of this nodes' children.     * @return the number of children descendant from this node     */    int numChildren() {	return children.size();    }      // Remove a light from the list of lights    void removeLight(int numLgt, LightRetained[] removelight, HashKey key) {	ArrayList l;	int index;	if (inSharedGroup) {	    int hkIndex = key.equals(localToVworldKeys, 0, localToVworldKeys.length);	    l = (ArrayList)lights.get(hkIndex);	    if (l != null) {		for (int i = 0; i < numLgt; i++) {		    index = l.indexOf(removelight[i]);		    l.remove(index);		}	    }	}	else {	    l = (ArrayList)lights.get(0);	    for (int i = 0; i < numLgt; i++) {		index = l.indexOf(removelight[i]);		l.remove(index);	    }	}	/*	// XXXX: lights may remove twice or more during clearLive(),	// one from itself and one call from every LightRetained	// reference this.  So there is case that this procedure get	// called when light already removed.	if (i >= 0) 	    lights.remove(i);	*/    }    void addAllNodesForScopedLight(int numLgts,				   LightRetained[] ml,				   ArrayList list,				   HashKey k) {	if (inSharedGroup) {	    for (int i = 0; i < localToVworldKeys.length; i++) {		k.set(localToVworldKeys[i]);		processAllNodesForScopedLight(numLgts,  ml, list,  k);	    }	}	else {	    processAllNodesForScopedLight(numLgts, ml,  list,  k);	}    }    void processAllNodesForScopedLight(int numLgts, LightRetained[] ml, ArrayList list, HashKey k) {	if (allocatedLights) {	    addLight(ml, numLgts, k);	}	if (this.source.isLive() || this.isInSetLive()) {	    for (int i = children.size()-1; i >=0; i--) {		NodeRetained child = (NodeRetained)children.get(i);		if(child != null) {		    if (child instanceof GroupRetained  && (child.source.isLive() || child.isInSetLive()))			((GroupRetained)child).processAllNodesForScopedLight(numLgts, ml, list, k);		    else if (child instanceof LinkRetained && (child.source.isLive()|| child.isInSetLive())) {			int lastCount = k.count;			LinkRetained ln = (LinkRetained) child;			if (k.count == 0) {			    k.append(locale.nodeId);			}			((GroupRetained)(ln.sharedGroup)).			    processAllNodesForScopedLight(numLgts, ml, list, k.append("+").						       append(ln.nodeId));			k.count = lastCount;		    } else if (child instanceof Shape3DRetained && child.source.isLive()) {			((Shape3DRetained)child).getMirrorObjects(list, k);		    } else if (child instanceof MorphRetained && child.source.isLive()) {			((MorphRetained)child).getMirrorObjects(list, k);		    }		}	    }	}    }    // If its a group, then add the scope to the group, if    // its a shape, then keep a list to be added during    // updateMirrorObject    void removeAllNodesForScopedLight(int numLgts, LightRetained[] ml, ArrayList list, HashKey k) {	if (inSharedGroup) {	    for (int i = 0; i < localToVworldKeys.length; i++) {		k.set(localToVworldKeys[i]);		processRemoveAllNodesForScopedLight(numLgts, ml,  list,  k);	    }	}	else {	    processRemoveAllNodesForScopedLight(numLgts, ml,  list,  k);	}    }    void processRemoveAllNodesForScopedLight(int numLgts, LightRetained[] ml, ArrayList list, HashKey k) {	if (allocatedLights) {	    removeLight(numLgts,ml, k);	}	// If the source is live, then notify the children	if (this.source.isLive() && !isInClearLive) {	    for (int i = children.size()-1; i >=0; i--) {		NodeRetained child = (NodeRetained)children.get(i);		if(child != null) {		    if (child instanceof GroupRetained &&(child.source.isLive() &&							    ! ((GroupRetained)child).isInClearLive))			((GroupRetained)child).processRemoveAllNodesForScopedLight(numLgts, ml,list, k);		    else if (child instanceof LinkRetained && child.source.isLive()) {			int lastCount = k.count;			LinkRetained ln = (LinkRetained) child;			if (k.count == 0) {			    k.append(locale.nodeId);			}			((GroupRetained)(ln.sharedGroup)).			    processRemoveAllNodesForScopedLight(numLgts, ml, list, k.append("+").							append(ln.nodeId));			k.count = lastCount;		    } else if (child instanceof Shape3DRetained && child.source.isLive() ) {			((Shape3DRetained)child).getMirrorObjects(list, k);		    } else if (child instanceof MorphRetained && child.source.isLive()) {			((MorphRetained)child).getMirrorObjects(list,  k);		    }		}	    }	}    }        void addAllNodesForScopedFog(FogRetained mfog, ArrayList list, HashKey k) {	if (inSharedGroup) {	    for (int i = 0; i < localToVworldKeys.length; i++) {		k.set(localToVworldKeys[i]);		processAddNodesForScopedFog(mfog,  list,  k);	    }	}	else {	    processAddNodesForScopedFog(mfog,  list,  k);	}    }    void processAddNodesForScopedFog(FogRetained mfog, ArrayList list, HashKey k) {	// If this group has it own scoping list then add .. 	if (allocatedFogs) 	    addFog(mfog, k);	// If the source is live, then notify the children	if (this.source.isLive() || this.isInSetLive()) {	    for (int i = children.size()-1; i >=0; i--) {		NodeRetained child = (NodeRetained)children.get(i);		if(child != null) {		    if (child instanceof GroupRetained && (child.source.isLive()|| child.isInSetLive()))			((GroupRetained)child).processAddNodesForScopedFog(mfog, list, k);		    else if (child instanceof LinkRetained && (child.source.isLive()||child.isInSetLive() )) {			int lastCount = k.count;			LinkRetained ln = (LinkRetained) child;			if (k.count == 0) {			    k.append(locale.nodeId);			}			((GroupRetained)(ln.sharedGroup)).			    processAddNodesForScopedFog(mfog, list,  k.append("+").						     append(ln.nodeId));			k.count = lastCount;		    } else if (child instanceof Shape3DRetained && child.source.isLive()) {			((Shape3DRetained)child).getMirrorObjects(list, k);		    } else if (child instanceof MorphRetained && child.source.isLive()) {			((MorphRetained)child).getMirrorObjects(list, k);		    }		}	    }	}    }        // If its a group, then add the scope to the group, if    // its a shape, then keep a list to be added during    // updateMirrorObject    void removeAllNodesForScopedFog(FogRetained mfog, ArrayList list, HashKey k) {	if (inSharedGroup) {	    for (int i = 0; i < localToVworldKeys.length; i++) {		k.set(localToVworldKeys[i]);		processRemoveAllNodesForScopedFog(mfog,  list,  k);	    }	}	else {	    processRemoveAllNodesForScopedFog(mfog,  list,  k);	}    }    void processRemoveAllNodesForScopedFog(FogRetained mfog, ArrayList list, HashKey k) {	// If the source is live, then notify the children	if (allocatedFogs) 	    removeFog(mfog, k);	if (this.source.isLive() && !isInClearLive) {	    for (int i = children.size()-1; i >=0; i--) {		NodeRetained child = (NodeRetained)children.get(i);		if(child != null) {		    if (child instanceof GroupRetained &&(child.source.isLive() &&							    ! ((GroupRetained)child).isInClearLive))			((GroupRetained)child).processRemoveAllNodesForScopedFog(mfog, list, k);		    else if (child instanceof LinkRetained && child.source.isLive()) {			int lastCount = k.count;			LinkRetained ln = (LinkRetained) child;			if (k.count == 0) {			    k.append(locale.nodeId);			}			((GroupRetained)(ln.sharedGroup)).			    processRemoveAllNodesForScopedFog(mfog, list, k.append("+").							append(ln.nodeId));			k.count = lastCount;		    } else if (child instanceof Shape3DRetained && child.source.isLive() ) {			((Shape3DRetained)child).getMirrorObjects(list, k);		    } else if (child instanceof MorphRetained && child.source.isLive()) {			((MorphRetained)child).getMirrorObjects(list,  k);		    }		}	    }	}    }    void addAllNodesForScopedModelClip(ModelClipRetained mModelClip, ArrayList list, HashKey k) {	if (inSharedGroup) {	    for (int i = 0; i < localToVworldKeys.length; i++) {		k.set(localToVworldKeys[i]);		processAddNodesForScopedModelClip(mModelClip,  list,  k);	    }	}	else {

⌨️ 快捷键说明

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