﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-GraphicSir-文章分类-DirectX</title><link>http://www.cppblog.com/topjackhjj/category/9562.html</link><description>游戏技术,实时渲染技术</description><language>zh-cn</language><lastBuildDate>Wed, 24 Jun 2009 14:05:37 GMT</lastBuildDate><pubDate>Wed, 24 Jun 2009 14:05:37 GMT</pubDate><ttl>60</ttl><item><title>DX下的屏幕分割</title><link>http://www.cppblog.com/topjackhjj/articles/88219.html</link><dc:creator>翾</dc:creator><author>翾</author><pubDate>Sun, 21 Jun 2009 07:51:00 GMT</pubDate><guid>http://www.cppblog.com/topjackhjj/articles/88219.html</guid><wfw:comment>http://www.cppblog.com/topjackhjj/comments/88219.html</wfw:comment><comments>http://www.cppblog.com/topjackhjj/articles/88219.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/topjackhjj/comments/commentRss/88219.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/topjackhjj/services/trackbacks/88219.html</trackback:ping><description><![CDATA[
		<p>近日因公司项目需要，写了个屏幕分割渲染的功能。<br /><br />如下图所示：假设我们有一个场景，场景里面大多数是静态对象（对应图中黑色点），而只有小量的动态对象并且相对集中（对应图中红色点），那么我们在渲染的时候，只要一开始将整个屏幕渲染一次，在后面只更新动态对象所在的区域就可以了。<br /><br /><img src="http://www.cppblog.com/images/cppblog_com/topjackhjj/10917/r_proj.PNG" /><br /><br />在测试例子中，我们将整个屏幕分成左右2块，各自分别对应一个投影矩阵和一个视口，他们共用一个视图矩阵和世界矩阵。在如何决定子屏幕所使用的投影矩阵时，主要采用 D3DXMatrixPerspectiveOffCenterLH（）或 D3DXMatrixPerspectiveOffCenterRH（）这2个函数。具体描述如下：</p>
		<p>D3DXMatrixPerspectiveOffCenterLH()<br />Builds a customized, left-handed perspective projection matrix. </p>
		<p>    <br />D3DXMATRIX * D3DXMatrixPerspectiveOffCenterLH(<br />        D3DXMATRIX * pOut,<br />        FLOAT        l,<br />        FLOAT        r,<br />        FLOAT        b,<br />        FLOAT        t,<br />        FLOAT        zn,<br />        FLOAT        zf);<br />  <br />Parameters <br />pOut <br />[in, out] Pointer to the D3DXMATRIX structure that is the result of the operation. <br />l <br />[in] Minimum x-value of the view volume. <br />r <br />[in] Maximum x-value of the view volume. <br />b <br />[in] Minimum y-value of the view volume. <br />t <br />[in] Maximum y-value of the view volume. <br />zn <br />[in] Minimum z-value of the view volume. <br />zf <br />[in] Maximum z-value of the view volume. <br />Return Values <br />Pointer to a D3DXMATRIX structure that is a customized, left-handed perspective projection matrix. </p>
		<p>Remarks <br />All the parameters of the D3DXMatrixPerspectiveOffCenterLH function are distances in camera space. The parameters describe the dimensions of the view volume. </p>
		<p>The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMatrixPerspectiveOffCenterLH function can be used as a parameter for another function. </p>
		<p>This function uses the following formula to compute the returned matrix. </p>
		<p>
				<font face="Courier New">2*zn/(r-l)   0            0              0<br />0            2*zn/(t-b)   0              0<br />(l+r)/(l-r)  (t+b)/(b-t)  zf/(zf-zn)     1<br />0            0            zn*zf/(zn-zf)  0</font>
		</p>
		<p> </p>
		<p>
				<br />D3DXMatrixPerspectiveOffCenterRH()<br />Builds a customized, right-handed perspective projection matrix. <br />    <br />D3DXMATRIX * D3DXMatrixPerspectiveOffCenterRH(<br />        D3DXMATRIX * pOut,<br />        FLOAT        l,<br />        FLOAT        r,<br />        FLOAT        b,<br />        FLOAT        t,<br />        FLOAT        zn,<br />        FLOAT        zf);<br />    <br />  <br />Parameters <br />pOut <br />[in, out] Pointer to the D3DXMATRIX structure that is the result of the operation. <br />l <br />[in] Minimum x-value of the view volume. <br />r <br />[in] Maximum x-value of the view volume. <br />b <br />[in] Minimum y-value of the view volume. <br />t <br />[in] Maximum y-value of the view volume. <br />zn <br />[in] Minimum z-value of the view volume. <br />zf <br />[in] Maximum z-value of the view volume. <br />Return Values <br />Pointer to a D3DXMATRIX structure that is a customized, right-handed perspective projection matrix. </p>
		<p>Remarks <br />All the parameters of the D3DXMatrixPerspectiveOffCenterRH function are distances in camera space. The parameters describe the dimensions of the view volume. </p>
		<p>The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMatrixPerspectiveOffCenterRH function can be used as a parameter for another function. </p>
		<p>This function uses the following formula to compute the returned matrix. </p>
		<p>
				<font face="Courier New">2*zn/(r-l)   0            0                0<br />0            2*zn/(t-b)   0                0<br />(l+r)/(r-l)  (t+b)/(t-b)  zf/(zn-zf)      -1<br />0            0            zn*zf/(zn-zf)    0</font>
				<br />  <br /><a href="/Files/topjackhjj/MultiProjection.rar"><br /><br />download: DEMO and source</a></p>
<img src ="http://www.cppblog.com/topjackhjj/aggbug/88219.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/topjackhjj/" target="_blank">翾</a> 2009-06-21 15:51 <a href="http://www.cppblog.com/topjackhjj/articles/88219.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>