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

📄 shape3dretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	    	    // Remove all the al app	    for (i = 0; i < numAltApps; i++)		altApps[i] = null;	    numAltApps = 0;	}    }    boolean isStatic() {	if (source.getCapability(Shape3D.ALLOW_APPEARANCE_WRITE) ||	    source.getCapability(Shape3D.ALLOW_GEOMETRY_WRITE) ||	    source.getCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE)) {	    return false;	} else {	    return true;	}    }    boolean staticXformCanBeApplied() {	// static xform can be applied if	// . shape is not pickable or collidable	// . geometry is not being shared by more than one shape nodes	// . geometry will be put in display list	// . geometry is not readable        // no static xform if shape is pickable or collidable because	// otherwise the static xform will have to be applied to the	// currentLocalToVworld in the intersect test, it will then	// be more costly and really beat the purpose of eliminating	// the static transform group        if (isPickable || isCollidable ||	    	source.getCapability(Shape3D.ALLOW_PICKABLE_WRITE) ||	    	source.getCapability(Shape3D.ALLOW_COLLIDABLE_WRITE)) {	    return false;	}	if (appearance != null &&	    (appearance.transparencyAttributes != null && appearance.transparencyAttributes.transparencyMode != TransparencyAttributes.NONE))	    return false;		GeometryRetained geo;	boolean alphaEditable;	for (int i=0; i<geometryList.size(); i++) {	    geo = (GeometryRetained) geometryList.get(i);	    if (geo != null) {		if (geo.refCnt > 1) {		    return false;		}		alphaEditable = isAlphaEditable(geo);		if (geo instanceof GeometryArrayRetained) {		    geo.isEditable = !((GeometryArrayRetained)geo).isWriteStatic();		    // TODO: for now if vertex data can be returned, then		    // don't apply static transform		    if (geo.source.getCapability(				GeometryArray.ALLOW_COORDINATE_READ) ||			geo.source.getCapability(				GeometryArray.ALLOW_NORMAL_READ))			return false;		}		if (!geo.canBeInDisplayList(alphaEditable)) {		    return false;		}	    } 	}	return true;    }    void compile(CompileState compState) {	AppearanceRetained newApp;	super.compile(compState);	if (isStatic() && staticXformCanBeApplied()) {	    mergeFlag = SceneGraphObjectRetained.MERGE;            if (J3dDebug.devPhase && J3dDebug.debug) {	        compState.numShapesWStaticTG++;	    }	} else 	{	    mergeFlag = SceneGraphObjectRetained.DONT_MERGE;	    compState.keepTG = true;	}        if (J3dDebug.devPhase && J3dDebug.debug) {	    compState.numShapes++;	}	if (appearance != null) {	    appearance.compile(compState);	    // Non-static apperanace can still be compiled, since in compile	    // state we will be grouping all shapes that have same appearance	    // so, when the appearance changes, all the shapes will be affected	    // For non-static appearances, we don't get an equivalent appearance	    // from the compile state	    if (appearance.isStatic()) {		newApp = compState.getAppearance(appearance);		appearance = newApp;	    }	}	for (int i = 0; i < geometryList.size(); i++) {	    GeometryRetained geo = (GeometryRetained)geometryList.get(i);	    if (geo != null)		geo.compile(compState);	}		    }    void merge(CompileState compState) {			if (mergeFlag == SceneGraphObjectRetained.DONT_MERGE) {	    // no need to save the staticTransform here	    TransformGroupRetained saveStaticTransform = 					compState.staticTransform;	    compState.staticTransform = null;	    super.merge(compState);	    compState.staticTransform = saveStaticTransform;        } else {	    super.merge(compState);	}	if (shapeIsMergeable(compState)) {	    compState.addShape(this);	}    }    boolean shapeIsMergeable(CompileState  compState) {	boolean mergeable = true;	AppearanceRetained newApp;	int i;	    	GeometryRetained geometry = null;	int index = 0;	i = 0;	/*	if (isPickable)	    return false;	*/	// For now, don't merge if the shape has static transform	if (staticTransform != null)	    return false;	// If this shape's to be immediate parent is orderedGroup or a switchNode	// this shape is not mergerable	if (parent instanceof OrderedGroupRetained ||	    parent instanceof SwitchRetained)	    return false;	// Get the first geometry that is non-null	while (geometry == null && index < geometryList.size()) {	    geometry = (GeometryRetained) geometryList.get(index);	    index++;	}	if (!(geometry  instanceof GeometryArrayRetained)) {	    return false;	}	GeometryArrayRetained firstGeo = (GeometryArrayRetained) geometry;		for(i=index; (i<geometryList.size() && mergeable); i++) {	    geometry = (GeometryRetained) geometryList.get(i);	    if (geometry != null) {		GeometryArrayRetained geo = (GeometryArrayRetained)geometry;		if (! geo.isWriteStatic())		    mergeable = false;		if (geo.vertexFormat != firstGeo.vertexFormat)		    mergeable = false;		    	    }	}	// For now, turn off lots of capability bits 	if (source.getCapability(Shape3D.ALLOW_COLLISION_BOUNDS_WRITE) ||	    source.getCapability(Shape3D.ALLOW_APPEARANCE_WRITE) || 	    source.getCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE) ||	    source.getCapability(Shape3D.ALLOW_AUTO_COMPUTE_BOUNDS_WRITE) ||	    source.getCapability(Shape3D.ALLOW_BOUNDS_WRITE) ||	    source.getCapability(Shape3D.ALLOW_COLLIDABLE_WRITE) ||	    source.getCapability(Shape3D.ALLOW_PICKABLE_WRITE) ||	    source.getCapability(Shape3D.ALLOW_GEOMETRY_WRITE)) {	    mergeable = false;	}	  	return mergeable;          }    void getMirrorObjects( ArrayList list, HashKey k) {	Shape3DRetained ms;	if (inSharedGroup) {	    if (k.count == 0) {		//		System.err.println("===> CAN NEVER BE TRUE");		return;	    }	    else {		ms = getMirrorShape(k);	    }	}	else {	    ms = (Shape3DRetained)mirrorShape3D.get(0);	}		list.add(getGeomAtom(ms));	    }        // Called on the mirror Object    void addLight(LightRetained light) {	 LightRetained[] newlights;	 int i, n;	 Shape3DRetained ms;	 if (lights == null) {	     lights = new LightRetained[10];	 }	 else if (lights.length == numlights) {	     newlights = new LightRetained[numlights*2];	     for (i=0; i<numlights; i++) {		 newlights[i] = lights[i];	     }	     lights = newlights;	 }	 lights[numlights] = light;	 numlights++;    }    // called on the mirror object    void removeLight(LightRetained light) {	 int i;	 for (i=0; i<numlights; i++) {	     if (lights[i] == light) {		 lights[i] = null;		 break;	     }	 }	 // Shift everyone down one.	 for (i++; i<numlights; i++) {	     lights[i-1] = lights[i];	 }	 numlights--;    }    // Called on the mirror object    void addFog(FogRetained fog) {	 FogRetained[] newfogs;	 int i;	 if (fogs == null) {	     fogs = new FogRetained[10];	 }	 else if (fogs.length == numfogs) {	     newfogs = new FogRetained[numfogs*2];	     for (i=0; i<numfogs; i++) {		 newfogs[i] = fogs[i];	     }	     fogs = newfogs;	 }	 fogs[numfogs] = fog;	 numfogs++;    }    // called on the mirror object    void removeFog(FogRetained fog) {		 int i;	 for (i=0; i<numfogs; i++) {	     if (fogs[i] == fog) {		 fogs[i] = null;		 break;	     }	 }	 // Shift everyone down one.	 for (i++; i<numfogs; i++) {	     fogs[i-1] = fogs[i];	 }	 numfogs--;    }    // Called on the mirror object    void addModelClip(ModelClipRetained modelClip) {	 ModelClipRetained[] newModelClips;	 int i;	 	 if (modelClips == null) {	     modelClips = new ModelClipRetained[10];	 }	 else if (modelClips.length == numModelClips) {	     newModelClips = new ModelClipRetained[numModelClips*2];	     for (i=0; i<numModelClips; i++) {		 newModelClips[i] = modelClips[i];	     }	     modelClips = newModelClips;	 }	 modelClips[numModelClips] = modelClip;	 numModelClips++;    }    // called on the mirror object    void removeModelClip(ModelClipRetained modelClip) {		 int i;	 for (i=0; i<numModelClips; i++) {	     if (modelClips[i] == modelClip) {		 modelClips[i] = null;		 break;	     }	 }	 // Shift everyone down one.	 for (i++; i<numModelClips; i++) {	     modelClips[i-1] = modelClips[i];	 }	 numModelClips--;    }    // Called on the mirror object    void addAltApp(AlternateAppearanceRetained aApp) {	 AlternateAppearanceRetained[] newAltApps;	 int i;	 if (altApps == null) {	     altApps = new AlternateAppearanceRetained[10];	 }	 else if (altApps.length == numAltApps) {	     newAltApps = new AlternateAppearanceRetained[numAltApps*2];	     for (i=0; i<numAltApps; i++) {		 newAltApps[i] = altApps[i];	     }	     altApps = newAltApps;	 }	 altApps[numAltApps] = aApp;	 numAltApps++;    }    // called on the mirror object    void removeAltApp(AlternateAppearanceRetained aApp) {	int i;	 for (i=0; i<numAltApps; i++) {	     if (altApps[i] == aApp) {		 altApps[i] = null;		 break;	     }	 }	 // Shift everyone down one.	 for (i++; i<numAltApps; i++) {	     altApps[i-1] = altApps[i];	 }	 numAltApps--;    }    void updatePickable(HashKey keys[], boolean pick[]) {       super.updatePickable(keys, pick);      Shape3DRetained shape;      if (!inSharedGroup) {	  shape = (Shape3DRetained) mirrorShape3D.get(0);	  shape.isPickable = pick[0];      } else {	  int size = mirrorShape3D.size();	  for (int j=0; j< keys.length; j++) {	      for (int i=0; i < size; i++) {		  shape = (Shape3DRetained) mirrorShape3D.get(i);		  if (keys[j].equals(shape.key)) {		      shape.isPickable = pick[j];		      break;		  }	      }	  }      }    }    void updateCollidable(HashKey keys[], boolean collide[]) {       super.updateCollidable(keys, collide);      Shape3DRetained shape;      if (!inSharedGroup) {	  shape = (Shape3DRetained) mirrorShape3D.get(0);	  shape.isCollidable = collide[0];      } else {	  int size = mirrorShape3D.size();	  for (int j=0; j< keys.length; j++) {	      for (int i=0; i < size; i++) {		  shape = (Shape3DRetained) mirrorShape3D.get(i);		  if (keys[j].equals(shape.key)) {		      shape.isCollidable = collide[j];		      break;		  }	      }	  }      }    }    // New 1.2.1 code ....    // Remove the old geometry atoms and reInsert    // the new geometry atoms and update the transform    // target list        private void sendDataChangedMessage( GeometryRetained newGeom ) {		int i, j, gaCnt;	GeometryAtom[] newGAArray =  null;	GeometryAtom[] oldGAArray = null;	GeometryAtom[] newGeometryAtoms = null;	int geometryCnt = 0;	GeometryRetained geometry = null;		int s3dMSize = mirrorShape3D.size();	if(s3dMSize < 1)	    return;		Shape3DRetained mS3d = (Shape3DRetained) mirrorShape3D.get(0);		mS3d.mirrorShape3DLock.writeLock();		GeometryAtom oldGA = mS3d.geomAtom;		GeometryAtom newGA = new GeometryAtom();	

⌨️ 快捷键说明

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