📄 locale.java
字号:
destroyMessage.type = J3dMessage.REMOVE_NODES; destroyMessage.universe = universe; destroyMessage.args[0] = universe.setLiveState.nodeList.toArray(); if (universe.setLiveState.viewScopedNodeList != null) { destroyMessage.args[3] = universe.setLiveState.viewScopedNodeList; destroyMessage.args[4] = universe.setLiveState.scopedNodesViewList; } if (messages == null) { VirtualUniverse.mc.processMessage(destroyMessage); destroyMessage = new J3dMessage(); } else { destroyMessage = messages[startIndex++]; } destroyMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT; destroyMessage.type = J3dMessage.VIEWSPECIFICGROUP_CLEAR; destroyMessage.universe = universe; destroyMessage.args[0] = universe.setLiveState.changedViewGroup; destroyMessage.args[1] = universe.setLiveState.keyList; if (messages == null) { VirtualUniverse.mc.processMessage(destroyMessage); } else { destroyMessage = messages[startIndex++]; } if (universe.isEmpty()) { VirtualUniverse.mc.postRequest(MasterControl.EMPTY_UNIVERSE, universe); } universe.setLiveState.reset(null); // cleanup memory universe.notifyStructureChangeListeners(false, this, branchGroup); } /** * Replaces the branch graph rooted at oldGroup in the list of * branch graphs with the branch graph rooted at * newGroup. * @param oldGroup root of the branch graph to be replaced. * @param newGroup root of the branch graph that will replace the old * branch graph. * @exception IllegalStateException if this Locale has been * removed from its VirtualUniverse. * @exception CapabilityNotSetException if the ALLOW_DETACH capability is * not set in the old BranchGroup node. * @exception MultipleParentException if the new BranchGroup node * is already live. */ public void replaceBranchGraph(BranchGroup oldGroup, BranchGroup newGroup){ if (universe == null) { throw new IllegalStateException(J3dI18N.getString("Locale4")); } if (! oldGroup.getCapability(BranchGroup.ALLOW_DETACH)) { throw new CapabilityNotSetException(J3dI18N.getString("Locale1")); } if (((BranchGroupRetained)newGroup.retained).parent != null) { throw new MultipleParentException(J3dI18N.getString("Locale3")); } universe.resetWaitMCFlag(); universe.notifyStructureChangeListeners(true, this, newGroup); synchronized (universe.sceneGraphLock) { doReplaceBranchGraph(oldGroup, newGroup); universe.setLiveState.reset(this); } universe.notifyStructureChangeListeners(false, this, oldGroup); universe.waitForMC(); } // The method that does the work once the lock is acquired. void doReplaceBranchGraph(BranchGroup oldGroup, BranchGroup newGroup){ BranchGroupRetained obgr = (BranchGroupRetained)oldGroup.retained; BranchGroupRetained nbgr = (BranchGroupRetained)newGroup.retained; J3dMessage createMessage; J3dMessage destroyMessage; branchGroups.removeElement(oldGroup); obgr.attachedToLocale = false; universe.setLiveState.reset(this); obgr.clearLive(universe.setLiveState); destroyMessage = new J3dMessage(); destroyMessage.threads = J3dThread.UPDATE_RENDER| J3dThread.UPDATE_RENDERING_ENVIRONMENT; destroyMessage.type = J3dMessage.ORDERED_GROUP_REMOVED; destroyMessage.universe = universe; destroyMessage.args[0] = universe.setLiveState.ogList.toArray(); destroyMessage.args[1] = universe.setLiveState.ogChildIdList.toArray(); destroyMessage.args[3] = universe.setLiveState.ogCIOList.toArray(); destroyMessage.args[4] = universe.setLiveState.ogCIOTableList.toArray(); VirtualUniverse.mc.processMessage(destroyMessage); destroyMessage = new J3dMessage(); destroyMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT; destroyMessage.type = J3dMessage.VIEWSPECIFICGROUP_CLEAR; destroyMessage.universe = universe; destroyMessage.args[0] = universe.setLiveState.changedViewGroup; destroyMessage.args[1] = universe.setLiveState.keyList; VirtualUniverse.mc.processMessage(destroyMessage); destroyMessage = new J3dMessage(); destroyMessage.threads = universe.setLiveState.notifyThreads; destroyMessage.type = J3dMessage.REMOVE_NODES; destroyMessage.universe = universe; destroyMessage.args[0] = universe.setLiveState.nodeList.toArray(); VirtualUniverse.mc.processMessage(destroyMessage); branchGroups.addElement(newGroup); nbgr.attachedToLocale = true; universe.setLiveState.reset(this); universe.setLiveState.currentTransforms[0] = new Transform3D[2]; universe.setLiveState.currentTransforms[0][0] = new Transform3D(); universe.setLiveState.currentTransforms[0][1] = new Transform3D(); universe.setLiveState.currentTransformsIndex[0] = new int[2]; universe.setLiveState.currentTransformsIndex[0][0] = 0; universe.setLiveState.currentTransformsIndex[0][1] = 0; universe.setLiveState.localToVworld = universe.setLiveState.currentTransforms; universe.setLiveState.localToVworldIndex = universe.setLiveState.currentTransformsIndex; universe.setLiveState.branchGroupPaths = new ArrayList(); universe.setLiveState.branchGroupPaths.add(new BranchGroupRetained[0]); universe.setLiveState.orderedPaths = new ArrayList(1); universe.setLiveState.orderedPaths.add(new OrderedPath()); universe.setLiveState.switchStates = new ArrayList(1); universe.setLiveState.switchStates.add(new SwitchState(false)); nbgr.setLive(universe.setLiveState); createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_RENDER| J3dThread.UPDATE_RENDERING_ENVIRONMENT; createMessage.type = J3dMessage.ORDERED_GROUP_INSERTED; createMessage.universe = universe; createMessage.args[0] = universe.setLiveState.ogList.toArray(); createMessage.args[1] = universe.setLiveState.ogChildIdList.toArray(); createMessage.args[2] = universe.setLiveState.ogOrderedIdList.toArray(); createMessage.args[3] = universe.setLiveState.ogCIOList.toArray(); createMessage.args[4] = universe.setLiveState.ogCIOTableList.toArray(); VirtualUniverse.mc.processMessage(createMessage); // XXXX: make these two into one message createMessage = new J3dMessage(); createMessage.threads = universe.setLiveState.notifyThreads; createMessage.type = J3dMessage.INSERT_NODES; createMessage.universe = universe; createMessage.args[0] = universe.setLiveState.nodeList.toArray(); createMessage.args[1] = null; createMessage.args[2] = null; if (universe.setLiveState.viewScopedNodeList != null) { createMessage.args[3] = universe.setLiveState.viewScopedNodeList; createMessage.args[4] = universe.setLiveState.scopedNodesViewList; } VirtualUniverse.mc.processMessage(createMessage); Object behaviorNodes[] = universe.setLiveState.behaviorNodes.toArray(); if (universe.isEmpty()) { VirtualUniverse.mc.postRequest(MasterControl.EMPTY_UNIVERSE, universe); } for (int i=0; i< behaviorNodes.length; i++) { ((BehaviorRetained) behaviorNodes[i]).executeInitialize(); } createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_BEHAVIOR; createMessage.type = J3dMessage.BEHAVIOR_ACTIVATE; createMessage.universe = universe; VirtualUniverse.mc.processMessage(createMessage); // Free up memory. universe.setLiveState.reset(null); } /** * Get number of branch graphs in this Locale. * @return number of branch graphs in this Locale. */ public int numBranchGraphs(){ return branchGroups.size(); } /** * Gets an Enumeration object of all branch graphs in this Locale. * @return an Enumeration object of all branch graphs. * @exception IllegalStateException if this Locale has been * removed from its VirtualUniverse. */ public Enumeration getAllBranchGraphs(){ if (universe == null) { throw new IllegalStateException(J3dI18N.getString("Locale4")); } return branchGroups.elements(); } void validateModeFlagAndPickShape(int mode, int flags, PickShape pickShape) { if (universe == null) { throw new IllegalStateException(J3dI18N.getString("Locale4")); } if((mode != PickInfo.PICK_BOUNDS) && (mode != PickInfo.PICK_GEOMETRY)) { throw new IllegalArgumentException(J3dI18N.getString("Locale5")); } if((pickShape instanceof PickPoint) && (mode == PickInfo.PICK_GEOMETRY)) { throw new IllegalArgumentException(J3dI18N.getString("Locale6")); } if(((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) && ((flags & PickInfo.ALL_GEOM_INFO) != 0)) { throw new IllegalArgumentException(J3dI18N.getString("Locale7")); } if((mode == PickInfo.PICK_BOUNDS) && (((flags & (PickInfo.CLOSEST_GEOM_INFO | PickInfo.ALL_GEOM_INFO | PickInfo.CLOSEST_DISTANCE | PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) { throw new IllegalArgumentException(J3dI18N.getString("Locale8")); } if((pickShape instanceof PickBounds) && (((flags & (PickInfo.CLOSEST_GEOM_INFO | PickInfo.ALL_GEOM_INFO | PickInfo.CLOSEST_DISTANCE | PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) { throw new IllegalArgumentException(J3dI18N.getString("Locale9")); } } /** * Returns an array referencing all the items that are pickable below this * <code>Locale</code> that intersect with PickShape. * The resultant array is unordered. * * @param pickShape the description of this picking volume or area. * * @exception IllegalStateException if this Locale has been * removed from its VirtualUniverse. * * @see BranchGroup#pickAll */ public SceneGraphPath[] pickAll( PickShape pickShape ) { if (universe == null) { throw new IllegalStateException(J3dI18N.getString("Locale4")); } PickInfo[] pickInfoArr = pickAll( PickInfo.PICK_BOUNDS, PickInfo.SCENEGRAPHPATH, pickShape); if(pickInfoArr == null) { return null; } SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length]; for( int i=0; i<sgpArr.length; i++) { sgpArr[i] = pickInfoArr[i].getSceneGraphPath(); } return sgpArr; } /** * Returns an array unsorted references to all the PickInfo objects that are pickable * below this <code>Locale</code> that intersect with PickShape. * The accuracy of the pick is set by the pick mode. The mode include : * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned * is specified via a masked variable, flags, indicating which components are * present in each returned PickInfo object. * * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. * * @param flags a mask indicating which components are present in each PickInfo object. * This is specified as one or more individual bits that are bitwise "OR"ed together to * describe the PickInfo data. The flags include : * <ul> * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> * </ul> * * @param pickShape the description of this picking volume or area. * * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and * ALL_GEOM_INFO. * * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode * is set to PICK_GEOMETRY. * * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS * nor PICK_GEOMETRY. * * @exception IllegalArgumentException if pick mode is PICK_BOUNDS * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. * * @exception IllegalArgumentException if pickShape is PickBounds * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. * * @exception IllegalStateException if this Locale has been * removed from its VirtualUniverse. * * @exception CapabilityNotSetException if the mode is * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit * is not set in any Geometry objects referred to by any shape * node whose bounds intersects the PickShape. * * @exception CapabilityNotSetException if flags contains any of * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO * or ALL_GEOM_INFO, and the capability bits that control reading of * coordinate data are not set in any GeometryArray object referred * to by any shape node that intersects the PickShape. * The capability bits that must be set to avoid this exception are as follows : * <ul> * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ * (in addition to one of the above)</li> * </ul> * * @see BranchGroup#pickAll(int,int,javax.media.j3d.PickShape) * @see PickInfo * * @since Java 3D 1.4 * */ public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) { validateModeFlagAndPickShape(mode, flags, pickShape); GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape); return PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -