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

📄 groupretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     }    // Remove a ModelClip from the list of ModelClip    void removeModelClip(ModelClipRetained modelClip, HashKey key) {	 ArrayList l;	 int index;	 if (inSharedGroup) {	     int hkIndex = key.equals(localToVworldKeys, 0, localToVworldKeys.length);	     l = (ArrayList)modelClips.get(hkIndex);	     if (l != null) {		 index = l.indexOf(modelClip);		 l.remove(index);	     }	 }	 else {	     l = (ArrayList)modelClips.get(0);	     index = l.indexOf(modelClip);	     l.remove(index);	 }     }    // Remove a fog from the list of alt appearance    void removeAltApp(AlternateAppearanceRetained altApp, HashKey key) {	 ArrayList l;	 int index;	 if (inSharedGroup) {	     int hkIndex = key.equals(localToVworldKeys, 0, localToVworldKeys.length);	     l = (ArrayList)altAppearances.get(hkIndex);	     if (l != null) {		 index = l.indexOf(altApp);		 l.remove(index);	     }	 }	 else {	     l = (ArrayList)altAppearances.get(0);	     index = l.indexOf(altApp);	     l.remove(index);	 }     }            void updatePickable(HashKey keys[], boolean pick[]) {	int nchild = children.size()-1;	super.updatePickable(keys, pick);	int i=0;	NodeRetained child;	for (i = 0; i < nchild; i++) {	    child = (NodeRetained)children.get(i);	    if(child != null)		child.updatePickable(keys, (boolean []) pick.clone());	}	// No need to clone for the last value	child = (NodeRetained)children.get(i);	if(child != null) 	    child.updatePickable(keys, pick);    }        void updateCollidable(HashKey keys[], boolean collide[]) {	int nchild = children.size()-1;	super.updateCollidable(keys, collide);	int i=0;	NodeRetained child;		for (i = 0; i < nchild; i++) {	    child = (NodeRetained)children.get(i);	    if(child != null) 		child.updateCollidable(keys, (boolean []) collide.clone()); 	}	// No need to clone for the last value	child = (NodeRetained)children.get(i);	if(child != null)	    child.updateCollidable(keys, collide);    }    void setAlternateCollisionTarget(boolean target) {	if (collisionTarget == target)	    return;	collisionTarget = target;	if (source.isLive()) {	    // Notify parent TransformGroup to add itself	    // Since we want to update collisionVwcBounds when	    // transform change in TransformStructure.	    TransformGroupRetained tg;	    J3dMessage message = new J3dMessage();	    message.threads = J3dThread.UPDATE_GEOMETRY;	    message.universe = universe;	    // send message to GeometryStructure to add/remove this	    // group node in BHTree as AlternateCollisionTarget	    int numPath;	    CachedTargets newCtArr[] = null;	    if (target) {		createMirrorGroup();                TargetsInterface ti = getClosestTargetsInterface(                                        TargetsInterface.TRANSFORM_TARGETS);                if (ti != null) {                    // update targets	            CachedTargets ct;		    Targets targets = new Targets();		    numPath = mirrorGroup.size();		    newCtArr = 	new CachedTargets[numPath];		    for (int i=0; i<numPath; i++) {                        ct = ti.getCachedTargets(TargetsInterface.TRANSFORM_TARGETS, i, -1);			if (ct != null) {		            targets.addNode((NnuId)mirrorGroup.get(i), 					    Targets.GRP_TARGETS);                            newCtArr[i] = targets.snapShotAdd(ct);			} else {			    newCtArr[i] = null;			}                    }            	    // update target threads and propagate change to above            	    // nodes in scene graph            	    ti.updateTargetThreads(TargetsInterface.TRANSFORM_TARGETS,                                                newCtArr);                    ti.resetCachedTargets(TargetsInterface.TRANSFORM_TARGETS,                                                newCtArr, -1);                }		message.type = J3dMessage.INSERT_NODES;		message.args[0] = mirrorGroup.toArray();                message.args[1] = ti;                message.args[2] = newCtArr;	    } else {                TargetsInterface ti = 		    getClosestTargetsInterface(TargetsInterface.TRANSFORM_TARGETS);                if (ti != null) {                    // update targets                    Targets targets = new Targets();	            CachedTargets ct;		    numPath = mirrorGroup.size();		    newCtArr = 	new CachedTargets[numPath];		    for (int i=0; i<numPath; i++) {                        ct = ti.getCachedTargets(TargetsInterface.TRANSFORM_TARGETS, i, -1);			if (ct != null) {			                                targets.addNode((NnuId)mirrorGroup.get(i),					    Targets.GRP_TARGETS);			    //Note snapShotRemove calls targets.clearNode()                            newCtArr[i] = targets.snapShotRemove(ct);                        } else {                            newCtArr[i] = null;                        }                    }            	    // update target threads and propagate change to above            	    // nodes in scene graph            	    ti.updateTargetThreads(TargetsInterface.TRANSFORM_TARGETS,					   newCtArr);                    ti.resetCachedTargets(TargetsInterface.TRANSFORM_TARGETS,					  newCtArr, -1);                }		message.type = J3dMessage.REMOVE_NODES;		message.args[0] = mirrorGroup.toArray();                message.args[1] = ti;                message.args[2] = newCtArr;		mirrorGroup = null;  // for gc	    }	    VirtualUniverse.mc.processMessage(message);	}    }    boolean getAlternateCollisionTarget() {	return collisionTarget;    }    /**     * This checks is setLive needs to be called.  If it does, it gets the     * needed info and calls it.     */    void checkSetLive(NodeRetained child, int childIndex, J3dMessage messages[], 				int messageIndex, NodeRetained linkNode) {	checkSetLive(child, childIndex, localToVworldKeys, inSharedGroup,		     messages, messageIndex, linkNode);    }        /**     * This checks is setLive needs to be called.  If it does, it gets the     * needed info and calls it.     */    void checkSetLive(NodeRetained child, int childIndex, HashKey keys[], 		      boolean isShared, J3dMessage messages[], 		      int messageIndex, NodeRetained linkNode) {        SceneGraphObject me = this.source;	SetLiveState s;	J3dMessage createMessage;	boolean sendMessages = false;	boolean sendOGMessage = true;	boolean sendVSGMessage = true;        if (me.isLive()) {	    s = universe.setLiveState;	    s.reset(locale);	    s.refCount = refCount;	    s.inSharedGroup = isShared;	    s.inBackgroundGroup = inBackgroundGroup;	    s.inViewSpecificGroup = inViewSpecificGroup;            s.geometryBackground = geometryBackground;	    s.keys = keys;	    	    s.viewLists = viewLists;	    s.parentBranchGroupPaths = branchGroupPaths;	    // Note that there is no need to clone individual	    // branchGroupArray since they will get replace (not append)	    // by creating a new reference in child's group.            s.branchGroupPaths = (ArrayList) branchGroupPaths.clone();            s.orderedPaths = orderedPaths;	    // Make the scoped fogs and lights of the child to include, the	    // the scoped fog of this group	    s.lights = lights;	    s.altAppearances = altAppearances;	    s.fogs = fogs;	    s.modelClips = modelClips;	    boolean pick[];	    boolean collide[];	    if (!inSharedGroup) {		pick = new boolean[1];		collide = new boolean[1];	    } else {		pick = new boolean[localToVworldKeys.length];		collide = new boolean[localToVworldKeys.length];	    }	    findPickableFlags(pick);	    super.updatePickable(null, pick);	    s.pickable = pick;	    findCollidableFlags(collide);	    super.updateCollidable(null, collide); 	    s.collidable = collide;            TargetsInterface transformInterface, switchInterface;            transformInterface = initTransformStates(s, true);            switchInterface = initSwitchStates(s, this, child, linkNode, true);	    if (s.inViewSpecificGroup && 		(s.changedViewGroup == null)) {		s.changedViewGroup = new ArrayList();		s.changedViewList = new ArrayList();		s.keyList = new int[10];		s.viewScopedNodeList = new ArrayList();		s.scopedNodesViewList = new ArrayList();	    }            childCheckSetLive(child, childIndex, s, linkNode);	    CachedTargets[] newCtArr = null;            newCtArr = updateTransformStates(s, transformInterface, true);            updateSwitchStates(s, switchInterface, true);	    // We're sending multiple messages in the call, inorder to	    // have all these messages to be process as an atomic operation.	    // We need to create an array of messages to MasterControl, this	    // will ensure that all these messages will get the same time stamp.	    // If it is called from "moveTo",  messages is not null. 	    if (messages == null) {		int numMessages = 2;		if(s.ogList.size() > 0) {		    numMessages++;		}		else {		    sendOGMessage = false;		}		if(s.changedViewGroup != null) {		    numMessages++;		}		else {		    sendVSGMessage = false;		}		messages = new J3dMessage[numMessages];		messageIndex = 0;		for(int mIndex=0; mIndex < numMessages; mIndex++) {		    messages[mIndex] = new J3dMessage();		}		sendMessages = true;	    }	    	    if(sendOGMessage) {		createMessage = messages[messageIndex++];	    		createMessage.threads = J3dThread.UPDATE_RENDER | 		    J3dThread.UPDATE_RENDERING_ENVIRONMENT;		createMessage.type = J3dMessage.ORDERED_GROUP_INSERTED;		createMessage.universe = universe;		createMessage.args[0] = s.ogList.toArray();		createMessage.args[1] = s.ogChildIdList.toArray();		createMessage.args[2] = s.ogOrderedIdList.toArray();		createMessage.args[3] = s.ogCIOList.toArray();		createMessage.args[4] = s.ogCIOTableList.toArray();	    }	    if(sendVSGMessage) {		createMessage = messages[messageIndex++];		createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;		createMessage.type = J3dMessage.VIEWSPECIFICGROUP_INIT;		createMessage.universe = universe;		createMessage.args[0] = s.changedViewGroup;		createMessage.args[1] = s.changedViewList;		createMessage.args[2] = s.keyList;	    }	    createMessage = messages[messageIndex++];	    createMessage.threads = s.notifyThreads;	    createMessage.type = J3dMessage.INSERT_NODES;	    createMessage.universe = universe;	    createMessage.args[0] = s.nodeList.toArray();	    if (newCtArr != null) {                createMessage.args[1] = transformInterface;                createMessage.args[2] = newCtArr;	    } else {                createMessage.args[1] = null;                createMessage.args[2] = null;	    } 	    if (s.viewScopedNodeList != null) {		createMessage.args[3] = s.viewScopedNodeList;		createMessage.args[4] = s.scopedNodesViewList;	    }	               // execute user behavior's initialize methods	    int sz = s.behaviorNodes.size();            for (int i=0; i < sz; i++) {                BehaviorRetained b;                b = (BehaviorRetained)s.behaviorNodes.get(i);                b.executeInitialize();            }            s.behaviorNodes.clear();	    createMessage = messages[messageIndex++];            	    createMessage.threads = J3dThread.UPDATE_BEHAVIOR;	    createMessage.type = J3dMessage.BEHAVIOR_ACTIVATE;	    createMessage.universe = universe;	    if (sendMessages == true) {		VirtualUniverse.mc.processMessage(messages);	    }            if (nodeType == NodeRetained.SWITCH) {	        // force reEvaluation of switch children		SwitchRetained sw = (SwitchRetained)this;	        sw.setWhichChild(sw.whichChild, true);            }	    //Reset SetLiveState to free up memory.	    s.reset(null);        }    }      void checkClearLive(NodeRetained child,                        J3dMessage messages[], int messageIndex, 			int childIndex, NodeRetained linkNode) {	checkClearLive(child, localToVworldKeys, inSharedGroup,		       messages, messageIndex, childIndex, linkNode);    }        /**     * This checks if clearLive needs to be called.  If it does, it gets the     * needed info and calls it.     */    void checkClearLive(NodeRetained child, HashKey keys[],			boolean isShared,                        J3dMessage messages[], int messageIndex,			int childIndex, NodeRetained linkNode) {        SceneGraphObject me = this.source;	J3dMessage destroyMessage;	boolean sendMessages = false;	boolean sendOGMessage = true;	boolean sendVSGMessage = true;  	int i, j;	TransformGroupRetained tg;        if (me.isLive()) {            SetLiveState s = universe.setLiveState;            s.reset(locale);	    s.refCount = refCount;            s.inSharedGroup = isShared;            s.inBackgroundGroup = inBackgroundGroup;            s.inViewSpecificGroup = inViewSpecificGroup;            s.keys = keys;            s.fogs = fogs;            s.lights = lights;	    s.altAppearances = altAppearances;	    s.modelClips = modelClips;            // Issue 312: Allocate data structures if we are in a ViewSpecificGroup	    if (s.inViewSpecificGroup && 		(s.changedViewGroup == null)) {		s.changedViewGroup = new ArrayList();		s.changedViewList = new ArrayList();		s.keyList = new int[10];		s.viewScopedNodeList = new ArrayList();

⌨️ 快捷键说明

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