📄 morphretained.java
字号:
} } } } GeometryArrayRetained mgaR = (GeometryArrayRetained)mga.retained; mgaR.setCoordRefFloat(Mcoord); if ((vFormat & GeometryArray.COLOR) != 0) mgaR.setColorRefFloat(Mcolor); // *******Need to normalize normals if ((vFormat & GeometryArray.NORMALS) != 0) mgaR.setNormalRefFloat(Mnormal); if ((vFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { for (k = 0; k < texCoordSetCount; k++) { mgaR.setTexCoordRefFloat(k, MtexCoord[k]); } } } void updateImmediateMirrorObject(Object[] objs) { int i; int component = ((Integer)objs[1]).intValue(); Shape3DRetained[] msArr = (Shape3DRetained[]) objs[2]; if ((component & APPEARANCE_CHANGED) != 0) { Object[] arg = (Object[])objs[3]; int val = ((Integer)arg[1]).intValue(); for ( i = msArr.length-1; i >=0; i--) { msArr[i].appearance = (AppearanceRetained)arg[0]; msArr[i].changedFrequent = val; } } if ((component & APPEARANCEOVERRIDE_CHANGED) != 0) { Object[] arg = (Object[])objs[3]; int val = ((Integer)arg[1]).intValue(); System.err.println("ChangedFrequent = "+changedFrequent); for ( i = msArr.length-1; i >=0; i--) { msArr[i].appearanceOverrideEnable = ((Boolean)arg[0]).booleanValue(); msArr[i].changedFrequent = val; } } } /** * assign a name to this node when it is made live. */ void setLive(SetLiveState s) { int i, j; Shape3DRetained shape; ArrayList msList = new ArrayList(); GeometryAtom ga; int oldrefCount = refCount; super.doSetLive(s); nodeId = universe.getNodeId(); for (i = 0; i < numGeometryArrays; i++) { synchronized(geometryArrays[i].liveStateLock) { geometryArrays[i].setLive(inBackgroundGroup, s.refCount); // Add this morph object as user the first time if (oldrefCount <= 0) { geometryArrays[i].addMorphUser(this); } } } if (this.morphedGeometryArray == null){ initMorphedGeometry(); } ((GeometryArrayRetained)(morphedGeometryArray.retained)).setLive(inBackgroundGroup, s.refCount); if (boundsAutoCompute) { GeometryArrayRetained mga = (GeometryArrayRetained)morphedGeometryArray.retained; // Compute the bounds once mga.incrComputeGeoBounds(); // This compute the bbox if dirty mga.decrComputeGeoBounds(); localBounds.setWithLock(mga.geoBounds); } if (inSharedGroup) { for (i=0; i<s.keys.length; i++) { shape = new Shape3DRetained(); shape.key = s.keys[i]; shape.localToVworld = new Transform3D[1][]; shape.localToVworldIndex = new int[1][]; j = s.keys[i].equals(localToVworldKeys, 0, localToVworldKeys.length); if(j < 0) { System.err.println("MorphRetained : Can't find hashKey"); } shape.localToVworld[0] = localToVworld[j]; shape.localToVworldIndex[0] = localToVworldIndex[j]; shape.branchGroupPath = (BranchGroupRetained []) branchGroupPaths.get(j); shape.isPickable = s.pickable[i]; shape.isCollidable = s.collidable[i]; shape.initMirrorShape3D(s, this, j); mirrorShape3D.add(j, shape); msList.add(shape); // Add any scoped lights to the mirror shape if (s.lights != null) { ArrayList l = (ArrayList)s.lights.get(j); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addLight((LightRetained)l.get(m)); } } } // Add any scoped fog if (s.fogs != null) { ArrayList l = (ArrayList)s.fogs.get(j); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addFog((FogRetained)l.get(m)); } } } // Add any scoped modelClip if (s.modelClips != null) { ArrayList l = (ArrayList)s.modelClips.get(j); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addModelClip((ModelClipRetained)l.get(m)); } } } // Add any scoped alt app if (s.altAppearances != null) { ArrayList l = (ArrayList)s.altAppearances.get(j); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addAltApp((AlternateAppearanceRetained)l.get(m)); } } } if (s.viewLists != null) shape.viewList = (ArrayList)s.viewLists.get(i); else shape.viewList = null; // ((GeometryArrayRetained)(morphedGeometryArray.retained)).addUser(shape); ga = Shape3DRetained.getGeomAtom(shape); // Add the geometry atom for this shape to the Targets s.nodeList.add(ga); if (s.transformTargets != null && s.transformTargets[i] != null) { s.transformTargets[i].addNode(ga, Targets.GEO_TARGETS); } if (s.switchTargets != null && s.switchTargets[i] != null) { s.switchTargets[i].addNode(shape, Targets.GEO_TARGETS); shape.closestSwitchParent = s.closestSwitchParents[i]; shape.closestSwitchIndex = s.closestSwitchIndices[i]; } shape.switchState = (SwitchState)s.switchStates.get(j); } } else { shape = new Shape3DRetained(); shape.localToVworld = new Transform3D[1][]; shape.localToVworldIndex = new int[1][]; shape.localToVworld[0] = this.localToVworld[0]; shape.localToVworldIndex[0] = this.localToVworldIndex[0]; shape.branchGroupPath = (BranchGroupRetained []) branchGroupPaths.get(0); shape.isPickable = s.pickable[0]; shape.isCollidable = s.collidable[0]; shape.initMirrorShape3D(s, this, 0); mirrorShape3D.add(shape); msList.add(shape); // Add any scoped lights to the mirror shape if (s.lights != null) { ArrayList l = (ArrayList)s.lights.get(0); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addLight((LightRetained)l.get(m)); } } } // Add any scoped fog if (s.fogs != null) { ArrayList l = (ArrayList)s.fogs.get(0); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addFog((FogRetained)l.get(m)); } } } // Add any scoped modelClip if (s.modelClips != null) { ArrayList l = (ArrayList)s.modelClips.get(0); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addModelClip((ModelClipRetained)l.get(m)); } } } // Add any scoped alt app if (s.altAppearances != null) { ArrayList l = (ArrayList)s.altAppearances.get(0); if (l != null) { for (int m = 0; m < l.size(); m++) { shape.addAltApp((AlternateAppearanceRetained)l.get(m)); } } } if (s.viewLists != null) shape.viewList = (ArrayList)s.viewLists.get(0); else shape.viewList = null; // ((GeometryArrayRetained)(morphedGeometryArray.retained)).addUser(shape); ga = Shape3DRetained.getGeomAtom(shape); // Add the geometry atom for this shape to the Targets s.nodeList.add(ga); if (s.transformTargets != null && s.transformTargets[0] != null) { s.transformTargets[0].addNode(ga, Targets.GEO_TARGETS); } if (s.switchTargets != null && s.switchTargets[0] != null) { s.switchTargets[0].addNode(shape, Targets.GEO_TARGETS); shape.closestSwitchParent = s.closestSwitchParents[0]; shape.closestSwitchIndex = s.closestSwitchIndices[0]; } shape.switchState = (SwitchState)s.switchStates.get(0); } if (appearance != null) { synchronized(appearance.liveStateLock) { appearance.setLive(inBackgroundGroup, s.refCount); appearance.initMirrorObject(); if (appearance.renderingAttributes != null) visible = appearance.renderingAttributes.visible; for (int k = 0; k < msList.size(); k++) { Shape3DRetained sh = (Shape3DRetained)msList.get(k); sh.appearance = (AppearanceRetained)appearance.mirror; appearance.addAMirrorUser(sh); } } } else { for (int k = 0; k < msList.size(); k++) { Shape3DRetained sh = (Shape3DRetained)msList.get(k); sh.appearance = null; } } s.notifyThreads |= (J3dThread.UPDATE_GEOMETRY | J3dThread.UPDATE_TRANSFORM | J3dThread.UPDATE_RENDER | J3dThread.UPDATE_RENDERING_ATTRIBUTES); // Need to clone the geometry , if its indexed ... if (refCount == 1 && this.geometryArrays[0] instanceof IndexedGeometryArrayRetained) { J3dMessage mChangeMessage = new J3dMessage(); mChangeMessage.type = J3dMessage.MORPH_CHANGED; mChangeMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES; mChangeMessage.args[0] = this; mChangeMessage.args[1]= new Integer(GEOMETRY_CHANGED); mChangeMessage.universe = universe; VirtualUniverse.mc.processMessage(mChangeMessage); } super.markAsLive(); } /** * assign a name to this node when it is made live. */ void clearLive(SetLiveState s) { int i, j; Shape3DRetained shape; Object[] shapes; ArrayList appList = new ArrayList(); GeometryAtom ga; super.clearLive(s); for (i = 0; i < numGeometryArrays; i++) { synchronized(geometryArrays[i].liveStateLock) { geometryArrays[i].clearLive(s.refCount); // Remove this morph object as user, when the last branch // is clearlived if (refCount <= 0) { geometryArrays[i].removeMorphUser(this); } } } GeometryArrayRetained mga = (GeometryArrayRetained)morphedGeometryArray.retained; mga.clearLive( s.refCount); if (inSharedGroup) { shapes = mirrorShape3D.toArray(); for (i=0; i<s.keys.length; i++) { for (j=0; j<shapes.length; j++) { shape = (Shape3DRetained)shapes[j]; if (shape.key.equals(s.keys[i])) { // clearMirrorShape(shape); mirrorShape3D.remove(j); if (s.switchTargets != null && s.switchTargets[i] != null) { s.switchTargets[i].addNode(shape, Targets.GEO_TARGETS); } if (appearance != null) appList.add(shape); // ((GeometryArrayRetained)(morphedGeometryArray.retained)).removeUser(shape); ga = Shape3DRetained.getGeomAtom(shape); // Add the geometry atoms for this shape to the Targets s.nodeList.add(ga); if (s.transformTargets != null && s.transformTargets[i] != null) { s.transformTargets[i].addNode(ga, Targets.GEO_TARGETS); } } } } } else { // Only entry 0 is valid shape = (Shape3DRetained)mirrorShape3D.get(0); // clearMirrorShape(shape); mirrorShape3D.remove(0); if (s.switchTargets != null && s.switchTargets[0] != null) { s.switchTargets[0].addNode(shape, Targets.GEO_TARGETS); } if (appearance != null) appList.add(shape); // ((GeometryArrayRetained)(morphedGeometryArray.retained)).removeUser(shape); ga = Shape3DRetained.getGeomAtom(shape); // Add the geometry atom for this shape to the Targets s.nodeList.add(ga); if (s.transformTargets != null && s.transformTargets[0] != null) { s.transformTargets[0].addNode(ga, Targets.GEO_TARGETS); } } if (appearance != null) { synchronized(appearance.liveStateLock) { appearance.clearLive(s.refCount); for (int k = 0; k < appList.size(); k++) { appearance.removeAMirrorUser((Shape3DRetained)appList.get(k)); } } } s.notifyThreads |= (J3dThread.UPDATE_GEOMETRY | J3dThread.UPDATE_TRANSFORM | // This is used to clear the scope info // of all the mirror shapes J3dThread.UPDATE_RENDERING_ENVIRONMENT | J3dThread.UPDATE_RENDER); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -