﻿<?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博客-平民程序 - linghuye's blog-随笔分类-我的3D引擎 －DestinyMatrix</title><link>http://www.cnitblog.com/linghuye/category/893.html</link><description>&lt;p align=right style="background-color: transparent"&gt;天下风云出我辈，一入江湖岁月催。皇图霸业谈笑中，不胜人生一场醉。提剑跨骑挥鬼雨，白骨如山鸟惊飞。尘事如潮人如水，只笑江湖几人回。&lt;p align=right style="background-color: transparent;"&gt;&lt;/p&gt;</description><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 10:39:22 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 10:39:22 GMT</pubDate><ttl>60</ttl><item><title>glSwapBuffer阻塞的几点猜测</title><link>http://www.cnitblog.com/linghuye/archive/2008/07/01/46188.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Tue, 01 Jul 2008 01:22:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2008/07/01/46188.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/46188.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2008/07/01/46188.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/46188.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/46188.html</trackback:ping><description><![CDATA[1.当前理论帧率远大于60帧,但垂直同步被打开,SwapBuffer阻塞以保证垂直同步.这个是低级错误.<br>2.整个场景画面或画面中的一块的渲染像素层叠覆盖过多,像素填充率瓶颈.这个很少发生,在高端显卡上这一般不是瓶颈.<br>3.调用OpenGL废指令过多,造成命令缓冲庞大,glSwapBuffer等待指令完成.<br>4.在一轮Render中,对上百个GL_ELEMENT_ARRAY_BUFFER_ARB作glBufferSubData时,Nvidia显卡下出现,原因不确定,估计VBO的使用导致了的同步问题,替换为直接使用内存指针后正常.<br><br><br>Reference:<br><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=306224&amp;whichpage=1"><span style="COLOR: #ffff00">http://www.gamedev.net/community/forums/topic.asp?topic_id=306224&amp;whichpage=1</span></a><span style="COLOR: #ffff00">?<br></span><a href="http://developer.apple.com/graphicsimaging/opengl/optimizingdata.html"><span style="COLOR: #ffff00">http://developer.apple.com/graphicsimaging/opengl/optimizingdata.html</span></a><br><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=338336"><span style="COLOR: #ffff00">http://www.gamedev.net/community/forums/topic.asp?topic_id=338336</span></a> 
<img src ="http://www.cnitblog.com/linghuye/aggbug/46188.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2008-07-01 09:22 <a href="http://www.cnitblog.com/linghuye/archive/2008/07/01/46188.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>OpenGL/DirectX渲染技巧集</title><link>http://www.cnitblog.com/linghuye/archive/2007/02/08/22837.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Thu, 08 Feb 2007 12:01:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2007/02/08/22837.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/22837.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2007/02/08/22837.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/22837.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/22837.html</trackback:ping><description><![CDATA[1.树叶/动物嘴上的牙齿,胡须/身上的鬃毛,形状曲折复杂,若直接用三角形带构建会大大增加物体的三角形数,所以应使用少量的三角形加Alpha纹理来实现.过滤了Alpha的纹理可以描绘出曲折的形状边缘.<br>2.怪物眼睛发光,那是用了额外附着的不透明的纹理三角片,很可能还是billboard.<br>3.该GL_CULL_FACE的地方应该Cull Face,以提升效率.<br>4.BLEND_MODULATE_2X使盔甲呈现高亮, BLEND_ADDITIVE_ALPHA增加加物体细节.<br>5.WoW的登录界面就是个m2 + xml + lua,一个模型搞定一个界面. <br>6.在3D空间中画一个中间镂空的平面边形(由三角形Mesh拼接而成),纹理使用全黑,SrcBlend=ZERO,DstBlend=ONE,这样渲染后,在画面上完全没有起变化,但是DepthBuffer起变化了,画过的地方已经出现了深度值,人物走到这地方会出现被透明的墙挡住的效果.
<img src ="http://www.cnitblog.com/linghuye/aggbug/22837.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2007-02-08 20:01 <a href="http://www.cnitblog.com/linghuye/archive/2007/02/08/22837.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DrawIndexedPrimitiveUP这个函数</title><link>http://www.cnitblog.com/linghuye/archive/2007/02/03/22602.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Fri, 02 Feb 2007 16:07:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2007/02/03/22602.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/22602.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2007/02/03/22602.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/22602.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/22602.html</trackback:ping><description><![CDATA[<p>最近被DrawIndexedPrimitiveUP这个函数搞崩了好几次,甚至连显卡的Blue Screen Of Death也出来凑热闹了,所以需要总结一下它崩溃的可能原因,理清下头绪:<br>1.与OpenGL的glXXXPointer一样,如果指针内存错误,崩溃是肯定的,这种bug比较好找.<br>DirectX的原因更复杂:<br>2.DrawIndexedPrimitiveUP不直接崩溃,而是在Present的时候崩溃.可能SetIndices的索引缓冲指针是野指针,LPDIRECT3DVERTEXDECLARATION9是野指针.<br><br>解决方法:使用Debug Runtime排除所有异常调用,这对显卡驱动程序蓝屏崩溃或异常现象的调试十分有效,如:<br>Direct3D9: Decl Validator: X249: (Element Error) (Decl Element [5]) Declaration can't map to fixed function FVF because blendweight must use D3DDECLTYPE_FLOAT1/2/3/4.<br>Direct3D9: (ERROR) :DrawIndexedPrimitive failed.<br><br>3.又发现一种DrawIndexedPrimitiveUP错误,当错误地把索引个数作为第2个参数传入(实际上第2个参数应该是顶点个数), 导致程序在运行一段不定时间,随机地,可能地,花屏了.此时DX8报告一个驱动程序的错误:<br>Direct3D8: (ERROR) :Driver not handled in DrawPrimitives2<br>Direct3D8: (ERROR) :Driver returned error: DDERR_INVALIDPARAMS&nbsp;&nbsp;<br>Direct3D8: (ERROR) :Driver failed command batch. Attempting to reset device state. The device may now be in an unstable state and the application may experience an access violation.<br><br>另:在试图安装现在的DirectX Debug Runtime时发现先前网上的资料或MSDN里都没谈到现在的安装方法:把Developer Runtime\x86里的dll复制到System32目录,然后再运行Utilities\Bin\x86\dxcpl.exe切换到Debug Rumtime模式.运行REF模式需要Debug Runtime环境!<br><br>Reference:<br><a style="COLOR: #ffff00" href="http://linghuye.googlepages.com/MyownlittleDirectXFAQ.mht">http://linghuye.googlepages.com/MyownlittleDirectXFAQ.mht</a><a href="http://tomsdxfaq.blogspot.com/"><font color=#ffff00></font></a></p>
<img src ="http://www.cnitblog.com/linghuye/aggbug/22602.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2007-02-03 00:07 <a href="http://www.cnitblog.com/linghuye/archive/2007/02/03/22602.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyWarCraftStudio 0.10.6337</title><link>http://www.cnitblog.com/linghuye/archive/2007/01/28/22395.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Sun, 28 Jan 2007 07:18:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2007/01/28/22395.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/22395.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2007/01/28/22395.html#Feedback</comments><slash:comments>22</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/22395.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/22395.html</trackback:ping><description><![CDATA[1.Update MyWarCraftStudio to 0.10.6337 for supporting Burning Crusade final formal client 2.0.6.6337.<br />2.It should be compatible with the normal 1.12 wow client.<br />3.I try to experiment DirectX rendering in this version. Change the Cnfg\MyWarCraftStudio.xml about &lt;RenderEngine API="OpenGL"/&gt; to &lt;RenderEngine API="DirectX"/&gt;. Be aware of bugs.<br /><br /><a href="/Files/linghuye/MyWarCraftStudio_0.10.6337.rar"><font color="#ffff00">http://www.cnitblog.com/Files/linghuye/MyWarCraftStudio_0.10.6337.rar</font></a><br /><a href="http://linghuye.googlepages.com/MyWarCraftStudio_0.10.6337.rar"><font color="#ffff00">http://linghuye.googlepages.com/MyWarCraftStudio_0.10.6337.rar</font></a><img src ="http://www.cnitblog.com/linghuye/aggbug/22395.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2007-01-28 15:18 <a href="http://www.cnitblog.com/linghuye/archive/2007/01/28/22395.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HLSL骨骼动画实现</title><link>http://www.cnitblog.com/linghuye/archive/2007/01/22/22226.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Mon, 22 Jan 2007 14:58:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2007/01/22/22226.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/22226.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2007/01/22/22226.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/22226.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/22226.html</trackback:ping><description><![CDATA[最近将我的DestinyMatrix图形接口用DirectX实现了一遍,过程中接口又进化了一次,现在可以像WoW一样选择使用那个API来渲染WoW的场景,觉得挺不错的.又用HLSL实现了一次骨骼动画:<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: #0000ff">struct</span><span style="COLOR: #000000"> VS_INPUT<br /><img id="Codehighlighter1_16_164_Open_Image" onclick="this.style.display='none'; Codehighlighter1_16_164_Open_Text.style.display='none'; Codehighlighter1_16_164_Closed_Image.style.display='inline'; Codehighlighter1_16_164_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_16_164_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_16_164_Closed_Text.style.display='none'; Codehighlighter1_16_164_Open_Image.style.display='inline'; Codehighlighter1_16_164_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_16_164_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_16_164_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float3 position : POSITION;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float2 texCoord    : TEXCOORD0;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float4 weight     : BLENDWEIGHT;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float4 bone        : BLENDINDICES;  <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></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" /></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> VS_OUTPUT<br /><img id="Codehighlighter1_185_282_Open_Image" onclick="this.style.display='none'; Codehighlighter1_185_282_Open_Text.style.display='none'; Codehighlighter1_185_282_Closed_Image.style.display='inline'; Codehighlighter1_185_282_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_185_282_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_185_282_Closed_Text.style.display='none'; Codehighlighter1_185_282_Open_Image.style.display='inline'; Codehighlighter1_185_282_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_185_282_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_185_282_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float4 position : POSITION;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float2 texCoord : TEXCOORD0;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float4 color     : COLOR;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></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" />uniform matrix modelViewProj;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/None.gif" align="top" />uniform matrix boneMatrices[</span><span style="COLOR: #000000">60</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" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000"> VS_INPUT inVert, </span><span style="COLOR: #0000ff">out</span><span style="COLOR: #000000"> VS_OUTPUT outVert)<br /><img id="Codehighlighter1_403_1001_Open_Image" onclick="this.style.display='none'; Codehighlighter1_403_1001_Open_Text.style.display='none'; Codehighlighter1_403_1001_Closed_Image.style.display='inline'; Codehighlighter1_403_1001_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_403_1001_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_403_1001_Closed_Text.style.display='none'; Codehighlighter1_403_1001_Open_Image.style.display='inline'; Codehighlighter1_403_1001_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_403_1001_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_403_1001_Open_Text"><span style="COLOR: #000000">{    <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float4 blendVertex </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> float4(</span><span style="COLOR: #000000">0.0f</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0.0f</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0.0f</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0.0f</span><span style="COLOR: #000000">);<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    float4 blendWeight </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> inVert.weight;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    int4 blendBone </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> int4(inVert.bone);<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_586_843_Open_Image" onclick="this.style.display='none'; Codehighlighter1_586_843_Open_Text.style.display='none'; Codehighlighter1_586_843_Closed_Image.style.display='inline'; Codehighlighter1_586_843_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_586_843_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_586_843_Closed_Text.style.display='none'; Codehighlighter1_586_843_Open_Image.style.display='inline'; Codehighlighter1_586_843_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_586_843_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_586_843_Open_Text"><span style="COLOR: #000000">{    <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(blendWeight.x </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0.0f</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_633_837_Open_Image" onclick="this.style.display='none'; Codehighlighter1_633_837_Open_Text.style.display='none'; Codehighlighter1_633_837_Closed_Image.style.display='inline'; Codehighlighter1_633_837_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_633_837_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_633_837_Closed_Text.style.display='none'; Codehighlighter1_633_837_Open_Image.style.display='inline'; Codehighlighter1_633_837_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span id="Codehighlighter1_633_837_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_633_837_Open_Text"><span style="COLOR: #000000">{    <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            blendVertex </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> mul(float4(inVert.position, </span><span style="COLOR: #000000">1.0f</span><span style="COLOR: #000000">), boneMatrices[blendBone.x]) </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> blendWeight.x;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            blendBone </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> blendBone.yzwx;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            blendWeight </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> blendWeight.yzwx;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    outVert.position </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> mul(blendVertex, modelViewProj);    <br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    outVert.texCoord </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> inVert.texCoord;<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    outVert.color </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> float4(</span><span style="COLOR: #000000">1.0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">1.0f</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">1.0f</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">1.0f</span><span style="COLOR: #000000">);<br /><img src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div>对比HLSL和GLSL,<br />1.OpenGL里的顶点属性attribute在DirectX里是通过SetStreamSource设置进去,感觉OpenGL的顶点attribute的思想更灵活.<br />2.为了实现接口,DirectX使用了多流模式与OpenGL的glXXXPointer保持思想上的兼容.<br />3.GLSL和Cg的顶点计算是标准数学的mul(mat, v),而HLSL是mul(v, mat),我调试了很久才发现 ：(<br />4.HLSL的modelViewProj需要外部程序使用LPD3DXCONSTANTTABLE设置Matrix变量,而GLSL是内置的变量不需要外部传入.<img src ="http://www.cnitblog.com/linghuye/aggbug/22226.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2007-01-22 22:58 <a href="http://www.cnitblog.com/linghuye/archive/2007/01/22/22226.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>身处何乡</title><link>http://www.cnitblog.com/linghuye/archive/2006/10/20/18206.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Fri, 20 Oct 2006 13:25:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2006/10/20/18206.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/18206.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2006/10/20/18206.html#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/18206.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/18206.html</trackback:ping><description><![CDATA[
		<p>基于Portal的引擎如何知道当前人物处于哪个sector是个难决的问题.用google搜索了一下论坛,有两种方案:<br />一种主张跟踪人物位置,给定一个起始sector,而后时刻检查人物是否穿过某个portal平面,一旦穿过则更新当前人物的sector位置变量.<br />一种主张实时计算,需要附加的对sector进行划分的bsp树数据进行计算.</p>
		<p>在程序逻辑上,我比较倾向第2种,因为其逻辑概念比较清晰简单,但其需要额外的数据制作,wmo数据的BSP树是普通的leafy bsp,而非solid leafy bsp,似乎不足以判断一个点是否在BSP整体空间内,而且不能适应2个sector相嵌套的情形,WoW的城内的建筑portal摆放随意性很大,似乎没什么限制.</p>
		<p>而判断人物穿过portal,感觉上逻辑比较模糊,脆弱,不稳定.当人物一直在portal边上左右徘徊时,算法是否够强壮?人物初始化时,又通过什么手段得知其初始sector呢?人物从城外进入城内的瞬间,又如何知道进入哪个sector?</p>
		<p>WoW使用了哪一种呢?至少穿越portal这方案还可以实现出来,Crystal Space也是这么干的,可惜大部分的资料根本不提这一问题.<br /></p>
