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

📄 canvasviewcache.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            // do the reset here.            if (canvas.offScreen) {                screenViewCache.scrvcDirtyMask[dirtyIndex] = 0;            }        }        if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_2)) {	    if(cvcDirtyMask != 0)		System.err.println("cvcDirtyMask : " +  cvcDirtyMask);	    if(scrvcDirtyMask != 0)		System.err.println("scrvcDirtyMask : "+ scrvcDirtyMask);	    if(viewCache.vcDirtyMask != 0)		System.err.println("vcDirtyMask : " +  viewCache.vcDirtyMask);	}	// NOTE: This fix is only fixing the symptoms, but not the	// root of the bug.  We shouldn't have to check for null here.	if(viewCache.vpRetained == null) {	     System.err.println("CanvasViewCache : Error! viewCache.vpRetained is null");	    return;	}	// This flag is use to force a computation when a ViewPlatformTransform	// is detected. No sync. needed. We're doing a read of t/f.	// XXXX: Peeking at the dirty flag is a hack. Need to revisit this.	boolean vprNotDirty = (viewCache.vpRetained.vprDirtyMask == 0);        // Issue 131: If not manual, it has to be considered as an onscreen canvas.	if(!canvas.manualRendering &&	   (vprNotDirty) &&	   (cvcDirtyMask == 0) &&	   (scrvcDirtyMask == 0) &&	   (viewCache.vcDirtyMask == 0) &&	    !(updateLastTime && (doInfinite != lastDoInfinite))) {	    if(frustumBBox != null)		computefrustumBBox(frustumBBox);	    // Copy the computed data into cvc.	    if(cvc != null) {		copyComputedCanvasViewCache(cvc, doInfinite);	    }	    lastDoInfinite = doInfinite;	    updateLastTime = false;	    return;	}	lastDoInfinite = doInfinite;	updateLastTime = true;	if(currentFlag) {	    vpcToVworld.set(viewCache.vpRetained.getCurrentLocalToVworld(null));	}	else {	    vpcToVworld.set(viewCache.vpRetained.getLastLocalToVworld(null));	}	// System.err.println("vpcToVworld is \n" + vpcToVworld);        try {	    vworldToVpc.invert(vpcToVworld);	}	catch (SingularMatrixException e) {	    vworldToVpc.setIdentity();	    //System.err.println("SingularMatrixException encountered when doing vworldToVpc invert");	}        if (doInfinite) {            vworldToVpc.getRotation(infVworldToVpc);	}	// Compute global flags	if (monoscopicViewPolicy == View.CYCLOPEAN_EYE_VIEW)	    effectiveMonoscopicViewPolicy = viewCache.monoscopicViewPolicy;	else	    effectiveMonoscopicViewPolicy = monoscopicViewPolicy;	// Recompute info about current canvas window	computeCanvasInfo();	// Compute coexistence center (in plate coordinates)	computeCoexistenceCenter();	// Get Eye position in image-plate coordinates	cacheEyePosition();	// Compute VPC to COE and COE to PLATE transforms	computeVpcToCoexistence();	computeCoexistenceToPlate();	// Compute view and projection matrices	computeView(doInfinite);	computePlateToVworld();	if (!currentFlag) {	    // save the result for use in RasterRetained computeWinCoord	    lastVworldToLeftPlate.set(vworldToLeftPlate);	}	computeHeadToVworld();	if (frustumBBox != null)	    computefrustumBBox(frustumBBox);	// Issue 109: cvc should *always* be null        assert cvc == null;	if(cvc != null)	    copyComputedCanvasViewCache(cvc, doInfinite);	canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY;	if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_1)) {	    // Print some data :	    System.err.println("useStereo = " + useStereo);	    System.err.println("leftProjection:\n" + leftProjection);	    System.err.println("rightProjection:\n " + rightProjection);	    System.err.println("leftVpcToEc:\n" + leftVpcToEc);	    System.err.println("rightVpcToEc:\n" + rightVpcToEc);	    System.err.println("vpcToVworld:\n" + vpcToVworld);	    System.err.println("vworldToVpc:\n" + vworldToVpc);	    if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_2)) {		int i;		for (i = 0; i < leftFrustumPlanes.length; i++) {		    System.err.println("leftFrustumPlanes " + i + " is " +				       leftFrustumPlanes[i]);		}		for (i = 0; i < rightFrustumPlanes.length; i++) {		    System.err.println("rightFrustumPlanes " + i + " is " +				       rightFrustumPlanes[i]);		}	    }	}    }    private void computeCanvasInfo() {	// Copy the screen width and height info into derived parameters	physicalScreenWidth = screenViewCache.physicalScreenWidth;	physicalScreenHeight = screenViewCache.physicalScreenHeight;	screenWidth = screenViewCache.screenWidth;	screenHeight = screenViewCache.screenHeight;	metersPerPixelX = screenViewCache.metersPerPixelX;	metersPerPixelY = screenViewCache.metersPerPixelY;	// If a multi-screen virtual device (e.g. Xinerama) is being used,	// then awtCanvasX and awtCanvasY are relative to the origin of that	// virtual screen.  Subtract the origin of the physical screen to	// compute the origin in physical (image plate) coordinates.	Rectangle screenBounds = canvas.graphicsConfiguration.getBounds();	canvasX = awtCanvasX - screenBounds.x;	canvasY = awtCanvasY - screenBounds.y;	// Use awtCanvasWidth and awtCanvasHeight as reported.	canvasWidth = awtCanvasWidth;	canvasHeight = awtCanvasHeight;	// Convert the window system ``pixel'' coordinate location and size	// of the window into physical units (meters) and coordinate system.	// Window width and Height in meters	physicalWindowWidth = canvasWidth * metersPerPixelX;	physicalWindowHeight = canvasHeight * metersPerPixelY;	// Compute the 4 corners of the window in physical units	physicalWindowXLeft = metersPerPixelX *	    (double) canvasX;	physicalWindowYBottom = metersPerPixelY *	    (double)(screenHeight - canvasHeight - canvasY);	physicalWindowXRight = physicalWindowXLeft + physicalWindowWidth;	physicalWindowYTop = physicalWindowYBottom + physicalWindowHeight;	//  Cache the physical location of the center of the window	physicalWindowCenter.x =	    physicalWindowXLeft + physicalWindowWidth / 2.0;	physicalWindowCenter.y =	    physicalWindowYBottom + physicalWindowHeight / 2.0;	physicalWindowCenter.z = 0.0;	if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_2)) {	    System.err.println("Canvas pos = (" + awtCanvasX + ", " +			       awtCanvasY + "), size = " + awtCanvasWidth +			       "x" + awtCanvasHeight);	    System.err.println("Window LL corner (in plate coordinates): " +		"(" + physicalWindowXLeft + "," + physicalWindowYBottom + ")");	    System.err.println("Window size (in plate coordinates): " +		"(" + physicalWindowWidth + "," + physicalWindowHeight + ")");	    System.err.println("Window center (in plate coordinates): " +			       physicalWindowCenter);	    System.err.println();	}	// Compute the view platform scale.  This combines	// the screen scale and the window scale.	computeViewPlatformScale();	if (!viewCache.compatibilityModeEnable &&	    viewCache.viewPolicy == View.HMD_VIEW) {	    if (!useStereo) {		switch(effectiveMonoscopicViewPolicy) {		case View.CYCLOPEAN_EYE_VIEW:		    if(J3dDebug.devPhase) {			System.err.println("CanvasViewCache : Should never reach here.\n" +					   "HMD_VIEW with CYCLOPEAN_EYE_VIEW is not allowed");		    }		    break;		case View.LEFT_EYE_VIEW:		    headTrackerToLeftImagePlate.set(screenViewCache.						    headTrackerToLeftImagePlate);		    break;		case View.RIGHT_EYE_VIEW: 		    headTrackerToLeftImagePlate.set(screenViewCache.						    headTrackerToRightImagePlate);		    break;		}	    }	    else {		headTrackerToLeftImagePlate.set(screenViewCache.						headTrackerToLeftImagePlate);		headTrackerToRightImagePlate.set(screenViewCache.						 headTrackerToRightImagePlate); 	    }	}    }    // Routine to compute the center of coexistence coordinates in    // imageplate coordinates.  Also compute the scale from Vpc    private void computeViewPlatformScale() {	windowScale = screenScale = 1.0;	if (!viewCache.compatibilityModeEnable) {	    switch (viewCache.screenScalePolicy) {	    case View.SCALE_SCREEN_SIZE:		screenScale = physicalScreenWidth / 2.0;		break;	    case View.SCALE_EXPLICIT:		screenScale = viewCache.screenScale;		break;	    }	    if (viewCache.windowResizePolicy == View.PHYSICAL_WORLD) {		windowScale = physicalWindowWidth / physicalScreenWidth;	    }	}	viewPlatformScale = windowScale * screenScale;	if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_2)) {	    System.err.println("viewCache.windowResizePolicy = " +			       viewCache.windowResizePolicy);	    System.err.println("physicalWindowWidth = " + physicalWindowWidth);	    System.err.println("physicalScreenWidth = " + physicalScreenWidth);	    System.err.println("windowScale = " + windowScale);	    System.err.println("screenScale = " + screenScale);	    System.err.println("viewPlatformScale = " + viewPlatformScale);	}    }    private void cacheEyePosFixedField() {	if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_1))	    System.err.println("cacheEyePosFixedField:");	// y is always the window center	rightEyeInImagePlate.y =	    leftEyeInImagePlate.y =	    physicalWindowCenter.y;	if (!useStereo) {	    switch(effectiveMonoscopicViewPolicy) {	    case View.CYCLOPEAN_EYE_VIEW:		leftEyeInImagePlate.x = physicalWindowCenter.x;		break;	    case View.LEFT_EYE_VIEW:		leftEyeInImagePlate.x =		    physicalWindowCenter.x + viewCache.leftEyePosInHead.x;		break;	    case View.RIGHT_EYE_VIEW:		leftEyeInImagePlate.x =		    physicalWindowCenter.x + viewCache.rightEyePosInHead.x;		break;	    }	    // Set right as well just in case	    rightEyeInImagePlate.x = leftEyeInImagePlate.x;	}	else {	    leftEyeInImagePlate.x =		physicalWindowCenter.x + viewCache.leftEyePosInHead.x;	    rightEyeInImagePlate.x =		physicalWindowCenter.x + viewCache.rightEyePosInHead.x;	}	//	// Derive the z distance by constraining the field of view of the	// window width to be constant.	//	rightEyeInImagePlate.z =	    leftEyeInImagePlate.z =	    physicalWindowWidth /	    (2.0 * Math.tan(viewCache.fieldOfView / 2.0));        // Denote that eyes-in-ImagePlate fields have changed so that	// these new values can be sent to the AudioDevice        if (this.viewCache.view.soundScheduler != null)            this.viewCache.view.soundScheduler.setListenerFlag(                 SoundScheduler.EYE_POSITIONS_CHANGED);    }    /**     *  Case of view eye position contrainted to center of window, but     *  with z distance from plate eye pos.     */    private void cacheEyePosWindowRelative() {	if ((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_1))	    System.err.println("cacheEyePosWindowRelative:");	// y is always the window center	rightEyeInImagePlate.y =	    leftEyeInImagePlate.y =	    physicalWindowCenter.y;	// z is always from the existing eye pos	rightEyeInImagePlate.z =	    leftEyeInImagePlate.z =	    leftManualEyeInImagePlate.z;	if (!useStereo) {	    switch(effectiveMonoscopicViewPolicy) {	    case View.CYCLOPEAN_EYE_VIEW:		leftEyeInImagePlate.x =		    physicalWindowCenter.x;		break;	    case View.LEFT_EYE_VIEW:		leftEyeInImagePlate.x =		    physicalWindowCenter.x +		    viewCache.leftEyePosInHead.x;		break;	    case View.RIGHT_EYE_VIEW:		leftEyeInImagePlate.x =		    physicalWindowCenter.x +		    viewCache.rightEyePosInHead.x;		    break;	    }	    // Set right as well just in case	    rightEyeInImagePlate.x =		leftEyeInImagePlate.x;	}	else {	    leftEyeInImagePlate.x =		physicalWindowCenter.x +		viewCache.leftEyePosInHead.x;	    rightEyeInImagePlate.x =		physicalWindowCenter.x +		viewCache.rightEyePosInHead.x;	    // Right z gets its own value	    rightEyeInImagePlate.z =		rightManualEyeInImagePlate.z;	}	// Denote that eyes-in-ImagePlate fields have changed so that	// these new values can be sent to the AudioDevice        if (this.viewCache.view.soundScheduler != null)            this.viewCache.view.soundScheduler.setListenerFlag(                 SoundScheduler.EYE_POSITIONS_CHANGED);    }    /**     * Common routine used when head tracking and when using manual     * relative_to_screen eyepoint policy.     */    private void cacheEyePosScreenRelative(Point3d leftEye, Point3d rightEye) {	if ((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_1))	    System.err.println("cacheEyePosScreenRelative:");	if (!useStereo) {	    switch(effectiveMonoscopicViewPolicy) {	    case View.CYCLOPEAN_EYE_VIEW:		leftEyeInImagePlate.x = (leftEye.x + rightEye.x) / 2.0;

⌨️ 快捷键说明

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