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

📄 rasterretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        isEditable = source.getCapability(Raster.ALLOW_OFFSET_WRITE) ||	    source.getCapability(Raster.ALLOW_POSITION_WRITE) ||	    ((type & Raster.RASTER_COLOR) != 0 &&	     source.getCapability(Raster.ALLOW_IMAGE_WRITE)) ||	    ((type & Raster.RASTER_DEPTH) != 0 &&	     source.getCapability(				     Raster.ALLOW_DEPTH_COMPONENT_WRITE)) ||	    source.getCapability( Raster.ALLOW_SIZE_WRITE);	super.markAsLive();    }    void clearLive(int refCount) {	super.clearLive(refCount);	if (texture != null)	    texture.clearLive(refCount);	if (depthComponent != null)	    depthComponent.clearLive(refCount);    }    /*    // Simply pass along to the NodeComponents    void compile(CompileState compState) {	setCompiled();	if (image != null)	    image.compile(compState);	if (depthComponent != null)	    depthComponent.compile(compState);    }    */    void computeBoundingBox() {	if(clipMode == Raster.CLIP_IMAGE) {	    // Disable view frustum culling by setting the raster's bounds to 	    // infinity.     	    Point3d minBounds = new Point3d(Double.NEGATIVE_INFINITY, 		    Double.NEGATIVE_INFINITY, 		    Double.NEGATIVE_INFINITY);	    Point3d maxBounds = new Point3d(Double.POSITIVE_INFINITY, 		    Double.POSITIVE_INFINITY, 		    Double.POSITIVE_INFINITY); 	    geoBounds.setUpper(maxBounds);	    geoBounds.setLower(minBounds);	} else {	    Point3d center = new Point3d();	    center.x = position.x;	    center.y = position.y;	    center.z = position.z;	    geoBounds.setUpper(center);	    geoBounds.setLower(center);	}    }    void update() {	computeBoundingBox();    }       private void sendChangedMessage(int threads, Object arg1, Object arg2) {	synchronized(liveStateLock) {	    if (source.isLive()) {		synchronized (universeList) {		    int numMessages = universeList.size();		    J3dMessage[] m = new J3dMessage[numMessages];		    for (int i=0; i<numMessages; i++) {			m[i] = new J3dMessage();			m[i].type = J3dMessage.GEOMETRY_CHANGED;			m[i].threads = threads;			m[i].args[0] = Shape3DRetained.			    getGeomAtomsArray((ArrayList)userLists.get(i));			m[i].args[1] = this;			Object[] obj = new Object[2];			obj[0] = arg1;			obj[1] = arg2;			m[i].args[2] = obj;			m[i].args[3] = new Integer(changedFrequent);			m[i].universe = (VirtualUniverse)universeList.get(i);		    }		    VirtualUniverse.mc.processMessage(m);		}	    }	}    }    void execute(Canvas3D cv, RenderAtom ra, boolean isNonUniformScale,            boolean updateAlpha, float alpha,            int screen, boolean ignoreVertexColors) {        // Compute the offset position of the raster        // This has to be done at render time because we need access        // to the Canvas3D info        // Check if adjusted position needs to be computed        Point3d adjPos = new Point3d();    // Position of the Raster after adjusting for dstOffset        adjPos.set(position);                Point2d winCoord = new Point2d();  // Position of Raster in window coordinates        Transform3D localToImagePlate = new Transform3D();  // Local to Image plate transform              Point3d clipCoord = computeWinCoord(cv, ra, winCoord, adjPos, localToImagePlate);        // Test raster for out of bounds in Z.        if (clipCoord == null) {            return;        }                if(clipMode == Raster.CLIP_POSITION) {            // Do trivial reject test on Raster position.            if(!isRasterClipPositionInside(clipCoord)) {                return;            }        }        // Add the destination offset to the Raster position in window coordinates        winCoord.x += xDstOffset;        winCoord.y += yDstOffset;        // System.err.println("Step 2 : adjPos " + adjPos + " winCoord " + winCoord);                        if((type == Raster.RASTER_COLOR) || (type == Raster.RASTER_COLOR_DEPTH)) {            float devCoordZ = (float) (clipCoord.z * 0.5 - 0.5);             // Do textfill stuffs            if (texture != null) {                // setup Texture pipe.                                cv.updateTextureForRaster(texture);                                                cv.textureFill(this, winCoord, (float) devCoordZ, alpha);                // Restore texture pipe.                cv.restoreTextureBin();            }        }        if((type == Raster.RASTER_DEPTH) || (type == Raster.RASTER_COLOR_DEPTH)) {            Point2i srcOffset = new Point2i(xSrcOffset, ySrcOffset);                        if (clipMode == Raster.CLIP_IMAGE) {                clipImage(cv, ra, winCoord, srcOffset);            }                        computeObjCoord(cv, winCoord, adjPos, localToImagePlate);             cv.executeRasterDepth(cv.ctx,                    (float) adjPos.x,                    (float) adjPos.y,                    (float) adjPos.z,                    srcOffset.x,                    srcOffset.y,                    width,                    height,                    depthComponent.width,                    depthComponent.height,                    depthComponent.type,                    ((DepthComponentIntRetained) depthComponent).depthData);                            }    }            /**     * Clips the image against the window.  This method simulates     * clipping the image by determining the subimage that will be     * drawn and adjusting the xOffset and yOffset accordingly.  Only     * clipping against the left and top edges needs to be handled,     * clipping against the right and bottom edges will be handled by     * the underlying graphics library automatically.     */    private void clipImage(Canvas3D canvas, RenderAtom ra, Point2d winCoord, Point2i srcOffset) {	        if ((winCoord.x > 0) && (winCoord.y > 0)) {            return;        }		// Check if the Raster point will be culled	// Note that w use 1 instead of 0, because when hardware	// tranform the coordinate back to winCoord it may get	// a small negative value due to numerically inaccurancy.	// This clip the Raster away and cause flickering 	// (see bug 4732965)	if(winCoord.x < 1) {	    // Negate the window position and use this as the offset	    srcOffset.x = (int)-winCoord.x+1;	    winCoord.x = 1;	}		if(winCoord.y < 1) {	    // Negate the window position and use this as the offset	    srcOffset.y = (int)-winCoord.y+1;	    winCoord.y = 1;	}		//check if user-specified subimage is smaller than the clipped image	if (srcOffset.x < xSrcOffset)	    srcOffset.x = xSrcOffset;	if(srcOffset.y < ySrcOffset)	    srcOffset.y = ySrcOffset;            }          private boolean isRasterClipPositionInside(Point3d clipCoord) {        return (clipCoord.x >= -1.0) && (clipCoord.x <= 1.0) &&                (clipCoord.y >= -1.0) && (clipCoord.y <= 1.0);    }        private void computeObjCoord(Canvas3D canvas, Point2d winCoord, Point3d objCoord,                                Transform3D localToImagePlate) {	// Back transform this pt. from window to object coordinates	// Assumes this method is ALWAYS called after computeWinCoord has been 	// called. computeWinCoord calculates the Vworld to Image Plate Xform. 	// This method simply uses it without recomputing it.		canvas.getPixelLocationInImagePlate(winCoord.x, winCoord.y, objCoord.z, 					    objCoord);	// Get image plate to object coord transform	// inv(P x M)	localToImagePlate.invert();	localToImagePlate.transform(objCoord);    }        private Point3d computeWinCoord(Canvas3D canvas, RenderAtom ra, 				Point2d winCoord, Point3d objCoord,                                Transform3D localToImagePlate) {	// Get local to Vworld transform	RenderMolecule rm = ra.renderMolecule;	if (rm == null) {	    // removeRenderAtom() may set ra.renderMolecule to null	    // in RenderBin before this renderer thread run. 	    return null;        }                // MT safe issue: We can't reference ra.renderMolecule below since        // RenderBin thread may set it to null anytime. Use rm instead.	Transform3D lvw = rm.localToVworld[rm.localToVworldIndex[				 NodeRetained.LAST_LOCAL_TO_VWORLD]];                Point3d clipCoord3 = new Point3d();        clipCoord3.set(objCoord);        Point4d clipCoord4 = new Point4d();                // Transform point from local coord. to clipping coord.        lvw.transform(clipCoord3);        canvas.vworldToEc.transform(clipCoord3);        canvas.projTrans.transform(clipCoord3, clipCoord4);                // clip check in Z        if((clipCoord4.w <= 0.0) ||                 (clipCoord4.z > clipCoord4.w) || (-clipCoord4.z > clipCoord4.w)) {            return null;        }        double invW = 1.0 / clipCoord4.w;                clipCoord3.x = clipCoord4.x * invW;        clipCoord3.y = clipCoord4.y * invW;        clipCoord3.z = clipCoord4.z * invW;      	// Get Vworld to image plate Xform	canvas.getLastVworldToImagePlate(localToImagePlate);		// v' = vwip x lvw x v 			// 		where v' = transformed vertex, 	// 			  lvw = local to Vworld Xform	//			  vwip = Vworld to Image plate Xform	//			  v = vertex		// Compute composite local to image plate Xform	localToImagePlate.mul(lvw);		// Transform the Raster's position from object to world coordinates	localToImagePlate.transform(objCoord);	        	// Get the window coordinates of this point	canvas.getPixelLocationFromImagePlate(objCoord, winCoord);                return clipCoord3;    }        int getClassType() {	return RASTER_TYPE;    }        // notifies the Raster mirror object that the image data in a referenced    // ImageComponent object is changed.    // Currently we are not making use of this information.    void notifyImageComponentImageChanged(ImageComponentRetained image,                                        ImageComponentUpdateInfo value) {    }    boolean intersect(PickShape pickShape, PickInfo pickInfo, int flags, Point3d iPnt,                      GeometryRetained geom, int geomIndex) {         return false;     }           boolean intersect(Bounds targetBound) {	return false;    }    boolean intersect(Point3d[] pnts) {	return false;    }    boolean intersect(Transform3D thisToOtherVworld, GeometryRetained		      geom) {	return false;    }    boolean intersect(Transform3D thisLocalToVworld, 		       Transform3D otherLocalToVworld,		       GeometryRetained geom) {	return false;    }    boolean intersect(Transform3D thisLocalToVworld, Bounds targetBound) {	return false;    }    void handleFrequencyChange(int bit) {	if (bit == Raster.ALLOW_IMAGE_WRITE)	    setFrequencyChangeMask(bit, 0x1);	    }}

⌨️ 快捷键说明

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