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

📄 viewinfo.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     *      * @param view the View to use     * @see #updateView     * @see #updateCanvas updateCanvas(Canvas3D)     * @see #updateScreen updateScreen(Screen3D)     * @see #updateHead     * @see #updateViewPlatform     */    public ViewInfo(View view) {	this(view, 0) ;    }    /**     * Creates a new ViewInfo for the specified View.  The View must be     * attached to a ViewPlatform.  If the ViewPlatform is attached to a live     * scene graph, then <code>ALLOW_POLICY_READ</code> capability must be set     * on the ViewPlatform node.     *      * @param view the View to use<p>     * @param autoUpdateFlags a logical <code>OR</code> of any of the     *	<code>VIEW_AUTO_UPDATE</code>, <code>CANVAS_AUTO_UPDATE</code>,     *	<code>SCREEN_AUTO_UPDATE</code>, <code>HEAD_AUTO_UPDATE</code>, or     *	<code>PLATFORM_AUTO_UPDATE</code> flags to control whether changes to     *	the View, its Canvas3D or Screen3D components, the tracked head     *	position, or the ViewPlatform's <code>localToVworld</code> transform     *	are checked automatically with each call to a public method of this     *	class; if a flag is not set, then the application must inform this     *	class of updates to the corresponding data     */    public ViewInfo(View view, int autoUpdateFlags) {	this(view, autoUpdateFlags, staticSiMap, staticVpMap) ;    }    /**     * Creates a new ViewInfo for the specified View.  The View must be     * attached to a ViewPlatform.  If the ViewPlatform is attached to a live     * scene graph, then <code>ALLOW_POLICY_READ</code> capability must be set     * on the ViewPlatform node.<p>     *     * ViewInfo caches Screen3D and ViewPlatform data, but Screen3D and     * ViewPlatform instances are shared across multiple Views in the Java 3D     * view model.  Since ViewInfo is per-View, all ViewInfo constructors     * except for this one use static references to manage the shared Screen3D     * and ViewPlatform objects.  In this constructor, however, the caller     * supplies two Map instances to hold these references for all ViewInfo     * instances, so static references can be avoided; it can be used to wrap     * this class into a multi-view context that provides the required     * maps.<p>     *     * Alternatively, the other constructors can be used by calling     * <code>ViewInfo.clear</code> when done with ViewInfo, or by simply     * retaining the static references until the JVM exits.<p>     *      * @param view the View to use<p>     * @param autoUpdateFlags a logical <code>OR</code> of any of the     *	<code>VIEW_AUTO_UPDATE</code>, <code>CANVAS_AUTO_UPDATE</code>,     *	<code>SCREEN_AUTO_UPDATE</code>, <code>HEAD_AUTO_UPDATE</code>, or     *	<code>PLATFORM_AUTO_UPDATE</code> flags to control whether changes to     *	the View, its Canvas3D or Screen3D components, the tracked head     *	position, or the ViewPlatform's <code>localToVworld</code> transform     *	are checked automatically with each call to a public method of this     *	class; if a flag is not set, then the application must inform this     *	class of updates to the corresponding data<p>     * @param screenMap a writeable Map to hold Screen3D information     * @param viewPlatformMap a writeable Map to hold ViewPlatform information     */    public ViewInfo(View view, int autoUpdateFlags,		    Map screenMap, Map viewPlatformMap) {	if (verbose)	    System.err.println("ViewInfo: init " + hashCode()) ;	if (view == null)	    throw new IllegalArgumentException("View is null") ;	if (screenMap == null)	    throw new IllegalArgumentException("screenMap is null") ;	if (viewPlatformMap == null)	    throw new IllegalArgumentException("viewPlatformMap is null") ;	this.view = view ;	this.screenMap = screenMap ;	this.viewPlatformMap = viewPlatformMap ;	if (autoUpdateFlags == 0) {	    this.autoUpdate = false ;	}	else {	    this.autoUpdate = true ;	    this.autoUpdateFlags = autoUpdateFlags ;	}	getViewInfo() ;    }    /**     * Gets the current transforms from image plate coordinates to view     * platform coordinates and copies them into the given Transform3Ds.<p>     *      * With a monoscopic canvas the image plate transform is copied to the     * first argument and the second argument is not used.  For a stereo     * canvas the first argument receives the left image plate transform, and     * if the second argument is non-null it receives the right image plate     * transform.  These transforms are always the same unless a head mounted     * display driven by a single stereo canvas is in use.     *     * @param c3d the Canvas3D associated with the image plate     * @param ip2vpl the Transform3D to receive the left transform     * @param ip2vpr the Transform3D to receive the right transform, or null     */    public void getImagePlateToViewPlatform(Canvas3D c3d,					    Transform3D ip2vpl,					    Transform3D ip2vpr) {	CanvasInfo ci = updateCache	    (c3d, "getImagePlateToViewPlatform", false) ;	getImagePlateToViewPlatform(ci) ;	ip2vpl.set(ci.plateToViewPlatform) ;	if (ci.useStereo && ip2vpr != null)	    ip2vpr.set(ci.rightPlateToViewPlatform) ;    }    private void getImagePlateToViewPlatform(CanvasInfo ci) {	if (ci.updatePlateToViewPlatform) {	    if (verbose) System.err.println("updating PlateToViewPlatform") ;	    if (ci.plateToViewPlatform == null)		ci.plateToViewPlatform = new Transform3D() ;	    getCoexistenceToImagePlate(ci) ;	    getViewPlatformToCoexistence(ci) ;	    ci.plateToViewPlatform.mul(ci.coeToPlate, ci.viewPlatformToCoe) ;	    ci.plateToViewPlatform.invert() ;	    if (ci.useStereo) {		if (ci.rightPlateToViewPlatform == null)		    ci.rightPlateToViewPlatform = new Transform3D() ;		ci.rightPlateToViewPlatform.mul(ci.coeToRightPlate,						ci.viewPlatformToCoe) ;		ci.rightPlateToViewPlatform.invert() ;	    }	    ci.updatePlateToViewPlatform = false ;	    if (verbose) t3dPrint(ci.plateToViewPlatform, "plateToVp") ;	}    }    /**     * Gets the current transforms from image plate coordinates to virtual     * world coordinates and copies them into the given Transform3Ds.<p>     *      * With a monoscopic canvas the image plate transform is copied to the     * first argument and the second argument is not used.  For a stereo     * canvas the first argument receives the left image plate transform, and     * if the second argument is non-null it receives the right image plate     * transform.  These transforms are always the same unless a head mounted     * display driven by a single stereo canvas is in use.<p>     *     * The View must be attached to a ViewPlatform which is part of a live     * scene graph, and the ViewPlatform node must have its     * <code>ALLOW_LOCAL_TO_VWORLD_READ</code> capability set.     *     * @param c3d the Canvas3D associated with the image plate     * @param ip2vwl the Transform3D to receive the left transform     * @param ip2vwr the Transform3D to receive the right transform, or null     */    public void getImagePlateToVworld(Canvas3D c3d,				      Transform3D ip2vwl, Transform3D ip2vwr) {	CanvasInfo ci = updateCache(c3d, "getImagePlateToVworld", true) ;	getImagePlateToVworld(ci) ;	ip2vwl.set(ci.plateToVworld) ;	if (ci.useStereo && ip2vwr != null)	    ip2vwr.set(ci.rightPlateToVworld) ;    }    private void getImagePlateToVworld(CanvasInfo ci) {	if (ci.updatePlateToVworld) {	    if (verbose) System.err.println("updating PlateToVworld") ;	    if (ci.plateToVworld == null)		ci.plateToVworld = new Transform3D() ;	    getImagePlateToViewPlatform(ci) ;	    ci.plateToVworld.mul		(vpi.viewPlatformToVworld, ci.plateToViewPlatform) ;	    if (ci.useStereo) {		if (ci.rightPlateToVworld == null)		    ci.rightPlateToVworld = new Transform3D() ;		ci.rightPlateToVworld.mul		    (vpi.viewPlatformToVworld, ci.rightPlateToViewPlatform) ;	    }	    ci.updatePlateToVworld = false ;	}    }    /**     * Gets the current transforms from coexistence coordinates to image plate     * coordinates and copies them into the given Transform3Ds.  The default     * coexistence centering enable and window movement policies are     * <code>true</code> and <code>PHYSICAL_WORLD</code> respectively, which     * will center coexistence coordinates to the middle of the canvas,     * aligned with the screen (image plate). A movement policy of     * <code>VIRTUAL_WORLD</code> centers coexistence coordinates to the     * middle of the screen.<p>     *     * If coexistence centering is turned off, then canvases and screens can     * have arbitrary positions with respect to coexistence, set through the     * the Screen3D <code>trackerBaseToImagePlate</code> transform and the     * PhysicalEnvironment <code>coexistenceToTrackerBase</code> transform.     * These are calibration constants used for multiple fixed screen displays.     * For head mounted displays the transform is determined by the user head     * position along with calibration parameters found in Screen3D and     * PhysicalBody. (See the source code for the private method     * <code>getEyesHMD</code> for more information).<p>     *     * With a monoscopic canvas the image plate transform is copied to the     * first argument and the second argument is not used.  For a stereo     * canvas the first argument receives the left image plate transform, and     * if the second argument is non-null it receives the right image plate     * transform.  These transforms are always the same unless a head mounted     * display driven by a single stereo canvas is in use.<p>     *     * @param c3d the Canvas3D associated with the image plate     * @param coe2ipl the Transform3D to receive the left transform     * @param coe2ipr the Transform3D to receive the right transform, or null     */    public void getCoexistenceToImagePlate(Canvas3D c3d,					   Transform3D coe2ipl,					   Transform3D coe2ipr) {	CanvasInfo ci = updateCache(c3d, "getCoexistenceToImagePlate", false) ;	getCoexistenceToImagePlate(ci) ;	coe2ipl.set(ci.coeToPlate) ;	if (ci.useStereo && coe2ipr != null)	    coe2ipr.set(ci.coeToRightPlate) ;    }    private void getCoexistenceToImagePlate(CanvasInfo ci) {	//	// This method will always set coeToRightPlate even if stereo is not	// in use.  This is necessary so that getEyeToImagePlate() can handle	// a monoscopic view policy of CYCLOPEAN_EYE_VIEW (which averages the	// left and right eye positions) when the eyepoints are expressed in	// coexistence coordinates or are derived from the tracked head.	// 	if (ci.updateCoeToPlate) {	    if (verbose) System.err.println("updating CoeToPlate") ;	    if (ci.coeToPlate == null) {		ci.coeToPlate = new Transform3D() ;		ci.coeToRightPlate = new Transform3D() ;	    }	    if (viewPolicy == View.HMD_VIEW) {		// Head mounted displays have their image plates fixed with		// respect to the head, so get the head position in		// coexistence.		ci.coeToPlate.mul(ci.si.headTrackerToLeftPlate,				  coeToHeadTracker) ;		if (ci.useStereo)		    // This is the only case in the view model in which the		    // right plate transform could be different from the left.		    ci.coeToRightPlate.mul(ci.si.headTrackerToRightPlate,					   coeToHeadTracker) ;		else		    ci.coeToRightPlate.set(ci.coeToPlate) ;	    }	    else if (coeCentering) {		// The default, for fixed single screen displays with no		// motion tracking.  The transform is just a translation.		if (movementPolicy == View.PHYSICAL_WORLD)		    // The default.  Coexistence is centered in the window.		    v3d.set(ci.canvasX + (ci.canvasWidth  / 2.0),			    ci.canvasY + (ci.canvasHeight / 2.0), 0.0) ;		else		    // Coexistence is centered in the screen.		    v3d.set(ci.si.screenWidth  / 2.0,			    ci.si.screenHeight / 2.0, 0.0) ;		ci.coeToPlate.set(v3d) ;		ci.coeToRightPlate.set(v3d) ;	    }	    else {		// Coexistence centering should be false for multiple fixed		// screens and/or motion tracking.  trackerBaseToImagePlate		// and coexistenceToTrackerBase are used explicitly.		ci.coeToPlate.mul(ci.si.trackerBaseToPlate, coeToTrackerBase) ;		ci.coeToRightPlate.set(ci.coeToPlate) ;	    }	    ci.updateCoeToPlate = false ;	    if (verbose) t3dPrint(ci.coeToPlate, "coeToPlate") ;	}    }    /**     * Gets the current transform from view platform coordinates to     * coexistence coordinates and copies it into the given transform.	View     * platform coordinates are always aligned with coexistence coordinates     * but may differ in scale and in Y and Z offset.  The scale is derived     * from the window resize and screen scale policies, while the offset is     * derived from the view attach policy.<p>     *     * Java 3D constructs a view from the physical position of the eyes     * relative to the physical positions of the image plates; it then uses a     * view platform to position that physical configuration into the virtual     * world and from there computes the correct projections of the virtual     * world onto the physical image plates.  Coexistence coordinates are used     * to place the physical positions of the view platform, eyes, head, image     * plate, sensors, and tracker base in relation to each other. The view     * platform is positioned with respect to the virtual world through the     * scene graph, so the view platform to coexistence transform defines the     * space in which the virtual world and physical world coexist.<p>     * 

⌨️ 快捷键说明

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