摘要: 在創(chuàng)建頂點(diǎn)緩沖區(qū)之前,需要先定義一個(gè)表示頂點(diǎn)的結(jié)構(gòu)類型,描述頂點(diǎn)保存格式的FVF和一個(gè)保存頂點(diǎn)的結(jié)構(gòu)數(shù)組。
閱讀全文
摘要: 圖元(primitives)是Direct3D中定義的基本圖形表示,它是組成一個(gè)單一實(shí)體的一組頂點(diǎn)。最簡單的圖元是三維坐標(biāo)系中多個(gè)點(diǎn)的集合,稱為點(diǎn)列表(point list)。通常,圖元是多邊形(polygon),一個(gè)多邊形是由至少三條邊組成的封閉圖形。最簡單的多邊形是三角形,Direct3D使用三角形來構(gòu)成大多數(shù)其他多邊形,這是因?yàn)槿切蔚娜齻€(gè)頂點(diǎn)肯定是共面的,而渲染不共面的頂點(diǎn)效率比較低。通過組合三角形可以形成更大、更復(fù)雜的多邊形和網(wǎng)格(mesh)。
閱讀全文
D3DFVF_XYZ和D3DFVF_XYZRHW有什么區(qū)別?以前好像沒有仔細(xì)思考過,只是見到Beginning DirectX9中如是說:The RHW
value, which stands for Reciprocal of Homogeneous W[
1],
tells Direct3D that the vertices that are being used are already in screen
coordinates. This value is normally used in fog and clipping calculations and
should be set to 1.0.
今天,做了個(gè)實(shí)驗(yàn)得知,在頂點(diǎn)結(jié)構(gòu)體中沒有RHW時(shí),Direct3D將執(zhí)行視、投影、世界等變換以及進(jìn)行光線計(jì)算,之后你才能在窗口中得到你所繪制的物體。當(dāng)頂點(diǎn)結(jié)構(gòu)體中有RHW時(shí),就像上面那段英文所述,告知Direct3D使用的頂點(diǎn)已經(jīng)在屏幕坐標(biāo)系中了,不再執(zhí)行視圖、投影、世界等變換和光線計(jì)算,因?yàn)镈3DFVF_XYZRHW標(biāo)志告訴它頂點(diǎn)已經(jīng)經(jīng)過了這些處理,并直接將頂點(diǎn)進(jìn)行光柵操作,任何用SetTransform進(jìn)行的轉(zhuǎn)換都對其無效。不過這時(shí)的原點(diǎn)就在客戶區(qū)的左上角了,其中x向右為正,y向下為正,而z的意義已經(jīng)變?yōu)閦-buffer的象素深度。
值得注意的是,D3DFVF_XYZRHW和D3DFVF_XYZ、D3DFVF_NORMAL不能共存,因?yàn)楹髢蓚€(gè)標(biāo)志與前一個(gè)矛盾。在使用這種頂點(diǎn)時(shí),系統(tǒng)需要頂點(diǎn)的位置已經(jīng)經(jīng)過變換了,也就是說x、y必須在屏幕坐標(biāo)系中,z必須是z-buffer中的象素深度,取值范圍:0.0-1.0,離觀察者最近的地方為0.0,觀察范圍內(nèi)最遠(yuǎn)可見的地方為1.0。(不過我測試的時(shí)候似乎z值不起作用。)
If you use D3DFVF_XYZ, then your vertex format needs to have 3 floats
in it, for x, y and z. Those are used to define a vertex position in 3D
space.If you use D3DFVF_XYZRHW, then your vertex format needs to have 4
floats in it, for x, y, z and rhw. X and Y are used to define a vertex
position in 2D space, Z is ignored (I think, it may be used for fog and
such, but I don't recall just now - I always set it to 0.0f), and rhw
is the Reciprocal of Homogenous W - which is basically 1 / the depth of
the vertex.
Usually, you use D3DFVF_XYZRHW for doing 2D, and D3DFVF_XYZ any other
time. However, a lot of people just use D3DFVF_XYZ, and use an
orthoganal projection matrix to make it seem 2D.
_______________________
[1] RHW表示投影空間中頂點(diǎn)所在的齊次點(diǎn)(x,y,z,w)(homogeneous point)的w坐標(biāo)的倒數(shù)(reciprocal)。
摘要: Microsoft Direct3D的一種實(shí)現(xiàn)方式是通過組件對象模型(Component Object Model, COM)及其接口實(shí)現(xiàn)的,在用C++語言和COM接口方式開發(fā)的程序中可以直接訪問這些接口和對象。Direct3D對象是Direct3D程序中需要?jiǎng)?chuàng)建的第一個(gè)對象,也是需要最后一個(gè)釋放的對象,這里所說的對象是指COM對象。通過Direct3D對象,可以枚舉和檢索Direct3D設(shè)備,這樣應(yīng)用程序就可以在不需要?jiǎng)?chuàng)建設(shè)備對象的前提下選擇Direct3D渲染設(shè)備。
閱讀全文
摘要: 使用Direct3D繪制三維圖形和使用GDI繪制二維圖形的方法非常類似,Direct3D程序中的Direct3D設(shè)備對象相當(dāng)于GDI程序中的 hdc(設(shè)備描述表),使用 GDI繪制圖形前,通常需要先利用hdc進(jìn)行相關(guān)設(shè)置,然后通過hdc進(jìn)行繪圖。同樣在Direct3D程序中通常先通過 Direct3D設(shè)備接口進(jìn)行相關(guān)的渲染設(shè)備設(shè)置,然后再渲染圖形。而且所有的渲染圖形操作必須在函數(shù)BeginScene()和EndScene()之間進(jìn)行。
閱讀全文
摘要: Direct3D是基于Microsoft Windows的圖形開發(fā)接口,它的使用必須建立在Windows窗口的基礎(chǔ)上,這就需要?jiǎng)?chuàng)建一個(gè)窗口,而創(chuàng)建窗口首先需要注冊一個(gè)窗口類。示例程序中注冊窗口類并根據(jù)窗口類創(chuàng)建窗口的代碼如下:
閱讀全文
摘要: Microsoft Direct3D的一種實(shí)現(xiàn)方式是通過組件對象模型(Component Object Model, COM)及其接口實(shí)現(xiàn)的,在用C++語言和COM接口方式開發(fā)的程序中可以直接訪問這些接口和對象。Direct3D對象是Direct3D程序中需要?jiǎng)?chuàng)建的第一個(gè)對象,也是需要最后一個(gè)釋放的對象,這里所說的對象是指COM對象。通過Direct3D對象,可以枚舉和檢索Direct3D設(shè)備,這樣應(yīng)用程序就可以在不需要?jiǎng)?chuàng)建設(shè)備對象的前提下選擇Direct3D渲染設(shè)備。
閱讀全文
摘要: Directly manipulating a mesh's vertex buffers is probably the easiest way to work with morphing. For this method you'll need a third mesh that contains the final coordinates of each vertex after morphing; it's this third mesh that you'll render.
To create the third mesh, which I call the resulting morphed mesh, you can clone the source mesh and be on your way.
閱讀全文
摘要: Back in the early 90s, a revolutionary computer?graphics animation technique known as morphing hit the big league and was brought into the mainstream, thanks to a man known as Michael Jackson. No, I'm not referring to one of his plastic surgery fiascos?rather, the use of morphing in one of his music videos. Yep, the King of Pop used morphing techniques in his video for the song "Black or White" and created an animation phenomenon that continues to this day.
閱讀全文
摘要: 一點(diǎn)P上的外力F亦在此平面內(nèi)。定義力F對z軸的力圖1是剛體的一個(gè)橫截平面,z軸為剛體的轉(zhuǎn)軸,它與橫截面的交點(diǎn)為O。作用在剛體內(nèi)矩為
M= Fd = F r sinθ
閱讀全文