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

📄 视区和裁剪viewports and clipping.htm

📁 此文件是微软MSDN中d3d部分资料的翻译文件
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><!--[if gte vml 1]><v:shape 
id=_x0000_i1044 style="WIDTH: 294pt; HEIGHT: 142.5pt" type = "#_x0000_t75" 
coordsize = "21600,21600"><v:imagedata o:title="frustum" src = 
"VnC_files/image002.gif"></v:imagedata></v:shape><![endif]--><![if !vml]><img border=0 width=392 height=190
src="VnC_files/image002.gif" v:shapes="_x0000_i1044"><![endif]><o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">想象我们站在一个黑暗的房间里,从一个方的窗口中看出去,这就是一个直观的视棱锥。在这个类比中,近裁剪平面就是窗口,远裁剪平面是最终妨碍我们视线的任何东西——街上的高楼,远处的山,或什么也不是。我们可以看见从窗口处开始,到任何妨碍我们视线的东西处结束,位于截棱锥内的一切,除此之外我们什么也看不见。<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">视棱锥由<I 
style="mso-bidi-font-style: normal"><SPAN lang=EN-US>fov</SPAN></I>(视角)和视点在<SPAN 
lang=EN-US>z轴方向上到前后裁剪平面的距离定义。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><!--[if gte vml 1]><v:shape 
id=_x0000_i1045 style="WIDTH: 246.75pt; HEIGHT: 150pt" type = "#_x0000_t75" 
coordsize = "21600,21600"><v:imagedata o:title="fovdiag" src = 
"VnC_files/image003.gif"></v:imagedata></v:shape><![endif]--><![if !vml]><img border=0 width=329 height=200
src="VnC_files/image003.gif" v:shapes="_x0000_i1045"><![endif]><o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">在这幅图中,变量<I 
style="mso-bidi-font-style: normal"><SPAN 
lang=EN-US>D</SPAN></I>是从摄像机到空间的原点的距离,该空间由几何流水线的上一步——视变换——定义。这就是用于限定视棱锥区域的边界。有关如何用变量<I 
style="mso-bidi-font-style: normal"><SPAN 
lang=EN-US>D</SPAN></I>构建一个投影矩阵的信息,请参阅<U>什么是投影矩阵?</U>。<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 1"><A 
name=裁剪体><B><SPAN 
style="FONT-SIZE: 24pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 18.0pt; mso-fareast-language: ZH-CN">裁剪体<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></B></A></P><SPAN 
style="mso-bookmark: 裁剪体"></SPAN>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">投影矩阵的结果决定了投影空间中的裁剪体。<SPAN 
lang=EN-US>Microsoft&reg; Direct3D&reg;将裁剪体定义为以下公式:<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><!--[if gte vml 1]><v:shape 
id=_x0000_i1046 style="WIDTH: 75.75pt; HEIGHT: 54pt" type = "#_x0000_t75" 
coordsize = "21600,21600"><v:imagedata o:title="clipfrml" src = 
"VnC_files/image004.gif"></v:imagedata></v:shape><![endif]--><![if !vml]><img border=0 width=101 height=72
src="VnC_files/image004.gif" v:shapes="_x0000_i1046"><![endif]><o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">在前面的公式中,<I 
style="mso-bidi-font-style: normal"><SPAN lang=EN-US>X</SPAN></I>,<I 
style="mso-bidi-font-style: normal"><SPAN lang=EN-US>Y</SPAN></I>,<I 
style="mso-bidi-font-style: normal"><SPAN lang=EN-US>Z</SPAN></I>和<I 
style="mso-bidi-font-style: normal"><SPAN 
lang=EN-US>W</SPAN></I>表示经过投影变换的顶点坐标。如果裁剪被启用(默认值),任何<SPAN 
lang=EN-US>x-,y-,或z-成员在这些范围之外的顶点将被裁剪掉。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">除了顶点缓存,应用程序通过<U><SPAN 
lang=EN-US>D3DRS_CLIPPING</SPAN></U>渲染状态启用或禁用裁剪。顶点缓存的裁剪信息在处理过程中产生,更多信息请参阅<U>固定功能顶点处理</U>和<U>可编程顶点处理</U>。<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">Direct3D不裁剪顶点缓存中经过变换的顶点,除非顶点是由<U>IDirect3DDevice9::ProcessVertices</U>得到的。如果应用程序自己进行变换并需要Direct3D进行裁剪,那么不应该使用顶点缓存。在这种情况下,应用程序遍历顶点数据进行变换,Direct3D再次遍历顶点数据进行裁剪,然后驱动程序渲染顶点数据,这是效率很低的。因此,如果应用程序自己变换顶点数据那么它同时也应该裁剪顶点数据。<o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">当设备需要对收到的经过变换且经过光照的顶点(<SPAN 
lang=EN-US>TL顶点)进行裁剪时,为了执行裁剪操作,Direct3D会根据顶点的rhw和视区信息,把顶点变换回裁剪空间。然后执行裁剪操作。并不是所有设备都能执行这种裁剪TL顶点所需的反向变换操作。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">D3DPMISCCAPS_CLIPTLVERTS设备能力标志指出设备是否能裁剪TL顶点。如果没有设置这个能力标志,那么应用程序应该负责对准备送到设备进行渲染的TL顶点进行裁剪。在软件顶点处理模式(无论设备自身是在软件顶点处理模式下创建,还是用D3DRS_SOFTWAREVERTEXPROCESSING渲染状态作为混合模式顶点处理设备创建然后切换到软件顶点处理模式)下,设备总是能裁剪TL顶点。<o:p></o:p></SPAN></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 1"><A 
name=视区缩放><B><SPAN 
style="FONT-SIZE: 24pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 18.0pt; mso-fareast-language: ZH-CN">视区缩放</SPAN></B></A><B><SPAN 
lang=EN-US 
style="FONT-SIZE: 24pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 18.0pt; mso-fareast-language: ZH-CN"><o:p></o:p></SPAN></B></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">用于视区的<U><SPAN 
lang=EN-US>D3DVIEWPORT9</SPAN></U>结构的<B 
style="mso-bidi-font-weight: normal"><SPAN lang=EN-US>X</SPAN></B>,<B 
style="mso-bidi-font-weight: normal"><SPAN lang=EN-US>Y</SPAN></B>,<B 
style="mso-bidi-font-weight: normal"><SPAN lang=EN-US>Width</SPAN></B>和<B 
style="mso-bidi-font-weight: normal"><SPAN 
lang=EN-US>Height</SPAN></B>成员定义了视区在渲染目标表面中的位置和大小。这些值是屏幕坐标,相对于表面的左上角。<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">Microsoft&reg; 
Direct3D&reg;使用视区的位置和大小缩放顶点使渲染后的场景正好在渲染目标表面的相应位置。在内部,Direct3D会把这些值插入到应用于每个顶点的矩阵中。<o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><!--[if gte vml 1]><v:shape 
id=_x0000_i1047 style="WIDTH: 304.5pt; HEIGHT: 70.5pt" type = "#_x0000_t75" 
coordsize = "21600,21600"><v:imagedata o:title="vpscale" src = 
"VnC_files/image005.gif"></v:imagedata></v:shape><![endif]--><![if !vml]><img border=0 width=406 height=94
src="VnC_files/image005.gif" v:shapes="_x0000_i1047"><![endif]><o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">这个矩阵根据视区的大小和希望的深度范围缩放顶点,并把它们转换到渲染目标表面的相应位置。矩阵同时翻转了<SPAN 
lang=EN-US>y-坐标,使屏幕原点在左上角,y值向下增长。在应用这个矩阵之后,顶点仍然在齐次空间中——也就是说,它们仍然以[x,y,z,w]顶点的形式存在——并且它们在被送到光栅化器之前必须被转换到非齐次坐标。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">注意<SPAN 
lang=EN-US><SPAN style="mso-tab-count: 1"> </SPAN></SPAN></SPAN></B><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">视区缩放矩阵合并了<B 
style="mso-bidi-font-weight: normal"><SPAN 
lang=EN-US>D3DVIEWPORT9</SPAN></B>结构的<B><SPAN 
lang=EN-US>MinZ</SPAN></B>和<B><SPAN 
lang=EN-US>MaxZ</SPAN></B>成员,使缩放后的顶点在深度范围<SPAN lang=EN-US>[<B>MinZ</B>, 
<B>MaxZ</B>]内。这和以前版本的Microsoft 
DirectX&reg;具有不同的语义,以前这些成员曾被用于裁剪。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">注意<SPAN 
lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp; </SPAN></SPAN></SPAN></B><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">更多信息,请参阅<U>视区矩形</U>和<U>裁剪体</U>。应用程序一般将<B><SPAN 
lang=EN-US>MinZ</SPAN></B>和<B><SPAN lang=EN-US>MaxZ</SPAN></B>设为<SPAN 
lang=EN-US>0.0和1.0,使系统渲染整个深度范围。应用程序可以把两个值都设为0.0,强制渲染所有最前面的物体,或都设为1.0,渲染所有最后面的物体。<o:p></o:p></SPAN></SPAN></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-outline-level: 1"><A 
name=视区的使用><B><SPAN 
style="FONT-SIZE: 24pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 18.0pt; mso-fareast-language: ZH-CN">视区的使用<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></B></A></P><SPAN 
style="mso-bookmark: 视区的使用"></SPAN>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">
<HR align=center width="100%" SIZE=1>
</SPAN></DIV>
<P class=MsoNormal 
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN">本节提供有关使用视区的细节,信息被分为以下主题。<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l1 level1 lfo4; mso-list-change: &#61623;SGuy 20030510T1452"><![if !supportLists]><SPAN 
lang=EN-US 
style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-language: ZH-CN; mso-fareast-font-family: Symbol; mso-bidi-font-size: 12.0pt"><SPAN 
style="mso-list: Ignore">·<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN></SPAN><![endif]><U><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><A 
href="http://www.gesoftfactory.com/developer/VnC.htm#设置视区裁剪体">设置视区裁剪体</A></SPAN></U><SPAN 
lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l1 level1 lfo4; mso-list-change: &#61623;SGuy 20030510T1452"><![if !supportLists]><SPAN 
lang=EN-US 
style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-language: ZH-CN; mso-fareast-font-family: Symbol; mso-bidi-font-size: 12.0pt"><SPAN 
style="mso-list: Ignore">·<SPAN 
style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</SPAN></SPAN></SPAN><![endif]><U><SPAN lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><A 
href="http://www.gesoftfactory.com/developer/VnC.htm#清除视区">清除视区</A></SPAN></U><SPAN 
lang=EN-US 
style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-fareast-language: ZH-CN"><o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt; mso-list: l1 level1 lfo4; mso-list-change: &#61623;SGuy 20030510T1452"><![if !supportLists]><SPAN 
lang=EN-US 

⌨️ 快捷键说明

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