﻿<?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>IT博客-小祥的BLOG</title><link>http://www.cnitblog.com/xfxsworld/</link><description>游戏开发</description><language>zh-cn</language><lastBuildDate>Thu, 30 Apr 2026 12:58:57 GMT</lastBuildDate><pubDate>Thu, 30 Apr 2026 12:58:57 GMT</pubDate><ttl>60</ttl><item><title>搬家。。。</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/17/36406.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Sat, 17 Nov 2007 07:02:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/17/36406.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36406.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/17/36406.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36406.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36406.html</trackback:ping><description><![CDATA[新blog地址：<a href="http://xfxsworld.cnblogs.com/">http://xfxsworld.cnblogs.com/</a>
<img src ="http://www.cnitblog.com/xfxsworld/aggbug/36406.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-17 15:02 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/17/36406.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vs2005环境下CELayoutEditor源码编译详细步骤</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/16/36385.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Fri, 16 Nov 2007 12:37:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/16/36385.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36385.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/16/36385.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36385.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36385.html</trackback:ping><description><![CDATA[今天初试了一下CEGUI的官方编辑器——CELayoutEditor，其过程真可谓&#8220;饱受挫折&#8221;<img height=20 src="http://www.cnitblog.com/Emoticons/QQ/13.gif" width=20 border=0>。现简要写下其源码的编译过程，已使可能会用到的朋友少走些弯路<br><br>1.&nbsp;&nbsp;&nbsp;&nbsp;要编译CELayoutEditor，自然需要先编译CEGUI的东东，有2种选择：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.1 安装SDK，这是下载地址：<a href="http://jaist.dl.sourceforge.net/sourceforge/crayzedsgui/CEGUI-SDK-0.5.0b-vc8.exe">http://jaist.dl.sourceforge.net/sourceforge/crayzedsgui/CEGUI-SDK-0.5.0b-vc8.exe</a>，不过并不推荐这种方法，因为SDK里的debug版dll似乎有问题。。。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2 编译其源代码。下载地址：<a href="http://jaist.dl.sourceforge.net/sourceforge/crayzedsgui/CEGUI-0.5.0b.zip">http://jaist.dl.sourceforge.net/sourceforge/crayzedsgui/CEGUI-0.5.0b.zip</a>，另外还需要下载依赖文件包dependencies package ，下载地址是：<a href="http://jaist.dl.sourceforge.net/sourceforge/crayzedsgui/CEGUI-DEPS-0.5.0b-vc8.zip">http://jaist.dl.sourceforge.net/sourceforge/crayzedsgui/CEGUI-DEPS-0.5.0b-vc8.zip</a>，然后将依赖文件解压进源代码文件夹就OK了。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2.1&nbsp;&nbsp; 先别急着找solution，有个地方需要注意。CEGUI默认的是OPENGL渲染，如果是用D3D的话还得改一个地方。进..\makefiles\premake文件夹找到config.lua文件，记事本打开。改成&#8220;OPENGL_RENDERER = false，DIRECTX9_RENDERER = true&#8221;，保存。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.2.2&nbsp;&nbsp;&nbsp; 运行build_vs2005.bat文件，执行完毕后会生成CEGUI.sln文件，打开就可直接编译了<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.3&nbsp;&nbsp; 建立环境变量：我的电脑\属性\高级\环境变量，然后在上面的用户变量区新建一个，变量名是CEGUI，变量值是CEGUI的解压目录。注意这步不能省<br><br><br>2&nbsp;&nbsp;&nbsp; 由于CELayoutEditor使用了wxWidgets，所以在编译CELayoutEditor之前还需要下载wxWidgets。目前最新版本是2.86，进入官方下载网页<a href="http://www.wxwidgets.org/downloads/">http://www.wxwidgets.org/downloads/</a>&nbsp;选择WxAll下载。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1 建立环境变量：我的电脑\属性\高级\环境变量，然后在上面的用户变量区新建一个，变量名是WXWIDGETS，变量值是wxWidgets的解压目录。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.2&nbsp; 进wxWidgets的解压目录找到<font size=2>wx.dsw，打开、&#8220;Yes To All&#8221;转换。转换完毕后先别编译，还需要改下。因为<font size=3>wxWidgets默认并不是OPENGL</font><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">Open&nbsp;$(WXWIDGETS)\include\wx\msw\setup.h&nbsp;and&nbsp;replace&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Code:&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;wxUSE_GLCANVAS&nbsp;0&nbsp;&nbsp;</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>WITH&nbsp;Code:&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;wxUSE_GLCANVAS&nbsp;1&nbsp;</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">7.2</span><span style="COLOR: #000000">&nbsp;Open&nbsp;$(WXWIDGETS)\include\wx\univ\setup.h&nbsp;and&nbsp;replace&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Code:&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">#if</span><span style="COLOR: #000000">&nbsp;defined(__WIN32__)&nbsp;</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;wxUSE_GLCANVAS&nbsp;1&nbsp;</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;wxUSE_GLCANVAS&nbsp;0&nbsp;</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>WITH&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Code:&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;wxUSE_GLCANVAS&nbsp;1&nbsp;</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<p><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.3&nbsp;&nbsp;&nbsp; 现在就可以开始编译了。注意要选择&#8220;Unicode Debug&#8221;和&#8220;'Unicode Release&#8221;方式<br><br>3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下载CELayoutEditor。我是用SVN接的，地址是 <a class=postlink href="https://crayzedsgui.svn.sourceforge.net/svnroot/crayzedsgui/CELayoutEditor/trunk" target=_blank><font color=#006699>https://crayzedsgui.svn.sourceforge.net/svnroot/crayzedsgui/CELayoutEditor/trunk</font></a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.1&nbsp;&nbsp;&nbsp; 解压后打开工程，将Include和Lib路径改成自己的，其他的不用改<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.2&nbsp;&nbsp;&nbsp;&nbsp;建立环境变量：我的电脑\属性\高级\环境变量，然后在上面的用户变量区新建一个，变量名是CE_LAYOUT_EDITOR ，变量值是CELayoutEditor的解压目录。注意这步不能省<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.3&nbsp;&nbsp;&nbsp; 终于可以开始编译了。。。<img height=20 src="http://www.cnitblog.com/Emoticons/QQ/11.gif" width=20 border=0><br><br>4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.1&nbsp;&nbsp;&nbsp; 编译会出现一个错误，暂时我还没找到解决方法，仅仅是给错误的地方注释掉了。。。然后就编译成功了<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.2&nbsp;&nbsp;&nbsp; 拷一些东西过来</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">TO&nbsp;$(CE_LAYOUT_EDITOR)\bin\debug&nbsp;(Debug&nbsp;configuration)&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUIBase_d.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUIExpatParser_d.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUIFalagardWRBase_d.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUISILLYImageCodec_d.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUITGAImageCodec_d.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;OpenGLGUIRenderer_d.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;SILLY_d.dll<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>TO&nbsp;$(CE_LAYOUT_EDITOR)\bin\release&nbsp;(Release&nbsp;configuration)&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUIBase.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUIExpatParser.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUIFalagardWRBase.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUISILLYImageCodec.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;CEGUITGAImageCodec.dll&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;OpenGLGUIRenderer.dll<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;SILLY.dll</span></div>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.3 SILLY.dll和SILLY_d.dll在依赖文件夹里<br><br>OK。。。到这里就完了，虽然这个工具的bug很多，不过不怕，编译它就是为了要改造它，呵呵。希望此文对你有所帮助<img height=20 src="http://www.cnitblog.com/Emoticons/QQ/13.gif" width=20 border=0><br><br>开启画面<br><img style="WIDTH: 768px; HEIGHT: 565px" height=565 src="http://www.cnitblog.com/images/cnitblog_com/xfxsworld/splash.jpg" width=768 border=0><br><br><br>运行界面<br><img style="WIDTH: 815px; HEIGHT: 600px" height=600 src="http://www.cnitblog.com/images/cnitblog_com/xfxsworld/layout.jpg" width=815 border=0><br></p>
</font>
<img src ="http://www.cnitblog.com/xfxsworld/aggbug/36385.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-16 20:37 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/16/36385.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>恢复CEGUI渲染状态</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36330.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Thu, 15 Nov 2007 12:22:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36330.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36330.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36330.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36330.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36330.html</trackback:ping><description><![CDATA[
		<p>刚刚接触CEGUI，在原D3D程序上画了一个小窗口后，发现渲染效果于以前的大相径庭，查看了源代码后发现，原来CEGUI在渲染后并没有恢复到默认的渲染状态，于是改之，再编译、运行、一切正常。。。<img height="20" src="http://www.cnitblog.com/Emoticons/QQ/14.gif" width="20" border="0" /><br /><br />下面是恢复其渲染状态的代码，与初始化渲染状态函数initPerFrameStates()对应</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> DirectX9Renderer::UnitFrameStates()<br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_44_1575_Open_Image" onclick="this.style.display='none'; Codehighlighter1_44_1575_Open_Text.style.display='none'; Codehighlighter1_44_1575_Closed_Image.style.display='inline'; Codehighlighter1_44_1575_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_44_1575_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_44_1575_Closed_Text.style.display='none'; Codehighlighter1_44_1575_Open_Image.style.display='inline'; Codehighlighter1_44_1575_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_44_1575_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cnitblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_44_1575_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080"> 3</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> setup vertex stream</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080"> 4</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080"> 5</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetFVF(NULL);<br /></span>
						<span style="COLOR: #008080"> 6</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080"> 7</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> set device states</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080"> 8</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);<br /></span>
						<span style="COLOR: #008080"> 9</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);<br /></span>
						<span style="COLOR: #008080">10</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);<br /></span>
						<span style="COLOR: #008080">11</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_ZWRITEENABLE, TRUE);<br /></span>
						<span style="COLOR: #008080">12</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_FOGENABLE, FALSE);<br /></span>
						<span style="COLOR: #008080">13</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);<br /></span>
						<span style="COLOR: #008080">14</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">15</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">16</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> setup texture addressing settings/*</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">17</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetSamplerState( </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);<br /></span>
						<span style="COLOR: #008080">18</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetSamplerState( </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);<br /></span>
						<span style="COLOR: #008080">19</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">20</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> setup colour calculations</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">21</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DTSS_COLORARG1, D3DTA_TEXTURE);<br /></span>
						<span style="COLOR: #008080">22</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DTSS_COLORARG2, D3DTA_CURRENT);<br /></span>
						<span style="COLOR: #008080">23</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DTSS_COLOROP, D3DTOP_SELECTARG1);<br /></span>
						<span style="COLOR: #008080">24</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">25</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> setup alpha calculations</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">26</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);<br /></span>
						<span style="COLOR: #008080">27</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DTSS_ALPHAARG2, D3DTA_CURRENT);<br /></span>
						<span style="COLOR: #008080">28</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);<br /></span>
						<span style="COLOR: #008080">29</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">30</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> setup filtering</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">31</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetSamplerState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DSAMP_MINFILTER, D3DTEXF_POINT);<br /></span>
						<span style="COLOR: #008080">32</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetSamplerState(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, D3DSAMP_MAGFILTER, D3DTEXF_POINT);<br /></span>
						<span style="COLOR: #008080">33</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">34</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> disable texture stages we do not need.</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">35</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetTextureStageState(</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, D3DTSS_COLOROP, D3DTOP_DISABLE);<br /></span>
						<span style="COLOR: #008080">36</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">37</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> setup scene alpha blending</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">38</span>
						<span style="COLOR: #008000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);<br /></span>
						<span style="COLOR: #008080">39</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);<br /></span>
						<span style="COLOR: #008080">40</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     d_device</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">42</span>
						<span style="COLOR: #000000">
								<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
		<br />另外CEGUI有2种渲染模式：立即渲染和缓冲渲染。所以在这2种渲染模式结束后都需要调用上面的代码以恢复渲染状态<img src ="http://www.cnitblog.com/xfxsworld/aggbug/36330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-15 20:22 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36330.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Alpha混合</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36327.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Thu, 15 Nov 2007 11:40:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36327.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36327.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36327.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36327.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36327.html</trackback:ping><description><![CDATA[
		<div>
				<font face="Verdana">Direct3D计算Alpha混合的颜色公式：</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana" color="#ff0000">Color = ( SrcRGB * SrcK ) + ( DestRGB * DestK )</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana" color="#ff0000">
				</font> </div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana" color="#000000">SrcRGB表示源颜色值，即将要绘制的颜色值。SrcK表示源混合系数，通常赋值为D3DBLEND_SRCALPHA，即当前绘制像素的Alpha值</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">DestRGB表示目标颜色值，即当前缓冲区中的颜色值。DestK表示目标系数，通常赋值为D3DBLEND_INVSRCALPHA，即1减去当前绘制像素的Alpha值</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">
				</font> </div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">则Direct3D计算Alpha混合的颜色公式可表示为</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana" color="#ff0000">Color = ( SrcRGB * SrcAlpha ) + ( DestRGB * ( 1 - SrcAlpha ) )</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">
				</font> </div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">混合步骤</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">
				</font> </div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">Alpha混合默认关闭，所以首先需要开启它</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">Device -&gt; SetRenderState( D3DRS_ALPHABLENDENABLE, true );</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">
				</font> </div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">然后设置Alpha混合系数</font>
		</div>
		<div>
				<font style="BACKGROUND-COLOR: #fffafa" face="Verdana">Device -&gt; SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );</font>
		</div>
		<div>
				<font face="Verdana">Device -&gt; SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); </font>
		</div>
		<div>
				<font face="Verdana">
				</font> </div>
		<div>
				<font face="Verdana">还要指定资源(材质或Alpha通道)</font>
		</div>
		<div>
				<font face="Verdana">Alpha通道可用DirectX自带的纹理工具创建，为DDS文件</font>
		</div>
		<div>
				<font face="Verdana">
				</font> </div>
		<div>
				<font face="Verdana">DEMO演示图片:<br /><img height="476" alt="alphablend.jpg" src="http://www.cnitblog.com/images/cnitblog_com/xfxsworld/alphablend.jpg" width="630" border="0" /></font>
		</div>
<img src ="http://www.cnitblog.com/xfxsworld/aggbug/36327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-15 19:40 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>地形高度算法小结</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36325.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Thu, 15 Nov 2007 11:26:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36325.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36325.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36325.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36325.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36325.html</trackback:ping><description><![CDATA[
		<div>
				<font size="2">地形一般是用网格再从高度图里读取每个顶点的高度来生成。若进一步，想实现摄像机在地形上行走的效果，就需要算出地形上任意一点的高度。总结了3个方法：<br /> <br />一：<br />《Introduction to 3D Game Programming With Directx 9.0》这本书里介绍的，利用向量来算。<br /><img height="251" alt="11.jpg" src="http://www.cnitblog.com/images/cnitblog_com/xfxsworld/11.jpg" width="458" border="0" /><br /> </font>
		</div>
		<div>
				<font size="2">
						<br />
						<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
								<span style="COLOR: #008080"> 1</span>
								<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
								<span style="COLOR: #0000ff">float</span>
								<span style="COLOR: #000000"> Terrain::GetHeight(</span>
								<span style="COLOR: #0000ff">float</span>
								<span style="COLOR: #000000"> x, </span>
								<span style="COLOR: #0000ff">float</span>
								<span style="COLOR: #000000"> z)<br /></span>
								<span style="COLOR: #008080"> 2</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_43_2225_Open_Image" onclick="this.style.display='none'; Codehighlighter1_43_2225_Open_Text.style.display='none'; Codehighlighter1_43_2225_Closed_Image.style.display='inline'; Codehighlighter1_43_2225_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
										<img id="Codehighlighter1_43_2225_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_43_2225_Closed_Text.style.display='none'; Codehighlighter1_43_2225_Open_Image.style.display='inline'; Codehighlighter1_43_2225_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
								</span>
								<span id="Codehighlighter1_43_2225_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cnitblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_43_2225_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080"> 3</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> Translate on xz-plane by the transformation that takes<br /></span>
										<span style="COLOR: #008080"> 4</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> the terrain START point to the origin.</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080"> 5</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> x </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> ((</span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000">)_width </span>
										<span style="COLOR: #000000">/</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">2.0f</span>
										<span style="COLOR: #000000">) </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> x;<br /></span>
										<span style="COLOR: #008080"> 6</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> z </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> ((</span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000">)_depth </span>
										<span style="COLOR: #000000">/</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">2.0f</span>
										<span style="COLOR: #000000">) </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> z;<br /></span>
										<span style="COLOR: #008080"> 7</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> Scale down by the transformation that makes the <br /></span>
										<span style="COLOR: #008080"> 8</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> cellspacing equal to one.  This is given by <br /></span>
										<span style="COLOR: #008080"> 9</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> 1 / cellspacing since; cellspacing * 1 / cellspacing = 1.</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">10</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> x </span>
										<span style="COLOR: #000000">/=</span>
										<span style="COLOR: #000000"> (</span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000">)_CellSpacing;<br /></span>
										<span style="COLOR: #008080">11</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> z </span>
										<span style="COLOR: #000000">/=</span>
										<span style="COLOR: #000000"> (</span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000">)_CellSpacing;<br /></span>
										<span style="COLOR: #008080">12</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> From now on, we will interpret our positive z-axis as<br /></span>
										<span style="COLOR: #008080">13</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> going in the 'down' direction, rather than the 'up' direction.<br /></span>
										<span style="COLOR: #008080">14</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> This allows to extract the row and column simply by 'flooring'<br /></span>
										<span style="COLOR: #008080">15</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> x and z:</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">16</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> col </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> ::floorf(x);<br /></span>
										<span style="COLOR: #008080">17</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> row </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> ::floorf(z);<br /></span>
										<span style="COLOR: #008080">18</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> get the heights of the quad we're in:<br /></span>
										<span style="COLOR: #008080">19</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> <br /></span>
										<span style="COLOR: #008080">20</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">  A   B<br /></span>
										<span style="COLOR: #008080">21</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">  *---*<br /></span>
										<span style="COLOR: #008080">22</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">    | / |<br /></span>
										<span style="COLOR: #008080">23</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">  *---*  <br /></span>
										<span style="COLOR: #008080">24</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">  C   D</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">25</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> A </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> GetHeightMapEntry(row,   col);<br /></span>
										<span style="COLOR: #008080">26</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> B </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> GetHeightMapEntry(row,   col</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080">27</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> C </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> GetHeightMapEntry(row</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">, col);<br /></span>
										<span style="COLOR: #008080">28</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> D </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> GetHeightMapEntry(row</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">, col</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080">29</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">30</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> Find the triangle we are in:<br /></span>
										<span style="COLOR: #008080">31</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">32</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> Translate by the transformation that takes the upper-left<br /></span>
										<span style="COLOR: #008080">33</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> corner of the cell we are in to the origin.  Recall that our <br /></span>
										<span style="COLOR: #008080">34</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> cellspacing was nomalized to 1.  Thus we have a unit square<br /></span>
										<span style="COLOR: #008080">35</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> at the origin of our +x -&gt; 'right' and +z -&gt; 'down' system.</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">36</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> dx </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> x </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> col;<br /></span>
										<span style="COLOR: #008080">37</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> dz </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> z </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> row;<br /></span>
										<span style="COLOR: #008080">38</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> Note the below compuations of u and v are unneccessary, we really<br /></span>
										<span style="COLOR: #008080">39</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> only need the height, but we compute the entire vector to emphasis<br /></span>
										<span style="COLOR: #008080">40</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> the books discussion.</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">41</span>
										<span style="COLOR: #008000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">float</span>
										<span style="COLOR: #000000"> height </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0.0f</span>
										<span style="COLOR: #000000">;<br /></span>
										<span style="COLOR: #008080">42</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">(dz </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">1.0f</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> dx)  </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> upper triangle ABC</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">43</span>
										<span style="COLOR: #008000">
												<img id="Codehighlighter1_1554_1858_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1554_1858_Open_Text.style.display='none'; Codehighlighter1_1554_1858_Closed_Image.style.display='inline'; Codehighlighter1_1554_1858_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_1554_1858_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1554_1858_Closed_Text.style.display='none'; Codehighlighter1_1554_1858_Open_Image.style.display='inline'; Codehighlighter1_1554_1858_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> </span>
										<span id="Codehighlighter1_1554_1858_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.cnitblog.com/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_1554_1858_Open_Text">
												<span style="COLOR: #000000">{<br /></span>
												<span style="COLOR: #008080">44</span>
												<span style="COLOR: #000000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #0000ff">float</span>
												<span style="COLOR: #000000"> uy </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> B </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> A; </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> A-&gt;B</span>
												<span style="COLOR: #008000">
														<br />
												</span>
												<span style="COLOR: #008080">45</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
												</span>
												<span style="COLOR: #000000">  </span>
												<span style="COLOR: #0000ff">float</span>
												<span style="COLOR: #000000"> vy </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> C </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> A; </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> A-&gt;C<br /></span>
												<span style="COLOR: #008080">46</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> Linearly interpolate on each vector.  The height is the vertex<br /></span>
												<span style="COLOR: #008080">47</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> height the vectors u and v originate from {A}, plus the heights<br /></span>
												<span style="COLOR: #008080">48</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> found by interpolating on each vector u and v.</span>
												<span style="COLOR: #008000">
														<br />
												</span>
												<span style="COLOR: #008080">49</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
												</span>
												<span style="COLOR: #000000">  height </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> A </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> Lerp(</span>
												<span style="COLOR: #000000">0.0f</span>
												<span style="COLOR: #000000">, uy, dx) </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> Lerp(</span>
												<span style="COLOR: #000000">0.0f</span>
												<span style="COLOR: #000000">, vy, dz);<br /></span>
												<span style="COLOR: #008080">50</span>
												<span style="COLOR: #000000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" /> }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">51</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">else</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> lower triangle DCB</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">52</span>
										<span style="COLOR: #008000">
												<img id="Codehighlighter1_1889_2207_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1889_2207_Open_Text.style.display='none'; Codehighlighter1_1889_2207_Closed_Image.style.display='inline'; Codehighlighter1_1889_2207_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_1889_2207_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1889_2207_Closed_Text.style.display='none'; Codehighlighter1_1889_2207_Open_Image.style.display='inline'; Codehighlighter1_1889_2207_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000"> </span>
										<span id="Codehighlighter1_1889_2207_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.cnitblog.com/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_1889_2207_Open_Text">
												<span style="COLOR: #000000">{<br /></span>
												<span style="COLOR: #008080">53</span>
												<span style="COLOR: #000000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #0000ff">float</span>
												<span style="COLOR: #000000"> uy </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> C </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> D; </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> D-&gt;C</span>
												<span style="COLOR: #008000">
														<br />
												</span>
												<span style="COLOR: #008080">54</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
												</span>
												<span style="COLOR: #000000">  </span>
												<span style="COLOR: #0000ff">float</span>
												<span style="COLOR: #000000"> vy </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> B </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> D; </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> D-&gt;B<br /></span>
												<span style="COLOR: #008080">55</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> Linearly interpolate on each vector.  The height is the vertex<br /></span>
												<span style="COLOR: #008080">56</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> height the vectors u and v originate from {D}, plus the heights<br /></span>
												<span style="COLOR: #008080">57</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000"> found by interpolating on each vector u and v.</span>
												<span style="COLOR: #008000">
														<br />
												</span>
												<span style="COLOR: #008080">58</span>
												<span style="COLOR: #008000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
												</span>
												<span style="COLOR: #000000">  height </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> D </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> Lerp(</span>
												<span style="COLOR: #000000">0.0f</span>
												<span style="COLOR: #000000">, uy, </span>
												<span style="COLOR: #000000">1.0f</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> dx) </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> Lerp(</span>
												<span style="COLOR: #000000">0.0f</span>
												<span style="COLOR: #000000">, vy, </span>
												<span style="COLOR: #000000">1.0f</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> dz);<br /></span>
												<span style="COLOR: #008080">59</span>
												<span style="COLOR: #000000">
														<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" /> }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">60</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span>
										<span style="COLOR: #0000ff">return</span>
										<span style="COLOR: #000000"> height;<br /></span>
										<span style="COLOR: #008080">61</span>
										<span style="COLOR: #000000">
												<img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">62</span>
								<span style="COLOR: #000000">
										<img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />
								</span>
						</div> <br />用到的2个函数<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> Terrain::Lerp(</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> a, </span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> b, </span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> t)     </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">一个插值函数</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">2</span><span style="COLOR: #008000"><img id="Codehighlighter1_60_91_Open_Image" onclick="this.style.display='none'; Codehighlighter1_60_91_Open_Text.style.display='none'; Codehighlighter1_60_91_Closed_Image.style.display='inline'; Codehighlighter1_60_91_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_60_91_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_60_91_Closed_Text.style.display='none'; Codehighlighter1_60_91_Open_Image.style.display='inline'; Codehighlighter1_60_91_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_60_91_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cnitblog.com/images/dot.gif" /></span><span id="Codehighlighter1_60_91_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> (a </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> (a</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">t) </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> (b</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">t));<br /></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Terrain::GetHeightMapEntry(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> row, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> col)         </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">读取高度函数</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">7</span><span style="COLOR: #008000"><img id="Codehighlighter1_160_235_Open_Image" onclick="this.style.display='none'; Codehighlighter1_160_235_Open_Text.style.display='none'; Codehighlighter1_160_235_Closed_Image.style.display='inline'; Codehighlighter1_160_235_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_160_235_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_160_235_Closed_Text.style.display='none'; Codehighlighter1_160_235_Open_Image.style.display='inline'; Codehighlighter1_160_235_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_160_235_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cnitblog.com/images/dot.gif" /></span><span id="Codehighlighter1_160_235_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">8</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> _heightmap[row </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> _numVertsPerRow </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> col];   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 高度图数据存在_heightmap里</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">9</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /></span><span style="COLOR: #000000">}</span></span></div><br /> <br />二：<br />先计算出摄像机所在三角形的平面方程，然后带入摄像机的X，Z坐标，即可得高度Y<br />具体实现过程见<a href="http://creatorchen1984.spaces.live.com/">http://creatorchen1984.spaces.live.com/</a> 《获取地形上某一点高度》，写的十分详细<br /> <br />三：<br />网上找的一个方法<br />假设你的地形为terrain[][];用下面的函数求出地形上点(x,z);的y值,将人物的高度加上这个y值即可.<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span><img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> GetHeight(GLfloat x, GLfloat z)<br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img id="Codehighlighter1_38_287_Open_Image" onclick="this.style.display='none'; Codehighlighter1_38_287_Open_Text.style.display='none'; Codehighlighter1_38_287_Closed_Image.style.display='inline'; Codehighlighter1_38_287_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_38_287_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_38_287_Closed_Text.style.display='none'; Codehighlighter1_38_287_Open_Image.style.display='inline'; Codehighlighter1_38_287_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_38_287_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cnitblog.com/images/dot.gif" /></span><span id="Codehighlighter1_38_287_Open_Text"><span style="COLOR: #000000">{ <br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> h</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> Xb,Yb;<br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Xa,Ya;<br /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />Xa</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">)x;<br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />Ya</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">)z;<br /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />Xb</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">x</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Xa;<br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />Yb</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">z</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Ya;<br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> a</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">terrain[Xa][Ya].y;<br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> b</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">terrain[Xa</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][Ya].y;<br /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> c</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">terrain[Xa][Ya</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">].y;<br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000"> d</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">terrain[Xa</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][Ya</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">].y;<br /></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />h</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Xb)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">b</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">Xb)</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Yb)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">(c</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">Xb)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">d</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">Xb)</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">Yb;<br /></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> h;<br /></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> <br /></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div></font>
		</div>
<img src ="http://www.cnitblog.com/xfxsworld/aggbug/36325.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-15 19:26 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36325.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>&lt;转&gt; c++指针 指针入门</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36324.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Thu, 15 Nov 2007 11:19:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36324.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36324.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36324.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36324.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36324.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 这是一篇我所见过的关于指针的最好的入门级文章，它可使初学者在很短的时间内掌握复杂的指针操作。虽然，现在的Java、C＃等语言已经取消了指针，但作为一个C++程序员，指针的直接操作内存，在数据操作方面有着速度快，节约内存等优点，仍是很多C++程序员的最爱。指针就像是一把良剑，就看你怎么去应用它!　什么是指针？　　其实指针就像是其它变量一样，所不同的是一般的变量包含的是实际的真实的数据，而指针是一个指...&nbsp;&nbsp;<a href='http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36324.html'>阅读全文</a><img src ="http://www.cnitblog.com/xfxsworld/aggbug/36324.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-15 19:19 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36324.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DirectX下 Viewing Frustum 的详细实现</title><link>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36321.html</link><dc:creator>小祥</dc:creator><author>小祥</author><pubDate>Thu, 15 Nov 2007 10:40:00 GMT</pubDate><guid>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36321.html</guid><wfw:comment>http://www.cnitblog.com/xfxsworld/comments/36321.html</wfw:comment><comments>http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36321.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/xfxsworld/comments/commentRss/36321.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/xfxsworld/services/trackbacks/36321.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 本文大部分内容翻译自Gil Gribb和Klaus Hartmann合写的《Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix》这篇文章，有兴趣的朋友可以搜索看下原文，里面DirectX下和OpenGL下的实现过程都说的很清楚，这里只说DirectX部分。 这里介绍的算法，可以直接从世界、观...&nbsp;&nbsp;<a href='http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36321.html'>阅读全文</a><img src ="http://www.cnitblog.com/xfxsworld/aggbug/36321.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/xfxsworld/" target="_blank">小祥</a> 2007-11-15 18:40 <a href="http://www.cnitblog.com/xfxsworld/archive/2007/11/15/36321.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>