<img src ="http://www.cnitblog.com/linghuye/aggbug/18206.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2006-10-20 21:25 <a href="http://www.cnitblog.com/linghuye/archive/2006/10/20/18206.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>程序启动内存分析报告</title><link>http://www.cnitblog.com/linghuye/archive/2006/03/21/7894.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Tue, 21 Mar 2006 05:50:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2006/03/21/7894.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/7894.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2006/03/21/7894.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/7894.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/7894.html</trackback:ping><description><![CDATA[
		<p>1.DM游戏程序进程Windows环境初始后3.7兆,考虑到使用了众多底层的初始化,且libavcodec.dll体积较大,正常.<br />2.启动OpenGL环境后激增到10.9兆,消耗7M内存,比较大,尚能接受.<br />   ChoosePixelFormat: 耗费1.1M<br />   wglCreateContext:  耗费0.5M<br />   wglMakeCurrent:    耗费5.3M<br />3.lua脚本环境,脚本执行后消耗不到500K,cool!<br />4.载入一般格式纹理消耗68M内存,达到78.5M内存消耗,不能容忍,必须使用压缩格式.<br />   a.对支持GL_ARB_texture_compression的显卡采用纹理压缩,启动时间变得稍微延长,尚能接受.<br />   消耗内存骤减至17M,达到28M内存消耗.<br />   b.glTexSubImage作用于压缩纹理时,对子块纹理的大小也有强制要求,虽然不需要2的n次方,但需要是4的整数倍,否则在不支持NPOT显卡上会失败,INVALID_OPERATION.后来测试发现,各种显卡的这个能力都很不稳定,甚至导致程序崩溃,另外纹理载入时间较长,所以使用预压缩的纹理是最终的解决方案.<br />5.载入一个大小的字体消耗4M内存,到82.6,再载入一个大小字体又4M内存,达86.7M,不能容忍.FTGL的实现对中文支持的纹理内存消耗上有重大设计问题.<br />    a.修改FTGL对中文支持中的错误,把中文当英文处理,结果分配了4096*1024的大纹理,浪费啊,改为512*512,消耗骤减至256k.<br />6.音效系统和声音文件消耗4M内存,尚可.<br />    a.需要优化<br />7.最终程序30M内存消耗.</p>
<img src ="http://www.cnitblog.com/linghuye/aggbug/7894.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2006-03-21 13:50 <a href="http://www.cnitblog.com/linghuye/archive/2006/03/21/7894.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>暂停所有程序技术研究,专心研究如何哄女朋友开心.</title><link>http://www.cnitblog.com/linghuye/archive/2006/03/13/7528.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Mon, 13 Mar 2006 04:51:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2006/03/13/7528.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/7528.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2006/03/13/7528.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/7528.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/7528.html</trackback:ping><description><![CDATA[<P><FONT color=#ffffff>恋爱症候群 - 黃舒駿 <BR>&nbsp;&nbsp;&nbsp;&nbsp; 曲︰黃舒駿<BR>&nbsp;&nbsp;&nbsp;&nbsp; 詞︰黃舒駿</FONT></P>
<P><FONT color=#ffffff>关于恋爱症候群的发生原因<BR>至今仍然是最大的一个谜<BR>不管性别年龄职业体重学历长相和血型<BR>没有一个人可以免疫<BR>有些专家学者研究后相信<BR>恋爱是内分泌失调所引起<BR>却有别人认为恋爱属于过滤性簿<BR>像感冒无药可救但会自动痊愈<BR>不管你同不同意<BR>自古到今许多例子证明<BR>恋爱不但是一种病态<BR>它还可能是一种变态</FONT></P>
<P><FONT color=#ffffff>一般发病后的初期反应<BR>会开始改变一些生活习性<BR>洗澡洗得特别干净刷牙刷得特别用力<BR>半夜里突然爬起来弹钢琴<BR>有人每天站在阳台对路人傻笑<BR>有人突然疯疯癫癫突然很安静<BR>有人一脸痴呆对著镜子咬著指甲打喷嚏<BR>有人对小狗骂三字经</FONT></P>
<P><FONT color=#ffffff>女人突然改变发型<BR>男人开始每天练著哑铃<BR>食欲不振歇斯底里四肢萎缩神经过敏发抖<BR>抽筋都出现在这时期<BR>随著病情越来越变本加厉<BR>人会变得格外敏感勇敢和恶心<BR>写的唱的说的都像天才诗人一般才华洋溢<BR>愈肉麻愈觉得有趣</FONT></P>
<P><FONT color=#ffffff>有人恋爱之后每天躲在厕所哭泣<BR>有人开记者会宣布恋爱的消息<BR>有人总是喜欢两个人躲在黑漆漆的地方<BR>像做了不可告人的事情<BR>每天忙著找人算命<BR>挖空心思改变自己配合对方的习性<BR>把每天都当作记念日<BR>把自己当作记念品</FONT></P>
<P><FONT color=#ffffff>每天漫无目的腻在一起<BR>言不及意也决得好有趣<BR>走著坐著躺著趴著都行影不离<BR>像是两人三脚又像连体婴<BR>心里想的只有爱你爱你爱你爱你<BR>也不管家里米缸有没有米<BR>也不管路上有人示威抗议<BR>只管爱你<BR>心里想的只有爱你爱你爱你爱你<BR>也不管海峡两岸统一问题<BR>也不管埃塞俄比亚多少难民<BR>只管爱你</FONT></P>
<P><FONT color=#ffffff>经过一段轰轰烈烈热恋时期<BR>不久就会开始渐渐痊愈<BR>两人开始互相厌倦互相攻击对方缺点<BR>所有甜言蜜语都随风而去<BR>然后开始从错觉和误解中清醒<BR>惊讶自己为何如此不聪明<BR>为了爱情不管一切<BR>不顾父母朋友姐妹兄弟<BR>开始感到后悔不已<BR>然后开始感到疲惫沉闷气喘心悸牙痛头痛梦呓<BR>然后是精神不济瞳孔放大脾气暴躁四肢麻痹<BR>终于受不了要分离</FONT></P>
<P><FONT color=#ffffff>虽然结果颇令人伤心<BR>了解之后也没什么了不起<BR>爱情终究是握不住的云<BR>只是我想要告诉你</FONT></P>
<P><FONT color=#ffffff>哦...<BR>在我落寞的岁月里<BR>你的温柔解脱我的孤寂<BR>带给我深深的狂喜<BR>如此颤动著我的心灵<BR>轻轻诉说爱你爱你爱你爱你<BR>不管是黑夜或是黎明<BR>不管是梦中或是清醒<BR>深深爱你<BR>我要对你说爱你爱你爱你爱你<BR>不管是黑夜或是黎明<BR>不管是梦中或是清醒<BR>深深爱你<BR>多么幸福<BR>让我遇见你<BR>呜...</FONT></P><img src ="http://www.cnitblog.com/linghuye/aggbug/7528.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2006-03-13 12:51 <a href="http://www.cnitblog.com/linghuye/archive/2006/03/13/7528.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Metoolkit物理引擎研究</title><link>http://www.cnitblog.com/linghuye/archive/2006/03/11/7501.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Sat, 11 Mar 2006 14:44:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2006/03/11/7501.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/7501.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2006/03/11/7501.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/7501.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/7501.html</trackback:ping><description><![CDATA[最近数月一直受困于实现wow中人物碰撞反应的问题,试过多种解决方案而一直不能解决,所以结论是在根本思路上有问题.<BR>一个完整的碰撞反应效果需要一个完整的物理引擎,一个完整的物理引擎如一个完整的图像渲染管线,不是我现在的能力所能到达的.<BR>前面的碰撞检测库实际上不能达到商业级应用标准,技术上还是太小儿科,所以只能依靠现有商业级的物理引擎.<BR>三大物理引擎Ipion,Metoolkit,Havok GDK, Havok收购了Ipion,所以相信Havok的引擎现在是最好的,XBOX都使用其SDK.<BR>Ipion在Halflife2泄漏代码中有,Metoolkit也google的到文档,看来要推倒原有设计重来,从Metoolkit开始.<BR><img src ="http://www.cnitblog.com/linghuye/aggbug/7501.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2006-03-11 22:44 <a href="http://www.cnitblog.com/linghuye/archive/2006/03/11/7501.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>无缝世界场景加载的解决方案研究</title><link>http://www.cnitblog.com/linghuye/archive/2005/12/31/5937.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Sat, 31 Dec 2005 03:44:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/12/31/5937.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/5937.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/12/31/5937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/5937.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/5937.html</trackback:ping><description><![CDATA[1.每帧评估周围MapArea的可见度,对即将可见的区域送入预加载线程逻辑,对必须可见的区域送入即时加载模块.<BR>2.必须加载2*2,进入3/4距离处开始预加载,退出1距离处卸载,保证最大加载量为3*3.<BR><BR>a.DX是有多线程支持,OpenGL渲染RC与线程相关,跨线程加载使用图形资源,如何解决?<BR>b.遇到更复杂的逻辑时,如何处理.<BR>c.是否要预加载全部,还是分Terrain,Model,Wmo加载.<BR>But it is just a design question.<BR><BR><img src ="http://www.cnitblog.com/linghuye/aggbug/5937.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-12-31 11:44 <a href="http://www.cnitblog.com/linghuye/archive/2005/12/31/5937.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3D人物模型在TriangleMesh环境中行走跳跃的碰撞行为反应</title><link>http://www.cnitblog.com/linghuye/archive/2005/12/28/5851.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Wed, 28 Dec 2005 09:08:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/12/28/5851.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/5851.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/12/28/5851.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/5851.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/5851.html</trackback:ping><description><![CDATA[How general games solve this question?So difficult.<BR><BR>ODE作的是刚体动力学,似乎不适合作解决方案.<BR><BR>1.The easiest way to handle a collision is to simply stop and not allow the move when a collision is detected. On the other hand - that is not how the professionals do is it? No, we want fancy collision response like sliding along the walls, automatically climbing stairs and automatically bumping over smaller obstacles on the ground.<BR><BR>2.The penetration depth of a pair of intersecting objects is the shortest vector over which one object needs to be translated in order to bring the pair in touching contact.<BR><BR>3.Responses are managed in response tables. To each object on which a response is defined in a response table a response class is assigned. Responses are defined per pair of response classes, rather than per pair of objects. So, the response for a pair of objects is the response defined for their respective response classes.<BR><BR><FONT color=#9acd32>1.Move our sphere as close as possible to the triangle we’re colliding with.<BR>Lets call this position for “newPosition”.<BR><BR>2.&nbsp;Calculate the sliding plane based on this new position.<BR><BR>3.&nbsp;Project the original velocity vector to the sliding plane to get a new<BR>destination.<BR><BR>4.Make a new velocity vector by subtracting the polygon intersection<BR>point from the new destination point.<BR><BR>5.Recursively call the entire collision detection routine with the new position<BR>and the new velocity vector.</FONT><BR><BR>Reference:<BR><A href="http://www.peroxide.dk/download/tutorials/tut10/pxdtut10.html"><FONT color=#ffff00>http://www.peroxide.dk/download/tutorials/tut10/pxdtut10.html</FONT></A><BR><A href="http://www.win.tue.nl/~gino/solid/gdc2001depth.pdf"><FONT color=#ffff00>http://www.win.tue.nl/~gino/solid/gdc2001depth.pdf</FONT></A><BR><A href="http://www.gamasutra.com/features/20000330/bobic_01.htm"><FONT color=#ffff00>http://www.gamasutra.com/features/20000330/bobic_01.htm</FONT></A><BR><A href="http://people.netfarm.it/~guyver1/Didattica/RTM/Lezioni/Lezione6/CollisionDetection_file/frame.html#slide0067.html"><FONT color=#ffff00>http://people.netfarm.it/~guyver1/Didattica/RTM/Lezioni/Lezione6/CollisionDetection_file/frame.html#slide0067.html</FONT></A><img src ="http://www.cnitblog.com/linghuye/aggbug/5851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-12-28 17:08 <a href="http://www.cnitblog.com/linghuye/archive/2005/12/28/5851.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PolygonSoup碰撞检测学习笔记</title><link>http://www.cnitblog.com/linghuye/archive/2005/12/26/5811.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Mon, 26 Dec 2005 14:59:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/12/26/5811.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/5811.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/12/26/5811.html#Feedback</comments><slash:comments>22</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/5811.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/5811.html</trackback:ping><description><![CDATA[<P>解决PolygonSoup碰撞检测的成熟方案是使用层次BV树,根据BV的不同衍生出:AABB,OBB,K-dop三种方案.<BR>在内存使用上: AABB -&gt; OBB -&gt; K-dop递增.在效率上则尚无定论,根据具体的应用环境不同而不同.</P>
<P>Opcode: 开源,完全免费,采用AABB树构造,内存耗用很小,支持复杂模型,起初想使用它,但发现其,基本上没有文档,Sample,1.3版本接口变动巨大,且无文档,自2003年来再无更新,最致命的是不支持Instance transform的Scale,AABBCollider没有Transform支持,而且是在看代码时发现的,吐血.主要设计目标是少的内存耗用,但速度也很快.为ODE,Tokamak,Crystal Space所用.</P>
<P>RAPID: 开源,免费,采用OBB构造,内存耗用巨大,学院派设计,最倒霉的库,因为其他每个库都拿它作比较,都说比它快.</P>
<P>SOLID: GPL开源,商业软件,采用AABB树构造,2005.4月出3.5版本,效率不错,内存耗用中等,在后面4.0会支持AABB数据压缩,有文档,接口简单,代码清晰.支持复杂模型,支持Instance transform的Scale,甚至支持各向不等缩放,支持Penetration Depth计算,cool.作者Gino van den Bergen是3D碰撞研究专家,著有:Collision Detection in Interactive 3D Environments一书,有e版.逻辑顺畅地集成入DM,效果不错,满足使用要求.不过其IndexBuffer是unsigned int,Matrix是DX风格的,但代码很清晰,很容易定制.<BR>SOLID有个严重的Bug,必须确保DT_GetCommonPoint,DT_GetPenDepth,DT_GetClosestPair在检测Complex和Convex对象时,第一个参数必须是Complex对象,否则崩溃.因为SOLID的double dispatch实现有问题,不完整,没有Convex + Complex顺序的对应函数.<BR><BR>QuickCD: 开源,免费,K-dop树构造.</P>
<P>ColDet,支持复杂模型,也不支持Instance Transform的Scale.<BR><BR>Reference:<BR><A href="http://www.codercorner.com/Opcode.htm"><FONT color=#ffff00>http://www.codercorner.com/Opcode.htm</FONT></A><BR><A href="http://www.dtecta.com/"><FONT color=#ffff00>http://www.dtecta.com/</FONT></A><BR><A href="http://www.cs.unc.edu/~geom/OBB/OBBT.html"><FONT color=#ffff00>http://www.cs.unc.edu/~geom/OBB/OBBT.html</FONT></A><BR><A href="http://www.ams.sunysb.edu/~jklosow/quickcd/QuickCD.html"><FONT color=#ffff00>http://www.ams.sunysb.edu/~jklosow/quickcd/QuickCD.html</FONT></A><BR><A href="http://photoneffect.com/coldet/"><FONT color=#ffff00>http://photoneffect.com/coldet/</FONT></A><BR><A href="http://www.merl.com/projects/vclip/"><FONT color=#ffff00>http://www.merl.com/projects/vclip/</FONT></A><BR><A href="http://www.q12.org/ode/ode.html"><FONT color=#ffff00>http://www.q12.org/ode/ode.html</FONT></A><BR><BR></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: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;DmModel::SetBoundPolygonSoup(uint32&nbsp;nPolygonSoupVertices,&nbsp;vec3_type</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">&nbsp;pVertices,&nbsp;uint32&nbsp;nTrianglePrims,&nbsp;uint16</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">&nbsp;pTrianglePrims)<BR><IMG id=Codehighlighter1_132_781_Open_Image onclick="this.style.display='none'; Codehighlighter1_132_781_Open_Text.style.display='none'; Codehighlighter1_132_781_Closed_Image.style.display='inline'; Codehighlighter1_132_781_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_132_781_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_132_781_Closed_Text.style.display='none'; Codehighlighter1_132_781_Open_Image.style.display='inline'; Codehighlighter1_132_781_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_132_781_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_132_781_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;ASSERT(m_hSolidShape&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;NULL);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(nTrianglePrims&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(nPolygonSoupVertices&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Save&nbsp;polygon&nbsp;soup&nbsp;data&nbsp;for&nbsp;collision&nbsp;test!</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;m_pPolygonSoupVertices&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;vec3_type[nPolygonSoupVertices];<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;memcpy(m_pPolygonSoupVertices,&nbsp;pVertices,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">sizeof</SPAN><SPAN style="COLOR: #000000">(vec3_type)&nbsp;</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">&nbsp;nPolygonSoupVertices);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Build&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;DT_VertexBaseHandle&nbsp;hVertexBase&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;DT_NewVertexBase(m_pPolygonSoupVertices,&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_hSolidShape&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;DT_NewComplexShape(hVertexBase);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_hSolidVertexBase&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;hVertexBase;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Define&nbsp;mesh&nbsp;triangles</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">(uint32&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">&nbsp;nTrianglePrims;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">)<BR><IMG id=Codehighlighter1_696_743_Open_Image onclick="this.style.display='none'; Codehighlighter1_696_743_Open_Text.style.display='none'; Codehighlighter1_696_743_Closed_Image.style.display='inline'; Codehighlighter1_696_743_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_696_743_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_696_743_Closed_Text.style.display='none'; Codehighlighter1_696_743_Open_Image.style.display='inline'; Codehighlighter1_696_743_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_696_743_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_696_743_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DT_VertexIndices(</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">,&nbsp;pTrianglePrims&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;i);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;End&nbsp;it</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;DT_EndComplexShape();<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></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></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;DmModelInstanceNode::BuildPhysics()<BR><IMG id=Codehighlighter1_825_1090_Open_Image onclick="this.style.display='none'; Codehighlighter1_825_1090_Open_Text.style.display='none'; Codehighlighter1_825_1090_Closed_Image.style.display='inline'; Codehighlighter1_825_1090_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_825_1090_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_825_1090_Closed_Text.style.display='none'; Codehighlighter1_825_1090_Open_Image.style.display='inline'; Codehighlighter1_825_1090_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_825_1090_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_825_1090_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Setup&nbsp;Phisic&nbsp;stuffs</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;DT_ShapeHandle&nbsp;hShape&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(DT_ShapeHandle)m_pRefModelInstance</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #000000">m_pRefModel</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #000000">m_hSolidShape;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(hShape)<BR><IMG id=Codehighlighter1_955_1088_Open_Image onclick="this.style.display='none'; Codehighlighter1_955_1088_Open_Text.style.display='none'; Codehighlighter1_955_1088_Closed_Image.style.display='inline'; Codehighlighter1_955_1088_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_955_1088_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_955_1088_Closed_Text.style.display='none'; Codehighlighter1_955_1088_Open_Image.style.display='inline'; Codehighlighter1_955_1088_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_955_1088_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_955_1088_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DT_ObjectHandle&nbsp;hObject&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;DT_CreateObject(NULL,&nbsp;hShape);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DM_SetMatrixf(hObject,&nbsp;m_matTransform);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_hSolidObject&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;hObject;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></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></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;DmGameCreature::BuildPhysics()<BR><IMG id=Codehighlighter1_1129_1415_Open_Image onclick="this.style.display='none'; Codehighlighter1_1129_1415_Open_Text.style.display='none'; Codehighlighter1_1129_1415_Closed_Image.style.display='inline'; Codehighlighter1_1129_1415_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_1129_1415_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1129_1415_Closed_Text.style.display='none'; Codehighlighter1_1129_1415_Open_Image.style.display='inline'; Codehighlighter1_1129_1415_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_1129_1415_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_1129_1415_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;ASSERT(m_hSolidObject&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;NULL);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;vec3_type&nbsp;vMin,&nbsp;vMax;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;getBoundBox(vMin,&nbsp;vMax);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;DT_ShapeHandle&nbsp;hShape&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;DT_NewBox(vMax.x&nbsp;</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">&nbsp;vMin.x,&nbsp;vMax.y&nbsp;</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">&nbsp;vMin.y,&nbsp;vMax.z&nbsp;</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">&nbsp;vMin.z);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;DT_ObjectHandle&nbsp;hObject&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;DT_CreateObject(NULL,&nbsp;hShape);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_hSolidShape&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;hShape;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_hSolidObject&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;hObject;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></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></SPAN><SPAN style="COLOR: #0000ff">bool</SPAN><SPAN style="COLOR: #000000">&nbsp;DmModelInstanceNode::TestCollision(HANDLE&nbsp;hSolidObject)<BR><IMG id=Codehighlighter1_1479_1726_Open_Image onclick="this.style.display='none'; Codehighlighter1_1479_1726_Open_Text.style.display='none'; Codehighlighter1_1479_1726_Closed_Image.style.display='inline'; Codehighlighter1_1479_1726_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_1479_1726_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1479_1726_Closed_Text.style.display='none'; Codehighlighter1_1479_1726_Open_Image.style.display='inline'; Codehighlighter1_1479_1726_Open_Text.style.display='inline';" src="http://www.cnitblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_1479_1726_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_1479_1726_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">m_hSolidObject)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;DT_ObjectHandle&nbsp;hTestObject&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(DT_ObjectHandle)hSolidObject;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;DT_ObjectHandle&nbsp;hThisObject&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(DT_ObjectHandle)m_hSolidObject;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;DT_Vector3&nbsp;v;<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;(DT_GetCommonPoint(hThisObject,&nbsp;hTestObject,&nbsp;v)&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnitblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><img src ="http://www.cnitblog.com/linghuye/aggbug/5811.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-12-26 22:59 <a href="http://www.cnitblog.com/linghuye/archive/2005/12/26/5811.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Horizon Occlusion Culling</title><link>http://www.cnitblog.com/linghuye/archive/2005/11/29/4976.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Mon, 28 Nov 2005 16:31:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/11/29/4976.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/4976.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/11/29/4976.html#Feedback</comments><slash:comments>21</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/4976.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/4976.html</trackback:ping><description><![CDATA[NND,图形学怎么有这么多的算法!一个接着一个,没完没了.一堆的论文要看,越学越难,越学越无知.看着国外的好书只能流口水,怎么赶得上人家的水平啊,做人的差距,咋就这么大呐,灰心寽.<BR><BR>1. How to walk through the elements in the scene in front-to-back ordering?<BR>2. How to representation for the visibility occlusion horizon?<BR>3. How give out a simplified representation of scene objects to be used for calculating occlusions with the horizon, ie, to test if the element is under the horizon?<BR>4. How to add the visible elements' affection into horizon line?<BR><FONT color=#ffff00><BR>Reference:<BR></FONT><A href="http://rivit.cs.byu.edu//a3dg/publications/horizonCullingVISFinal.pdf"><FONT color=#ffff00>http://rivit.cs.byu.edu//a3dg/publications/horizonCullingVISFinal.pdf</FONT></A><BR><A href="http://www.cs.tau.ac.il/~dcor/online_papers/papers/visibility-survey-ieee.pdf"><FONT color=#ffff00>http://www.cs.tau.ac.il/~dcor/online_papers/papers/visibility-survey-ieee.pdf</FONT></A><BR><FONT color=#ffff00>游戏编程精粹4,P424,翻译的极烂(把实数译成真正的值),原作者的代码也烂,书中说的这个容易,那个容易,一到具体代码就不行了,到处hack,连视点从前到后遍历都不能保证.<BR><A href="http://www.cs.lth.se/home/Tomas_Akenine_Moller/pubs/i3d2001.pdf"><FONT color=#ffff00>http://www.cs.lth.se/home/Tomas_Akenine_Moller/pubs/i3d2001.pdf</FONT></A><BR><A href="http://graphics.stanford.edu/courses/cs248-05/real-time-programming/moller-cs248-01-lecture.pdf"><FONT color=#ffff00>http://graphics.stanford.edu/courses/cs248-05/real-time-programming/moller-cs248-01-lecture.pdf</FONT></A><BR><A href="http://www.cs.sun.ac.za/~henri/advgfx.html"><FONT color=#ffff00>http://www.cs.sun.ac.za/~henri/advgfx.html</FONT></A><BR><BR><FONT color=#008000>12.23</FONT><BR></FONT><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>终于把水平线裁减算法的Bug解决了,开贴纪念.<BR>主要是原游戏编程精粹4的水平线算法代码有无数的Bug,Demo控制高空镜头有意地避开一些Bug,强烈鄙视.<BR><BR></FONT><IMG src="http://www.linghuye.nease.net/Pic/Show10.jpg"></IMG><img src ="http://www.cnitblog.com/linghuye/aggbug/4976.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-11-29 00:31 <a href="http://www.cnitblog.com/linghuye/archive/2005/11/29/4976.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>场景裁减方案估计</title><link>http://www.cnitblog.com/linghuye/archive/2005/11/25/4899.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Fri, 25 Nov 2005 09:06:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/11/25/4899.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/4899.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/11/25/4899.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/4899.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/4899.html</trackback:ping><description><![CDATA[0.使用天空球包围整个世界,使用雾限制可控远景.<BR>1.地形裁减: <BR>&nbsp; 1.使用四叉树算法对MapArea-&gt;AreaChunk逐层进行相对镜头的可见性裁减.<BR>&nbsp; 2.在1过程中,对镜头内的地形进行水平线扫描剔除.<BR>&nbsp; 2.然后镜头裁减完的区域必然是连续区域,对此连续区域作ROAM算法下的LOD处理,近细远粗.<BR>2.模型裁减: <BR>&nbsp; 1.基于上述地形四叉树裁减下作基本的每一个模型的裁减,实践测试结果表明收益大于测试成本.<BR>&nbsp; 2.距离裁减:以镜头为中心画圆,处于远景雾外的模型不作渲染,模型进雾后会逐步显示,这样不会有poping缺陷.<BR>&nbsp; 3.不采用模型LOD,数据制作过于复杂,控制复杂,加大内存需求,也有poping缺陷,优点不明显.<BR>&nbsp;&nbsp;4.在地形水平线裁减中剔除物体.<BR>3.进入BSP室内场景后的裁减.<BR><BR><IMG src="http://linghuye.nease.net/Pic/Show8.jpg" border=0><img src ="http://www.cnitblog.com/linghuye/aggbug/4899.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-11-25 17:06 <a href="http://www.cnitblog.com/linghuye/archive/2005/11/25/4899.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DestinyMatrix开发手扎.2700</title><link>http://www.cnitblog.com/linghuye/archive/2005/09/29/2974.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Thu, 29 Sep 2005 03:12:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/09/29/2974.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/2974.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/09/29/2974.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/2974.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/2974.html</trackback:ping><description><![CDATA[<P>场景图系统使得引擎实体从管理层中分离出来,实体不参加管理层的运作,也不带管理的数据.<BR>对一个物质实体而言,其不存在可见性这一属性数据,可见性是由管理层控制的,即物质实体是唯物主义,场景图是唯心主义.</P>
<P>场景图是个宽松的,随意的管理层,其任务是为各种各样的SceneNode保持最基本的层次关系,这个层次关系可以用来实现从上到下的空间变换,渲染状态的最小化切换. </P>
<P>从ISceneNode派生出各方面的SceneNode,表达对自己管理的场景的理解,即一个ISceneNode从概念上就是个小场景图,但其算法是单一的,如4叉,8叉,BSP等,从而实现一个大场景图中包含应用各种算法的小场景图.<BR>而最上层的场景图是一种由人力控制,排序,维护的场景图,它的节点是泛用容器节点类型,基本概念是可以在编辑器中显式地创建一个容器式的节点,并为节点加载内容场景.<BR>万事万物都可以纳入场景图,因为它的上层是宽松的逻辑概念.<BR><BR>10.4 完成基本场景图程序设计.<BR>11.4 笑傲江湖马戏团 :)<BR>11.08,终于一个雏形诞生了,真正基于场景图,渲染API层完全隔离,采用统一的Material+Mesh渲染抽象,渲染状态切换最小化,骨骼动画框架,仿WoW游戏镜头控制.<BR>12.12&nbsp;&nbsp;地形算法整合清理,整合原先写成的UI,脚本模块,整合wmo加载和渲染模块,完善重新思考引擎的Mesh概念,加入基本的Shader以支持复杂光照模型.基本地平线剔除代码.多次代码重构.<BR><BR><BR><IMG src="http://linghuye.nease.net/Pic/Show2.jpg" Bordor="0"></IMG> </P><img src ="http://www.cnitblog.com/linghuye/aggbug/2974.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-09-29 11:12 <a href="http://www.cnitblog.com/linghuye/archive/2005/09/29/2974.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DestinyMatrix 开发手扎</title><link>http://www.cnitblog.com/linghuye/archive/2005/08/13/1860.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Sat, 13 Aug 2005 09:39:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/08/13/1860.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/1860.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/08/13/1860.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/1860.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/1860.html</trackback:ping><description><![CDATA[<P>2005.3.22<BR>1.开始制定开发计划<BR>2.总结先前累计的若干基本功能模块.</P>
<P>2005.4.8<BR>1.基本场景建立,4叉树+ROAM地形,多重纹理AlphaMap,物体模型分布,水面,天空.<BR></P><IMG src="http://blog.blogchina.com/upload/2005-04-12/20050412101651549313.JPG" border=0> <BR>
<P>2005.4.11<BR>1.今天随便看了一下HL2分析的文章,觉得HL2的MaterialSystem非常好,非常对我的脾胃,决定采用.<BR></P>
<P>2005.4.14<BR>1.加入最简单的室内场景.<BR>2.开始研究HL2的MateiaSystem,并移植入DestinyMatrix,当前的主要任务是建立MaterialSystem.<BR></P><IMG src="http://blog.blogchina.com/upload/2005-04-15/2005041521004812870.jpg" border=0> <BR>
<P>2005.5.3<BR>1.这两个星期忙于现实工作,所以一直在思考引擎实现框架的设计问题,各大模块之间的责任和协作到底如何,思绪渺渺.</P>
<P>较之,HL2于大局架构把握上层次更高,游戏引擎/渲染系统(MaterialSystem)/底层渲染API实现(ShaderAPI),通观全局,层次分明,接口手法也很符合规范.但,HL2的具体实现实在够乱,接口的具体语义逻辑实在牵强,不够平民化,调用环节过多,我想它没能完成OpenGL的实现,也跟它在逻辑语义抽象上的局限性有关.特别她把渲染状态管理放在API实现层,有DX的实现,那Opengl怎么实现DXX的概念,可能是未完成的版本.相较其他引擎,明显的看出它作为商业级的产物,架构,编译速度,代码更符合现实程序实践.</P>
<P>OpenSceneGraph的在接口逻辑设计上比HL2清晰,Geometry,Material,StateSet的语义逻辑更明确,更灵活,具有极强的伸缩性,但它没有大局架构,没有API和总体层次间的隔离机制,我估计效率也不太好,几个Demo都很慢,而且是为VR设计的,而不是游戏.</P>
<P>Torque的结构实在是不敢恭维,网络,脚本,图形,场景管理代码一起堆,客户端和服务端代码一起堆,编辑器和引擎代码一起堆,是个高大全的产物,实际结果确实是高大全,直接就用脚本写服务器和客户端了.她的总体设计目标和思路都与其他引擎不同,她想直接用以别人作游戏.不过她的场景图的算法思路很好,网络实现也很强,效率不错.</P>
<P>Ogre号称面向对象,而我却以为是肤浅的面向对象,基本上没有接口语义概念,除了一堆的Singleton Manager就看不到其他设计模式了,依靠强制的C++技法来实现,如C++单体类,C++跨DLL继承等手法,在概念抽象上比较强硬,如Material就来个Techniche数组,Techniche就来个Pass数组,简单的用一个类包装一个观念,实际上没能很好地抽象出其中的关键逻辑.为了达到它可扩展的目的,连场景图算法都丢进去了,有必要吗?<BR></P>
<P>2005.5.16<BR>推翻原来的设计,采用HL2引擎的3层结构,借鉴OpenSceneGraph的操作手法,统一了渲染逻辑,为渲染状态的管理打下了基础.<BR>接下来开始深入剖析渲染状态的表达,并增强渲染逻辑的广泛适用性.然后采用OpenSceneGraph的算法进行管理.</P>
<P>2005.5.17<BR>开始编写场景图DmSceneGraph,渲染状态封装DmStateSet,以及场景图与渲染状态之间的树型关系维护,进一步统一IRenderCraft的接口.</P>
<P>2005.5.19<BR>不切实际!如何将多种场景管理算法融合进一个SceneGraph呢?然后才是渲染状态排序实现.谁能告诉我是对还是错,只是命运的折磨不住地困扰着我,sigh.</P><img src ="http://www.cnitblog.com/linghuye/aggbug/1860.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-08-13 17:39 <a href="http://www.cnitblog.com/linghuye/archive/2005/08/13/1860.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DestinyMatrix</title><link>http://www.cnitblog.com/linghuye/archive/2005/08/13/1852.html</link><dc:creator>linghuye</dc:creator><author>linghuye</author><pubDate>Sat, 13 Aug 2005 09:27:00 GMT</pubDate><guid>http://www.cnitblog.com/linghuye/archive/2005/08/13/1852.html</guid><wfw:comment>http://www.cnitblog.com/linghuye/comments/1852.html</wfw:comment><comments>http://www.cnitblog.com/linghuye/archive/2005/08/13/1852.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/linghuye/comments/commentRss/1852.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/linghuye/services/trackbacks/1852.html</trackback:ping><description><![CDATA[<DIV align=left><PRE>我的3D游戏引擎 DestinyMatrix,简称DM.</PRE><PRE>1.对3D基础的建立相对稳固，有了足够的数据和学习参考资料。</PRE><PRE>2.目前最重要的是场景图的建立,然后是光照特效系统。</PRE></DIV><PRE>3.由于整个体系太过庞大复杂，而且毫无经验，从头写一定失败不可行，应该画瓢照搬Ogre的体系和代码编写.</PRE><PRE>4.具体实现:Resource文件格式实现,UI界面系统，Script脚本系统，RenderSystem系统使用现有自己写好的一套。</PRE><PRE>5.骨骼动画,地形,纹理,BSP场景使用Blizz的数据格式。</PRE><PRE>6.特效，粒子系统先采用Ogre的实现。</PRE><img src ="http://www.cnitblog.com/linghuye/aggbug/1852.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/linghuye/" target="_blank">linghuye</a> 2005-08-13 17:27 <a href="http://www.cnitblog.com/linghuye/archive/2005/08/13/1852.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>