?? 構建高級粒子系統.htm
字號:
particle systems and removes all systems which died after the
update.</TD></TR>
<TR bgColor=#ffffff>
<TD class=ColorCode vAlign=top width="18%">Render</TD>
<TD class=EtoC colSpan=2 vAlign=top>Renders all active and
visible systems.</TD></TR>
<TR bgColor=#ffffff>
<TD class=ColorCode vAlign=top width="18%">Shutdown</TD>
<TD class=EtoC colSpan=2 vAlign=top>Shuts down the manager
(removes all allocated systems).</TD></TR>
<TR bgColor=#ffffff>
<TD class=ColorCode vAlign=top width="18%">DoesExist</TD>
<TD class=EtoC colSpan=2 vAlign=top>Checks whether a given
particle system still exists in the particle manager (if it
has not been removed yet).</TD></TR>
<TR bgColor=#ffffff>
<TD class=BGRed colSpan=3 vAlign=top>
<DIV align=center><B><FONT color=#cccccc>表3
粒子管理器類的成員函數</FONT></B></DIV></TD></TR></TBODY></TABLE><BR> AddSystem函數可能只有一個參數:指向粒子類的指針。這將允許你根據需要輕易地增加一個煙系統或火系統。下面是我如何在引擎中增加一個粒子系統的例子:<BR><BR> <SPAN
class=ColorCode>gParticleMgr->AddSystem( new
Smoke(nrSmokeParticles, position, ...)
);</SPAN><BR><BR> 在世界更新函數中我調用了gParticleMgr->Update()函數,這個函數自動更新所有的系統并釋放死亡的系統。Render函數然后渲染所有的可見粒子系統。因為我們不想在每一幀跟蹤系統中的所有粒子以判斷是否所有的粒子均已死亡(這樣系統可被刪除),我們將使用Update函數來代替。如果這個函數返回TRUE,這意味著系統處于存活狀態。反之系統已死亡并可以被刪除。粒子管理程序的Update函數如清單2所示。<BR><BR> <SPAN
class=ColorCatchword>// 清單2 - Update function of the particle
manager.</SPAN><BR> <SPAN class=ColorCode>for (int i=0;
i<particleSystems.Length())</SPAN> <SPAN class=ColorCatchword>//
traverse all particle systems<BR></SPAN> <SPAN
class=ColorCode>{<BR> if
(!particleSystems[i]->Update())</SPAN> <SPAN
class=ColorCatchword>// if the system died, remove
it<BR></SPAN> <SPAN class=ColorCode>{<BR> delete
particleSystems[i];</SPAN> <SPAN class=ColorCatchword>//
release it from memory<BR></SPAN> <SPAN
class=ColorCode>particleSystems.SwapRemove(i);</SPAN> <SPAN
class=ColorCatchword>// remove number i, and fill the
gap<BR> // with the last entry in the
array<BR></SPAN> <SPAN
class=ColorCode>}<BR> else<BR> i++;<BR> }</SPAN><BR><BR> 在我的粒子系統中,其中分配的所有具有相同底紋和混合方式的粒子將連續地渲染,同時將底紋轉換和上載減到最小。這樣,如果在屏幕上有十個可見的煙系統,就只有一個底紋轉換和狀態改變將被執行。<BR><A
name=5.0></A><BR><B>5、設計,然后再編碼</B><BR> 設計一個靈活的,快速的和可擴展的高級粒子系統并不很困難,如果你花時間來考慮你將如何在游戲中使用它,并且由此細致設計你的系統。由于在此討論的系統使用帶有繼承的類,你也可以在.DLL文件中加入獨立的粒子系統形式。這就使建立某種插件(<SPAN
class=English>Plug-In</SPAN>)系統成為可能,而這可能是某些開發者所感興趣的。<BR> 你也可以下載我的粒子系統(我為Oxygen3D開發的最新的引擎)的源程序。這些源碼不是獨立的可編輯系統,但如果你遇到問題,它應該能幫助你。如果你還有任何問題或意見,請直接給我發電子郵件。<BR><BR> <IMG
height=16 src="download.gif" width=16> <A
class=BlackLink
href="http://mays.soage.com/develop/effect/200111/image/AParSystem/AdvancedParticles.zip">附帶的源程序</A>(12K)、<A
class=BlackLink
href="http://www.mysticgd.com/misc/AdvancedParticleSystems.pdf">英文版的原稿</A>(PDF
1.0MB)<BR><BR>
<HR align=center noShade SIZE=1 width="95%">
<BR> <B>原作者及其它</B><BR> <SPAN class=English>John van der Burg is
the lead programmer for Mystic Game Development, located in the
Netherlands. Currently he is working on Oxygen3D, which is his third
hardware-only engine and his eighth engine overall. Currently he is
doing freelance work on LOOSE CANNON for Digital Anvil and for OMG
Games on THE CREST OF DHARIM. He previously freelanced for Lionhead
Studios on BLACK AND WHITE, and for Orange Games on CORE. You can
find screenshots of his previous work at <A class=cLink
href="http://www.mysticgd.com/"
target=_blank>http://www.mysticgd.com/</A>.Feel free to drop him a
line at<A class=cLink
href="mailto:john@mysticgd.com.">mailto:john@mysticgd.com.</A>.</SPAN><BR><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0
class=BGRed>
<TBODY>
<TR>
<TD align=middle><IMG height=250
src="APSother-4.jpg" width=250></TD>
<TD><FONT color=#cccccc face="Times New Roman, Times, serif">A
blood system. Blood colors were set based on the colors in the
light maps. Blood on dark areas looks dark as well. The red
areas in the bottom screenshot are the blood splats on the
camera lens, dripping down the lens.
</FONT></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0
class=BGRed>
<TBODY>
<TR>
<TD align=middle><IMG height=250
src="APSother-5.jpg" width=250></TD>
<TD><FONT color=#cccccc
face="Times New Roman, Times, serif">This was constructed from
sparks and a big real-time calculated flare explosion (not
just a texture). </FONT></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0
class=BGRed>
<TBODY>
<TR>
<TD align=middle><IMG height=250
src="APSother-6.jpg" width=250></TD>
<TD><FONT color=#cccccc
face="Times New Roman, Times, serif">This image is the same as
the above one, but with some extra animated explo- sions
(animated textures) and shockwaves, which are admittedly very
small and may be difficult to see in this
image.</FONT></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0
class=BGRed>
<TBODY>
<TR>
<TD align=middle><IMG height=250
src="APSother-7.jpg" width=250></TD>
<TD><FONT color=#cccccc
face="Times New Roman, Times, serif">This electricity has its
own render function. A hierarchy tree was constructed to
represent the electricity flow using branches and
sub-branches. It is a thunder- storm lightning effect with the
branches animated. Particle shapes are being con- structed for
every part in the electricity
tree.</FONT></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0
class=BGRed>
<TBODY>
<TR>
<TD align=middle><IMG height=250
src="APSother-8.jpg" width=250></TD>
<TD><FONT color=#cccccc face="Times New Roman, Times, serif">A
rain effect, using stretched shapes for the particles. The
rain also splats on the ground by calling the sparks system
with adjusted settings and texture.</FONT></TD></TR></TBODY></TABLE><!-- #EndEditable --></TD></TR>
<TR>
<TD class=BGGray width="100%">
<DIV align=right><!-- #BeginEditable "%B2%D9%D7%F7%CC%A8" --><A
class=BlackLink
href="http://mays.soage.com/develop/effect/200111/AParSystem.htm#7758258"><B>返回</B></A><!-- #EndEditable -->
</DIV></TD></TR>
<TR>
<TD class=BGGray width="100%">
</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD width=0%></TD>
<TD class=BGGray colSpan=2 height=3 vAlign=top></TD>
<TD colSpan=2></TD>
<TD colSpan=3 vAlign=top width="84%"></TD></TR></TBODY></TABLE><BR></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -