📄 viewmodel.html
字号:
<ul> <font size="-1"><b><i>Figure 2</i> – A Portion of a Scene GraphContaining a ViewPlatform Object</b></font></ul><p></p><h3>Moving through the VirtualWorld</h3><p>An application navigates within the virtual world by modifying aViewPlatform's parent TransformGroup. Examples of applications thatmodify a ViewPlatform's location and orientation include browsers,object viewers that provide navigational controls, applications that doarchitectural walkthroughs, and even search-and-destroy games.</p><p>Controlling the ViewPlatform object can produce very interesting anduseful results. Our first simple scene graph (see <a href="intro.html#Figure_1">"Introduction," Figure 1</a>)defines a scene graph for a simple application that draws an object inthe center of a window and rotates that object about its center point.In that figure, the Behavior object modifies the TransformGroupdirectly above the Shape3D node.</p><p>An alternative application scene graph, shown in <a href="#Figure_3">Figure3</a>,leaves the central object alone and moves the ViewPlatform around theworld. If the shape node contains a model of the earth, thisapplication could generate a view similar to that seen by astronauts asthey orbit the earth.</p><p>Had we populated this world with more objects, this scene graphwould allow navigation through the world via the Behavior node.</p><p><a name="Figure_3"></a><img style="width: 500px; height: 289px;" alt="Simple Scene Graph with View Control" title="Simple Scene Graph with View Control" src="ViewModel3.gif"></p><p></p><ul> <font size="-1"><b><i>Figure 3</i> – A Simple Scene Graph with ViewControl</b></font></ul><p>Applications and behaviors manipulate a <a href="../TransformGroup.html">TransformGroup</a> through itsaccess methods. These methods allow an application to retrieve andset the Group node's Transform3D object. Transform3D Node methodsinclude <code>getTransform</code> and <code>setTransform</code>.</p><p></p><h3>Dropping in on a FavoritePlace</h3><p>A scene graph may contain multiple <a href="../ViewPlatform.html">ViewPlatform</a>objects. If a user detaches a <a href="../View.html">View</a> objectfrom a ViewPlatform and thenreattaches that View to a different ViewPlatform, the image on thedisplay will now be rendered from the point of view of the newViewPlatform.</p><h3>Associating Geometry with aViewPlatform</h3><p>Java 3D does not have any built-in semantics for displaying avisiblemanifestation of a ViewPlatform within the virtual world (an <em>avatar</em>).However, a developer can construct and manipulate an avatar usingstandard Java 3D constructs.</p><p>A developer can construct a small scene graph consisting of aTransformGroup node, a behavior leaf node, and a shape node and insertit directly under the BranchGroup node associated with the ViewPlatformobject. The shape node would contain a geometric model of the avatar'shead. The behavior node would change the TransformGroup's transformperiodically to the value stored in a View object's <code>UserHeadToVworld</code><strong></strong>parameter (see "<a href="#View_Model_Details">View ModelDetails</a>").The avatar's virtual head, represented by the shape node, will now movearound in lock-step with the ViewPlatform's TransformGroup<em> and </em>anyrelative position and orientation changes of the user's actual physicalhead (if a system has a head tracker).</p><p></p><h2><a name="Generating_View"></a>Generating a View</h2><p>Java 3D generates viewing matrices in one of a few differentways,depending on whether the end user has a head-mounted or a room-mounteddisplay environment and whether head tracking is enabled. This sectiondescribes the computation for a non-head-tracked, room-mounteddisplay-a standard computer display. Other environments are describedin "<a href="#View_Model_Details">View Model Details</a>."</p><p>In the absence of head tracking, the ViewPlatform's origin specifiesthe virtual eye's location and orientation within the virtual world.However, the eye location provides only part of the information neededto render an image. The renderer also needs a projection matrix. In thedefault mode, Java 3D uses the projection policy, the specifiedfield-of-view information, and the front and back clipping distances toconstruct a viewing frustum.</p><p></p><h3>Composing Model and ViewingTransformations</h3><p><a href="#Figure_4">Figure4</a>shows a simple scene graph. To draw the object labeled "S,"Java 3Dinternally constructs the appropriate model, view platform, eye, andprojection matrices. Conceptually, the model transformation for aparticular object is computed by concatenating all the matrices in adirect path between the object and the VirtualUniverse. The view matrixis then computed-again, conceptually-by concatenating all the matricesbetween the VirtualUniverse object and the ViewPlatform attached to thecurrent View object. The eye and projection matrices are constructedfrom the View object and its associated component objects.</p><p><a name="Figure_4"></a><img style="width: 500px; height: 332px;" alt="Object and ViewPlatform Transform" title="Object and ViewPlatform Transform" src="ViewModel4.gif"></p><p></p><ul> <font size="-1"><b><i>Figure 4</i> – Object and ViewPlatformTransformations</b></font></ul><p>In our scene graph, what we would normally consider themodel transformation would consist of the following threetransformations: <strong>LT</strong>1<strong>T</strong>2. Bymultiplying <strong>LT</strong>1<strong>T</strong>2by a vertex in the shape object, we would transform that vertex intothe virtual universe's coordinate system. What we would normallyconsider the view platform transformation would be (<strong>LT</strong>v1)-1or <strong>T</strong>v1<sup>-1</sup><strong>L</strong>-1.This presents a problem since coordinates in the virtual universe are256-bit fixed-point values, which cannot be used to representtransformed points efficiently.</p><p>Fortunately, however, there is a solution to this problem. Composingthe model and view platform transformations gives us</p><dl> <dt><br> </dt> <dd> <strong>T</strong>v1<sup>-1</sup><strong>L</strong>-1<strong>LT</strong>1<strong>T</strong>2= <strong>T</strong>v1<sup>-1</sup><strong>IT</strong>1<strong>T</strong>2= <strong>T</strong>v1<sup>-1</sup><strong>T</strong>1<strong>T</strong>2, </dd></dl><p>the matrix that takes vertices in an object's local coordinatesystemand places them in the ViewPlatform's coordinate system. Note that thehigh-resolution Locale transformations cancel each other out, whichremoves the need to actually transform points into high-resolutionVirtualUniverse coordinates. The general formula of the matrix thattransforms object coordinates to ViewPlatform coordinates is <strong>T</strong>vn<sup>-1</sup>...<strong>T</strong>v2<sup>-1</sup><strong>T</strong>v1<sup>-1</sup><strong>T</strong>1<strong>T</strong>2...<strong>T</strong>m.</p><p>As mentioned earlier, the View object contains the remainder of theview information, specifically, the eye matrix, <strong>E</strong>,that takes points in the View-Platform's local coordinate system andtranslates them into the user's eye coordinate system, and theprojection matrix, <strong>P</strong>, that projects objects in theeye's coordinate system into clipping coordinates. The finalconcatenation of matrices for rendering our shape object "S" on thespecified Canvas3D is <strong>PET</strong>v1<sup>-1</sup><strong>T</strong>1<strong>T</strong>2.In general this is <strong>PET</strong>vn<sup>-1</sup>...<strong>T</strong>v2<sup>-1</sup><strong>T</strong>v1<sup>-1</sup><strong>T</strong>1<strong>T</strong>2...<strong>T</strong>m.</p><p>The details of how Java 3D constructs the matrices <strong>E</strong>and <strong>P</strong> in different end-user configurations aredescribed in "<a href="#View_Model_Details">View Model Details</a>."</p><p></p><h3>Multiple Locales</h3><p>Java 3D supports multiple high-resolution Locales. In somecases,theseLocales are close enough to each other that they can "see" each other,meaning that objects can be rendered even though they are not in thesame Locale as the ViewPlatform object that is attached to the View.Java 3D automatically handles this case without the applicationhavingto do anything. As in the previous example, where the ViewPlatform andthe object being rendered are attached to the same Locale, Java 3Dinternally constructs the appropriate matrices for cases in which theViewPlatform and the object being rendered are <em>not</em> attachedto the same Locale.</p><p>Let's take two Locales, L1 and L2, with the View attached to aViewPlatform in L1. According to our general formula, the modelingtransformation-the transformation that takes points in objectcoordinates and transforms them into VirtualUniverse coordinates-is <strong>LT</strong>1<strong>T</strong>2...<strong>T</strong>m.In our specific example, a point in Locale L2 would be transformed intoVirtualUniverse coordinates by <strong>L</strong>2<strong>T</strong>1<strong>T</strong>2...<strong>T</strong>m.The view platform transformation would be (<strong>L</strong>1<strong>T</strong>v1<strong>T</strong>v1...<strong>T</strong>vn)-1or <strong>T</strong>vn<sup>-1</sup>...<strong>T</strong>v2<sup>-1</sup><strong>T</strong>v1<sup>-1</sup><strong>L</strong>1<sup>-1</sup>.Composing these two matrices gives us</p><dl> <dt><br> </dt> <dd> <strong>T</strong>vn<sup>-1</sup>...<strong>T</strong>v2<sup>-1</sup><strong>T</strong>v1<sup>-1</sup><strong>L</strong>1<sup>-1</sup><strong>L</strong>2<strong>T</strong>1<strong>T</strong>2...<strong>T</strong>m. </dd></dl><p>Thus, to render objects in another Locale, it is sufficient tocompute <strong>L</strong>1<sup>-1</sup><strong>L</strong>2and use that as the starting matrix when composing the modeltransformations. Given that a Locale is represented by a singlehigh-resolution coordinate position, the transformation <strong>L</strong>1<sup>-1</sup><strong>L</strong>2is a simple translation by <strong>L</strong>2 - <strong>L</strong>1.Again, it is not actually necessary to transform points intohigh-resolution VirtualUniverse coordinates.</p><p>In general, Locales that are close enough that the difference intheirhigh-resolution coordinates can be represented in double precision by anoninfinite value are close enough to be rendered. In practice, moresophisticated culling techniques can be used to render only thoseLocales that really are "close enough."</p><p></p><h2>A Minimal Environment</h2><p>An application must create a minimal set of Java 3D objectsbeforeJava3D can render to a display device. In addition to a Canvas3D object,the application must create a View object, with its associatedPhysicalBody and PhysicalEnvironment objects, and the following scenegraph elements:</p><ul> <li>A VirtualUniverse object</li></ul><ul> <li>A high-resolution Locale object</li></ul><ul> <li>A BranchGroup node object</li></ul><ul> <li>A TransformGroup node object with associated transform</li></ul><ul> <li>A ViewPlatform leaf node object that defines the position andorientation within the virtual universe for generating views</li></ul><hr><h2><a name="View_Model_Details"></a>View Model Details</h2><p>An application programmer writing a 3Dgraphics program that will deploy on a variety of platforms mustanticipate the likely end-user environments and must carefullyconstruct the view transformations to match those characteristics usinga low-level API. This appendix addresses many of the issues anapplication must face and describes the sophisticated features thatJava 3D's advanced view model provides.</p><p></p><h2>An Overview of theJava 3DView Model</h2>Both camera-based and Java 3D-based view models allow a programmertospecify the shape of a view frustum and, under program control, toplace, move, and reorient that frustum within the virtual environment.However, how they do this varies enormously. Unlike the camera-basedsystem, the Java 3D view model allows slaving the view frustum's
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -