Strip comments and inline ids onto h*
This commit is contained in:
parent
1997a7846d
commit
0f5f617adb
362 changed files with 2519 additions and 6694 deletions
35
62-03.html
35
62-03.html
|
|
@ -10,16 +10,9 @@
|
|||
<meta name="vspubdate" content="07/01/97" />
|
||||
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
|
||||
|
||||
<title>Michael Abrash's Graphics Programming Black Book Special Edition: On Story, Two Rules, and a BSP Renderer</title><!-- HEADER -->
|
||||
<!-- Empty Reference Subhead -->
|
||||
<!--ISBN=1576101746//-->
|
||||
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
|
||||
<!--AUTHOR=Michael Abrash//-->
|
||||
<!--PUBLISHER=The Coriolis Group, Inc.//-->
|
||||
<title>Michael Abrash's Graphics Programming Black Book Special Edition: On Story, Two Rules, and a BSP Renderer</title>
|
||||
<meta name="chapter" content="62" />
|
||||
<meta name="pages" content="1157-1160" />
|
||||
<!--UNASSIGNED1//-->
|
||||
<!--UNASSIGNED2//-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
@ -37,7 +30,7 @@
|
|||
|
||||
<p><br /></p>
|
||||
|
||||
<h4 align="left"><a id="Heading4"></a>The Rendering Pipeline</h4>
|
||||
<h4 align="left" id="Heading4">The Rendering Pipeline</h4>
|
||||
|
||||
<p>Conceptually rendering from a BSP tree really is that simple, but the implementation is a bit more complicated. The full rendering pipeline, as coordinated by <b>UpdateWorld()</b>, is this:</p>
|
||||
|
||||
|
|
@ -55,13 +48,13 @@
|
|||
|
||||
<p>Next, we’ll look at each part of the pipeline more closely. The pipeline is too complex for me to be able to discuss each part in complete detail. Some sources for further reading are <i>Computer Graphics</i>, by Foley and van Dam (ISBN 0-201-12110-7), and the <i>DDJ Essential Books on Graphics Programming</i> CD.</p>
|
||||
|
||||
<h3><a id="Heading5"></a>Moving the Viewer</h3>
|
||||
<h3 id="Heading5">Moving the Viewer</h3>
|
||||
|
||||
<p>The sample BSP program performs first-person rendering; that is, it renders the world as seen from your eyes as you move about. The rate of movement is controlled by key-handling code that’s not shown in Listing 62.1; however, the variables set by the key-handling code are used in <b>UpdateViewPos()</b> to bring the current location up to date.</p>
|
||||
|
||||
<p>Note that the view position can change not only in x and z (movement around the but only viewing horizontally. Although the BSP tree is only 2-D, it is quite possible to support looking up and down to at least some extent, particularly if the world dataset is restricted so that, for example, there are never two rooms stacked on top of each other, or any tilted walls. For simplicity’s sake, I have chosen not to implement this in Listing 62.1, but you may find it educational to add it to the program yourself.</p>
|
||||
|
||||
<h3><a id="Heading6"></a>Transformation into Viewspace</h3>
|
||||
<h3 id="Heading6">Transformation into Viewspace</h3>
|
||||
|
||||
<p>The viewing angle (which controls direction of movement as well as view direction) can sweep through the full 360 degrees around the viewpoint, so long as it remains horizontal. The viewing angle is controlled by the key handler, and is used to define a unit vector stored in <b>currentorientation</b> that explicitly defines the view direction (the z axis of viewspace), and implicitly defines the x axis of viewspace, because that axis is at right angles to the z axis, where x increases to the right of the viewer.</p>
|
||||
|
||||
|
|
@ -71,7 +64,7 @@
|
|||
|
||||
<p>When this is done the walls are in viewspace, ready to be clipped.</p>
|
||||
|
||||
<h3><a id="Heading7"></a>Clipping</h3>
|
||||
<h3 id="Heading7">Clipping</h3>
|
||||
|
||||
<p>In viewspace, the walls may be anywhere relative to the viewpoint: in front, behind, off to the side. We only want to draw those parts of walls that properly belong on the screen; that is, those parts that lie in the view pyramid (view frustum), as shown in Figure 62.2. Unclipped walls—walls that lie entirely in the frustum—should be drawn in their entirety, fully clipped walls should not be drawn, and partially clipped walls must be trimmed before being drawn.</p>
|
||||
|
||||
|
|
@ -79,19 +72,17 @@
|
|||
|
||||
<p>After clipping in z, we clip by viewspace x coordinate, to ensure that we draw only wall portions that lie between the left and right edges of the screen. Like z-clipping, x-clipping can be done as a 2-D clip, because the walls and the left and right sides of the frustum are all vertical. We compare both the start and endpoint of each wall to the left and right sides of the frustum, and reject, accept, or clip each wall’s t values accordingly. The test for x clipping is very simple, because the edges of the frustum are defined as the planes where x==z and -x==z.</p>
|
||||
|
||||
<p><a id="Fig2"><!-- </A><A HREF="javascript:displayWindow('images/62-02.jpg',389,241 )"> --><img src="images/62-02.jpg" /><br />
|
||||
<!-- </A>
|
||||
<BR><A HREF="javascript:displayWindow('images/62-02.jpg',389,241)"> --><b>Figure 62.2</b></a> <i>Clipping to the view pyramid.</i></p>
|
||||
<p><a id="Fig2"><img src="images/62-02.jpg" /><br />
|
||||
<b>Figure 62.2</b></a> <i>Clipping to the view pyramid.</i></p>
|
||||
|
||||
<p>The final clip stage is clipping by y coordinate, and this is the most complicated, because vertical walls can be clipped at an angle in y, as shown in Figure 62.3, so true 3-D clipping of all four wall vertices is involved. We handle this in <b>ClipWalls()</b> by detecting trivial rejection in y, using y==z and ==z as the y boundaries of the frustum. However, we leave partial clipping to be handled as a 2-D clipping problem; we are able to do this only because our earlier z-clip to the near clip plane guarantees that no remaining polygon point can have z<=0, ensuring that when we project we’ll always pass valid, y-clippable screenspace vertices to the polygon filler.</p>
|
||||
|
||||
<h3><a id="Heading8"></a>Projection to Screenspace</h3>
|
||||
<h3 id="Heading8">Projection to Screenspace</h3>
|
||||
|
||||
<p>At this point, we have viewspace vertices for each wall that’s at least partially visible. All we have to do is project these vertices according to z distance—that is, perform perspective projection—and scale the results to the width of the screen, then we’ll be ready to draw. Although this step is logically separate from clipping, it is performed as the last step for visible walls in <b>ClipWalls()</b>.</p>
|
||||
|
||||
<p><a id="Fig3"><!-- </A><A HREF="javascript:displayWindow('images/62-03.jpg',405,220 )"> --><img src="images/62-03.jpg" /><br />
|
||||
<!-- </A>
|
||||
<BR><A HREF="javascript:displayWindow('images/62-03.jpg',405,220)"> --><b>Figure 62.3</b></a> <i>Why y clipping is more complex than x or z clipping.</i></p>
|
||||
<p><a id="Fig3"><img src="images/62-03.jpg" /><br />
|
||||
<b>Figure 62.3</b></a> <i>Why y clipping is more complex than x or z clipping.</i></p>
|
||||
|
||||
<p><br /></p>
|
||||
|
||||
|
|
@ -110,10 +101,6 @@
|
|||
|
||||
<div align="center">
|
||||
Graphics Programming Black Book © 2001 Michael Abrash
|
||||
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed -->
|
||||
<!-- reference_subfoot = footer -->
|
||||
<!-- reference_footer = subfoot -->
|
||||
<!-- BEGIN SUB FOOTER -->
|
||||
<!-- END FOOTER -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue