📄 renderingenvironmentstructure.java
字号:
// in effect Object[] getInfluencingAppearance(RenderAtom ra, View view) { AlternateAppearanceRetained altApp = null; int i, j, k, n, nAltApp;; Bounds closestBounds; Bounds bounds; Object[] retVal; ArrayList globalAltApps; retVal = new Object[2]; if (ra.geometryAtom.source.inBackgroundGroup) { retVal[0] = Boolean.FALSE; return retVal; } // Need to lock lockObj, since on a multi-processor // system with 2 views on a single universe, there might // be councurrent access synchronized(lockObj) { nAltApp = 0; bounds = ra.localeVwcBounds; if (intersectedBounds.length < numberOfAltApps) intersectedBounds = new Bounds[numberOfAltApps]; if ((globalAltApps =(ArrayList)viewScopedAltAppearances.get(view)) != null) { nAltApp = processAltApps(globalAltApps, ra, nAltApp); } nAltApp = processAltApps(nonViewScopedAltAppearances, ra, nAltApp); altApp = null; if (nAltApp == 1) altApp = intersectedAltApps[0]; else if (nAltApp > 1) { closestBounds = bounds.closestIntersection(intersectedBounds); for (j= 0; j < nAltApp; j++) { if (intersectedBounds[j] == closestBounds) { altApp = intersectedAltApps[j]; break; } } } if (altApp == null) { retVal[0] = Boolean.FALSE; return retVal; } else { retVal[0] = Boolean.TRUE; retVal[1] = altApp.appearance; return retVal; } } } // Called while holding lockObj lock int processAltApps(ArrayList globalAltApps, RenderAtom ra, int nAltApp) { int size = globalAltApps.size(); AlternateAppearanceRetained altApp; int i, k, n; Bounds bounds = ra.localeVwcBounds; AlternateAppearanceRetained[] shapeScopedAltApp; if (size > 0) { for (i = 0; i < size; i++) { altApp = (AlternateAppearanceRetained) globalAltApps.get(i); // System.err.println("altApp.region = "+altApp.region+" altApp.switchState.currentSwitchOn = "+altApp.switchState.currentSwitchOn+" intersect = "+altApp.region.intersect(ra.geometryAtom.vwcBounds)); // System.err.println("altApp.isScoped = "+altApp.isScoped); // Note : There is no enable check for fog if (altApp.region != null && altApp.switchState.currentSwitchOn) { if (altApp.region.intersect(bounds) == true) { n = ((Shape3DRetained)ra.geometryAtom.source).numAltApps; shapeScopedAltApp = ((Shape3DRetained)ra.geometryAtom.source).altApps; if (altApp.isScoped) { for (k = 0; k < n; k++) { // then check if the light is scoped to // this group if (altApp == shapeScopedAltApp[k]) { intersectedBounds[nAltApp] = altApp.region; intersectedAltApps[nAltApp++] = altApp; break; } } } else { intersectedBounds[nAltApp] = altApp.region; intersectedAltApps[nAltApp++] = altApp; } } } } } return nAltApp; } void initViewSpecificInfo(J3dMessage m) { int[] keys = (int[])m.args[2]; ArrayList vlists = (ArrayList)m.args[1]; ArrayList vsgs = (ArrayList)m.args[0]; if (vsgs != null) { // System.err.println("===> non null Vsg"); int size = vsgs.size(); for (int i = 0; i < size; i++) { ViewSpecificGroupRetained v = (ViewSpecificGroupRetained)vsgs.get(i); ArrayList l = (ArrayList)vlists.get(i); int index = keys[i]; // System.err.println("v = "+v+" index = "+index+" l = "+l); v.cachedViewList.add(index, l); /* for (int k = 0; k < v.cachedViewList.size(); k++) { System.err.println("v = "+v+" k = "+k+" v.cachedViewList.get(k) = "+v.cachedViewList.get(k)); } */ } } } void clearViewSpecificInfo(J3dMessage m) { int[] keys = (int[])m.args[1]; ArrayList vsgs = (ArrayList)m.args[0]; if (vsgs != null) { int size = vsgs.size(); for (int i = 0; i < size; i++) { ViewSpecificGroupRetained v = (ViewSpecificGroupRetained)vsgs.get(i); int index = keys[i]; if (index == -1) { int csize = v.cachedViewList.size(); for (int j = 0; j< csize; j++) { ArrayList l = (ArrayList)v.cachedViewList.get(j); l.clear(); } v.cachedViewList.clear(); } else { ArrayList l = (ArrayList) v.cachedViewList.remove(index); l.clear(); } } } } void updateViewSpecificGroupChanged(J3dMessage m) { int component = ((Integer)m.args[0]).intValue(); Object[] objAry = (Object[])m.args[1]; ArrayList ltList = null; ArrayList fogList = null; ArrayList mclipList = null; ArrayList altAppList = null; ArrayList bgList = null; ArrayList clipList = null; int idx; if (((component & ViewSpecificGroupRetained.ADD_VIEW) != 0) || ((component & ViewSpecificGroupRetained.SET_VIEW) != 0)) { int i; Object obj; View view = (View)objAry[0]; ArrayList vsgList = (ArrayList)objAry[1]; ArrayList leafList = (ArrayList)objAry[2]; int[] keyList = (int[])objAry[3]; int size = vsgList.size(); // Don't add null views if (view != null) { for (i = 0; i < size; i++) { ViewSpecificGroupRetained vsg = (ViewSpecificGroupRetained)vsgList.get(i); int index = keyList[i]; vsg.updateCachedInformation(ViewSpecificGroupRetained.ADD_VIEW, view, index); } size = leafList.size(); // Leaves is non-null only for the top VSG if (size > 0) { // Now process the list of affected leaved for( i = 0; i < size; i++) { obj = leafList.get(i); if (obj instanceof LightRetained) { ((LightRetained)obj).isViewScoped = true; numberOfLights++; if (ltList == null) { if ((ltList = (ArrayList)viewScopedLights.get(view)) == null) { ltList = new ArrayList(); viewScopedLights.put(view, ltList); } } ltList.add(obj); } if (obj instanceof FogRetained) { ((FogRetained)obj).isViewScoped = true; numberOfFogs++; if (fogList == null) { if ((fogList= (ArrayList)viewScopedFogs.get(view)) == null) { fogList = new ArrayList(); viewScopedFogs.put(view, fogList); } } fogList.add(obj); } if (obj instanceof ModelClipRetained) { ((ModelClipRetained)obj).isViewScoped = true; numberOfModelClips++; if (mclipList == null) { if ((mclipList= (ArrayList)viewScopedModelClips.get(view)) == null) { mclipList = new ArrayList(); viewScopedModelClips.put(view, mclipList); } } mclipList.add(obj); } if (obj instanceof AlternateAppearanceRetained) { ((AlternateAppearanceRetained)obj).isViewScoped = true; numberOfAltApps++; if (altAppList == null) { if ((altAppList= (ArrayList)viewScopedAltAppearances.get(view)) == null) { altAppList = new ArrayList(); viewScopedAltAppearances.put(view, altAppList); } } altAppList.add(obj); } if (obj instanceof ClipRetained) { ((ClipRetained)obj).isViewScoped = true; numberOfClips++; if (clipList == null) { if ((clipList= (ArrayList)viewScopedClips.get(view)) == null) { clipList = new ArrayList(); viewScopedClips.put(view, clipList); } } clipList.add(obj); } if (obj instanceof BackgroundRetained) { ((BackgroundRetained)obj).isViewScoped = true; numberOfBgs++; if (bgList == null) { if ((bgList= (ArrayList)viewScopedBackgrounds.get(view)) == null) { bgList = new ArrayList(); viewScopedBackgrounds.put(view, bgList); } } bgList.add(obj); } } if (numberOfLights > retlights.length) retlights = new LightRetained[numberOfLights]; if (intersectedFogs.length < numberOfFogs) intersectedFogs = new FogRetained[numberOfFogs]; if (intersectedAltApps.length < numberOfAltApps) intersectedAltApps = new AlternateAppearanceRetained[numberOfAltApps]; if (intersectedBacks.length < numberOfBgs) intersectedBacks = new BackgroundRetained[numberOfBgs]; if (intersectedClips.length < numberOfClips) intersectedClips = new ClipRetained[numberOfClips]; if (intersectedModelClips.length < numberOfModelClips) intersectedModelClips = new ModelClipRetained[numberOfModelClips]; } } } if (((component & ViewSpecificGroupRetained.REMOVE_VIEW) != 0)|| ((component & ViewSpecificGroupRetained.SET_VIEW) != 0)) { int i; Object obj; ArrayList vsgList; ArrayList leafList; int[] keyList; View view; if ((component & ViewSpecificGroupRetained.REMOVE_VIEW) != 0) { view = (View)objAry[0]; vsgList = (ArrayList)objAry[1]; leafList = (ArrayList)objAry[2]; keyList = (int[])objAry[3]; } else { view = (View)objAry[4]; vsgList = (ArrayList)objAry[5]; leafList = (ArrayList)objAry[6]; keyList = (int[])objAry[7]; } // Don't add null views if (view != null) { int size = vsgList.size(); for (i = 0; i < size; i++) { ViewSpecificGroupRetained vsg = (ViewSpecificGroupRetained)vsgList.get(i); int index = keyList[i]; vsg.updateCachedInformation(ViewSpecificGroupRetained.REMOVE_VIEW, view, index); } size = leafList.size(); // Leaves is non-null only for the top VSG if (size > 0) { // Now process the list of affected leaved for( i = 0; i < size; i++) { obj = leafList.get(i); if (obj instanceof LightRetained) { ((LightRetained)obj).isViewScoped = false; numberOfLights--; if (ltList == null) { ltList = (ArrayList)viewScopedLights.get(view); } ltList.remove(obj); } if (obj instanceof FogRetained) { ((FogRetained)obj).isViewScoped = false; numberOfFogs--; if (fogList == null) { fogList = (ArrayList)viewScopedFogs.get(view); } fogList.remove(obj); } if (obj instanceof ModelClipRetained) { ((ModelClipRetained)obj).isViewScoped = false; numberOfModelClips--; if (mclipList == null) { mclipList = (ArrayList)viewScopedModelClips.get(view); } mclipList.remove(obj); } if (obj instanceof AlternateAppearanceRetained) { ((AlternateAppearanceRetained)obj).isViewScoped = false; numberOfAltApps--; if (altAppList == null) { altAppList = (ArrayList)viewScopedAltAppearances.get(view); } altAppList.remove(obj); } if (obj instanceof ClipRetained) { ((ClipRetained)obj).isViewScoped = false; numberOfClips--; if (clipList == null) { clipList = (ArrayList)viewScopedClips.get(view); } clipList.remove(obj); } if (obj instanceof BackgroundRetained) { ((BackgroundRetained)obj).isViewScoped = false; numberOfBgs++; if (bgList == null) { bgList = (ArrayList)viewScopedBackgrounds.get(view); } bgList.remove(obj); } } // If there are no more lights scoped to the view, // remove the mapping if (ltList != null && ltList.size() == 0) viewScopedLights.remove(view); if (fogList != null && fogList.size() == 0) viewScopedFogs.remove(view); if (mclipList != null && mclipList.size() == 0) viewScopedModelClips.remove(view); if (altAppList != null && altAppList.size() == 0) viewScopedAltAppearances.remove(view); if (clipList != null && clipList.size() == 0) viewScopedClips.remove(view); if (bgList != null && bgList.size() == 0) viewScopedBackgrounds.remove(view); } } } } boolean isLightScopedToThisView(Object obj, View view) { LightRetained light = (LightRetained)obj; if (light.isViewScoped) { ArrayList l = (ArrayList)viewScopedLights.get(view); // If this is a scoped lights, but has no views then .. if (l == null || !l.contains(light)) return false; } return true; } boolean isFogScopedToThisView(Object obj, View view) { FogRetained fog = (FogRetained)obj; if (fog.isViewScoped) { ArrayList l = (ArrayList)viewScopedFogs.get(view); // If this is a scoped fog, but has no views then .. if (l ==null || !l.contains(fog)) return false; } return true; } boolean isAltAppScopedToThisView(Object obj, View view) { AlternateAppearanceRetained altApp = (AlternateAppearanceRetained)obj; if (altApp.isViewScoped) { ArrayList l = (ArrayList)viewScopedAltAppearances.get(view); // If this is a scoped altapp, but has no views then .. if (l == null || !l.contains(altApp)) return false; } return true; } boolean isBgScopedToThisView(Object obj, View view) { BackgroundRetained bg = (BackgroundRetained)obj; if (bg.isViewScoped) { ArrayList l = (ArrayList)viewScopedBackgrounds.get(view); // If this is a scoped bg, but has no views then .. if (l == null || !l.contains(bg)) return false; } return true; } boolean isClipScopedToThisView(Object obj, View view) { ClipRetained clip = (ClipRetained)obj; if (clip.isViewScoped) { ArrayList l = (ArrayList)viewScopedClips.get(view); // If this is a scoped clip, but has no views then .. if (l == null || !l.contains(clip)) return false; } return true; } boolean isMclipScopedToThisView(Object obj, View view) { ModelClipRetained mclip = (ModelClipRetained)obj; if (mclip.isViewScoped) { ArrayList l = (ArrayList)viewScopedModelClips.get(view); // If this is a scoped mclip, but has no views then .. if (l == null || !l.contains(mclip)) return false; } return true; } void cleanup() {}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -