📄 renderingenvironmentstructure.java
字号:
for (j= 0; j < nModelClips; j++) { if (intersectedBounds[j] == closestBounds) { modelClip = intersectedModelClips[j]; break; } } } return (modelClip); } } int processModelClips(ArrayList globalModelClips, RenderAtom ra, int nModelClips) { int size = globalModelClips.size(); int i, k, n; ModelClipRetained modelClip; Bounds bounds = ra.localeVwcBounds; ModelClipRetained[] shapeScopedModelClip; if (size > 0) { for (i = 0; i < size; i++) { modelClip = (ModelClipRetained) globalModelClips.get(i); if (modelClip.enableFlag == true && modelClip.region != null && modelClip.switchState.currentSwitchOn) { if (modelClip.region.intersect(bounds) == true) { n = ((Shape3DRetained)ra.geometryAtom.source).numModelClips; shapeScopedModelClip = ((Shape3DRetained)ra.geometryAtom.source).modelClips; if (modelClip.isScoped) { for (k = 0; k < n; k++) { // then check if the modelClip is scoped to // this group if (shapeScopedModelClip[k] == modelClip) { intersectedBounds[nModelClips] = modelClip.region; intersectedModelClips[nModelClips++] = modelClip; break; } } } else { intersectedBounds[nModelClips] = modelClip.region; intersectedModelClips[nModelClips++] = modelClip; } } } } } return nModelClips; } BackgroundRetained getApplicationBackground(BoundingSphere bounds, Locale viewLocale, View view) { BackgroundRetained bg = null; Bounds closestBounds; BackgroundRetained back; int i = 0, j = 0; int nbacks; ArrayList globalBgs; // Need to lock lockObj, since on a multi-processor // system with 2 views on a single universe, there might // be councurrent access synchronized(lockObj) { nbacks = 0; if (intersectedBounds.length < numberOfBgs) intersectedBounds = new Bounds[numberOfBgs]; if ((globalBgs = (ArrayList)viewScopedBackgrounds.get(view)) != null) { nbacks = processBgs(globalBgs, bounds, nbacks, viewLocale); } nbacks = processBgs(nonViewScopedBackgrounds, bounds, nbacks, viewLocale); // If there are no intersections, set to black. if (nbacks == 1) { bg = intersectedBacks[0]; } else if (nbacks > 1) { closestBounds = bounds.closestIntersection(intersectedBounds); for (j=0; j<nbacks; j++) { if (intersectedBounds[j] == closestBounds) { bg = intersectedBacks[j]; //System.err.println("matched " + closestBounds); break; } } } return (bg); } } // Called while holding lockObj lock int processBgs(ArrayList globalBgs, BoundingSphere bounds, int nbacks, Locale viewLocale) { int size = globalBgs.size(); int i; BackgroundRetained back; for (i=0; i<size; i++) { back = (BackgroundRetained)globalBgs.get(i); if (back.transformedRegion != null && back.switchState.currentSwitchOn) { if (back.cachedLocale != viewLocale) { localeBounds = (Bounds) back.transformedRegion.clone(); // Translate the transformed region back.cachedLocale.hiRes.difference(viewLocale.hiRes, localeTranslation); localeXform.setIdentity(); localeXform.setTranslation(localeTranslation); localeBounds.transform(localeXform); if (localeBounds.intersect(bounds) == true) { intersectedBounds[nbacks] = localeBounds; intersectedBacks[nbacks++] = back; } } else { if (back.transformedRegion.intersect(bounds) == true) { intersectedBounds[nbacks] = back.transformedRegion; intersectedBacks[nbacks++] = back; } } } } return nbacks; } double[] backClipDistanceInVworld (BoundingSphere bounds, View view) { int i,j; int nclips; Bounds closestBounds; ClipRetained clip; boolean backClipActive; double[] backClipDistance; double distance; ArrayList globalClips; // Need to lock intersectedBounds, since on a multi-processor // system with 2 views on a single universe, there might // be councurrent access synchronized(lockObj) { backClipDistance = null; backClipActive = false; nclips = 0; distance = 0.0; if (intersectedBounds.length < numberOfClips) intersectedBounds = new Bounds[numberOfClips]; if ((globalClips = (ArrayList)viewScopedClips.get(view)) != null) { nclips = processClips(globalClips, bounds, nclips); } nclips = processClips(nonViewScopedClips, bounds, nclips); if (nclips == 1) { distance = intersectedClips[0].backDistanceInVworld; backClipActive = true; } else if (nclips > 1) { closestBounds = bounds.closestIntersection(intersectedBounds); for (j=0; j < nclips; j++) { if (intersectedBounds[j] == closestBounds) { distance = intersectedClips[j].backDistanceInVworld; backClipActive = true; break; } } } if (backClipActive) { backClipDistance = new double[1]; backClipDistance[0] = distance; } return (backClipDistance); } } int processClips(ArrayList globalClips, BoundingSphere bounds, int nclips) { int i; int size = globalClips.size(); ClipRetained clip; for (i=0 ; i<size; i++) { clip = (ClipRetained)globalClips.get(i); if (clip.transformedRegion != null && clip.transformedRegion.intersect(bounds) == true && clip.switchState.currentSwitchOn) { intersectedBounds[nclips] = clip.transformedRegion; intersectedClips[nclips++] = clip; } } return nclips; } void updateLight(Object[] args) { Object[] objs; LightRetained light = (LightRetained)args[0]; int component = ((Integer)args[1]).intValue(); // Store the value to be updated during object update // If its an ambient light, then if color changed, update immediately if ((component & (LightRetained.INIT_MIRROR)) != 0) { light.initMirrorObject(args); } if (light instanceof AmbientLightRetained && ((component & LightRetained.COLOR_CHANGED) != 0)) { light.updateImmediateMirrorObject(args); } else if ((component & (LightRetained.COLOR_CHANGED| LightRetained.INIT_MIRROR | PointLightRetained.POSITION_CHANGED | PointLightRetained.ATTENUATION_CHANGED| DirectionalLightRetained.DIRECTION_CHANGED | SpotLightRetained.DIRECTION_CHANGED | SpotLightRetained.CONCENTRATION_CHANGED | SpotLightRetained.ANGLE_CHANGED)) != 0) { objs = getObjectArray(); objs[0] = args[0]; objs[1] = args[1]; objs[2] = args[2]; objs[3] = args[3]; objs[4] = args[4]; objList.add(objs); } else if ((component & LightRetained.CLEAR_MIRROR) != 0) { light.clearMirrorObject(args); } else { light.updateImmediateMirrorObject(args); } } void updateBackground(Object[] args) { BackgroundRetained bg = (BackgroundRetained)args[0]; bg.updateImmediateMirrorObject(args); } void updateFog(Object[] args) { Object[] objs; FogRetained fog = (FogRetained)args[0]; int component = ((Integer)args[1]).intValue(); if ((component & FogRetained.INIT_MIRROR) != 0) { fog.initMirrorObject(args); // Color, distance et all should be updated when renderer // is not running .. objs = getObjectArray(); objs[0] = args[0]; objs[1] = args[1]; objs[2] = args[2]; objs[3] = args[3]; objs[4] = args[4]; objList.add(objs); } else if ((component & FogRetained.CLEAR_MIRROR) != 0) { fog.clearMirrorObject(args); // Store the value to be updated during object update } else if ((component & (FogRetained.COLOR_CHANGED | LinearFogRetained.FRONT_DISTANCE_CHANGED| LinearFogRetained.BACK_DISTANCE_CHANGED | ExponentialFogRetained.DENSITY_CHANGED)) != 0) { objs = getObjectArray(); objs[0] = args[0]; objs[1] = args[1]; objs[2] = args[2]; objs[3] = args[3]; objs[4] = args[4]; objList.add(objs); } else { fog.updateImmediateMirrorObject(args); } } void updateAltApp(Object[] args) { AlternateAppearanceRetained altApp = (AlternateAppearanceRetained)args[0]; int component = ((Integer)args[1]).intValue(); if ((component & AlternateAppearanceRetained.INIT_MIRROR) != 0) { AlternateAppearanceRetained altapp = (AlternateAppearanceRetained)args[0]; altapp.initMirrorObject(args); } else if ((component & AlternateAppearanceRetained.CLEAR_MIRROR) != 0) { AlternateAppearanceRetained altapp = (AlternateAppearanceRetained)args[0]; altapp.clearMirrorObject(args); } else { altApp.updateImmediateMirrorObject(args); } } void updateClip(Object[] args) { ClipRetained clip = (ClipRetained)args[0]; clip.updateImmediateMirrorObject(args); } void updateModelClip(Object[] args) { ModelClipRetained modelClip = (ModelClipRetained)args[0]; Object[] objs; int component = ((Integer)args[1]).intValue(); if ((component & ModelClipRetained.INIT_MIRROR) != 0) { modelClip.initMirrorObject(args); } if ((component & ModelClipRetained.CLEAR_MIRROR) != 0) { modelClip.clearMirrorObject(args); } else if ((component & (ModelClipRetained.PLANES_CHANGED | ModelClipRetained.INIT_MIRROR | ModelClipRetained.PLANE_CHANGED)) != 0) { objs = getObjectArray(); objs[0] = args[0]; objs[1] = args[1]; objs[2] = args[2]; objs[3] = args[3]; objs[4] = args[4]; objList.add(objs); } else { modelClip.updateImmediateMirrorObject(args); } } void updateBoundingLeaf(Object[] args) { BoundingLeafRetained bl = (BoundingLeafRetained)args[0]; Object[] users = (Object[])(args[3]); bl.updateImmediateMirrorObject(args); // Now update all users of this bounding leaf object for (int i = 0; i < users.length; i++) { LeafRetained mLeaf = (LeafRetained)users[i]; mLeaf.updateBoundingLeaf(); } } void updateShape3D(Object[] args) { Shape3DRetained shape = (Shape3DRetained)args[0]; shape.updateImmediateMirrorObject(args); } void updateOrientedShape3D(Object[] args) { OrientedShape3DRetained shape = (OrientedShape3DRetained)args[4]; shape.updateImmediateMirrorObject(args); } void updateMorph(Object[] args) { MorphRetained morph = (MorphRetained)args[0]; morph.updateImmediateMirrorObject(args); } void updateTransformChange() { int i,j; Object[] nodes, nodesArr; BoundingLeafRetained bl; LightRetained ml; UnorderList arrList; int size; targets = universe.transformStructure.getTargetList(); blUsers = universe.transformStructure.getBlUsers(); // process misc environment nodes arrList = targets.targetList[Targets.ENV_TARGETS]; if (arrList != null) { size = arrList.size(); nodesArr = arrList.toArray(false); for (j = 0; j < size; j++) { nodes = (Object[])nodesArr[j]; for (i = 0; i < nodes.length; i++) { if (nodes[i] instanceof LightRetained) { ml = (LightRetained)nodes[i]; ml.updateImmediateTransformChange(); xformChangeList.add(nodes[i]); } else if (nodes[i] instanceof FogRetained) { FogRetained mfog = (FogRetained) nodes[i]; mfog.updateImmediateTransformChange(); xformChangeList.add(nodes[i]); } else if (nodes[i] instanceof AlternateAppearanceRetained){ AlternateAppearanceRetained mAltApp = (AlternateAppearanceRetained) nodes[i]; mAltApp.updateImmediateTransformChange(); xformChangeList.add(nodes[i]); } else if (nodes[i] instanceof BackgroundRetained) { BackgroundRetained bg = (BackgroundRetained) nodes[i]; bg.updateImmediateTransformChange(); } else if (nodes[i] instanceof ModelClipRetained) { ModelClipRetained mc = (ModelClipRetained) nodes[i]; mc.updateImmediateTransformChange(); } } } } // process BoundingLeaf nodes arrList = targets.targetList[Targets.BLN_TARGETS]; if (arrList != null) { size = arrList.size(); nodesArr = arrList.toArray(false); for (j = 0; j < size; j++) { nodes = (Object[])nodesArr[j]; for (i = 0; i < nodes.length; i++) { bl = (BoundingLeafRetained)nodes[i]; bl.updateImmediateTransformChange(); } } } // Now notify the list of all users of bounding leaves // to update its boundingleaf transformed region if (blUsers != null) { for (i = 0; i < blUsers.size(); i++) { LeafRetained leaf = (LeafRetained) blUsers.get(i); leaf.updateBoundingLeaf(); } } targets = null; blUsers = null; } // The first element is TRUE, if alternate app is in effect // The second element return the appearance that should be used // Note , I can't just return null for app, then I don't know // if the appearance is null or if the alternate app in not
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -