




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、譯文:OpenGL 簡(jiǎn)介OpenGL是一個(gè)底層圖形庫(kù)規(guī)范。它為程序員提供了一個(gè)小的幾何圖元(點(diǎn)、線、多邊形、圖片和位圖)庫(kù)和一個(gè)支持2D/3D幾何對(duì)象繪圖命令庫(kù),通過(guò)所提供的圖元和命令來(lái)控制對(duì)象的呈現(xiàn)(繪圖)。由于OpenGL的繪圖命令僅限于畫(huà)一些簡(jiǎn)單的幾何圖元(如點(diǎn)、線和多邊形),所以O(shè)penGL實(shí)用工具包(GLUT)應(yīng)運(yùn)而生,它能夠幫助繪畫(huà)出更復(fù)雜的三維對(duì)象(比如球體、圓環(huán)甚至茶壺)。如果你要構(gòu)建需要利用到OpenGL全部特性的應(yīng)用的話,GLUT未必適合,但是對(duì)剛學(xué)習(xí)OpenGL的人來(lái)說(shuō)GLUT就非常有用。GLUT是為滿足windows系統(tǒng)下OpenGL程序獨(dú)立編程接口的需求而設(shè)計(jì)的,接口
2、被設(shè)計(jì)的非常簡(jiǎn)單而又實(shí)用。從OpenGL中移除windows系統(tǒng)的操作是一個(gè)非常英明的決定,因?yàn)檫@意味著OpenGL圖形系統(tǒng)能夠被應(yīng)用于更廣泛的系統(tǒng)中(包括功能強(qiáng)大但昂貴的圖形工作站以及需要大量圖形運(yùn)算的視頻游戲、互動(dòng)電視機(jī)機(jī)頂盒和個(gè)人電腦)。GLUT簡(jiǎn)化了用OpenGL進(jìn)行渲染的程序的實(shí)現(xiàn)。GLUT應(yīng)用編程接口(API)只需要調(diào)用很少的接口就可以用OpenGL來(lái)渲染圖形場(chǎng)景,并且GLUT接口所需的參數(shù)也相對(duì)較少。渲染管線大多數(shù)OpenGL實(shí)現(xiàn)都有著類似的操作順序,這一系列的操作過(guò)程叫做OpenGL渲染管線。盡管OpenGL并不嚴(yán)格要求需要按照渲染管線這一順序來(lái)實(shí)現(xiàn),但是這樣做可以為預(yù)測(cè)Ope
3、nGL下一步將要做什么提供可靠的指引。幾何數(shù)據(jù)(點(diǎn)、線、多邊形)將會(huì)沿著一條依次通過(guò)求值器、頂點(diǎn)操作和裝配階段的路徑進(jìn)行傳遞,而像素?cái)?shù)據(jù)(像素,圖形,位圖)將會(huì)沿著另一條路徑傳遞,在最終像素寫(xiě)入幀緩沖區(qū)前,像素?cái)?shù)據(jù)和幾何數(shù)據(jù)都會(huì)經(jīng)歷相同的最后一步柵格化處理。Display Lists:所有數(shù)據(jù),無(wú)論是用來(lái)描述幾何體還是像素的,都可以保存在一個(gè)display list中來(lái)在當(dāng)下或?qū)?lái)使用(用以替代display list的用法是在需要時(shí)立即處理數(shù)據(jù)稱為立即模式)當(dāng)一個(gè)display list被觸發(fā)時(shí),保存的數(shù)據(jù)就像立即模式一樣被發(fā)送至顯示器。Evaluators:所有幾何原語(yǔ)最終都是由頂點(diǎn)描述的
4、,但evaluator提供了一種用控制點(diǎn)表示面的方法。這種方法是擬合多項(xiàng)式,可以通過(guò)控制點(diǎn)提供面法線、顏色、和空間紋理坐標(biāo)。基于頂點(diǎn)和圖元的裝配:對(duì)于頂點(diǎn)的數(shù)據(jù),下一步就是將它們轉(zhuǎn)換成圖元。某些類型的頂點(diǎn)數(shù)據(jù)被轉(zhuǎn)換為4x4的浮點(diǎn)型矩陣??臻g坐標(biāo)從三維世界中的一個(gè)位置被投影到您顯示屏上的一個(gè)位置。在某些情形中,這一步之后會(huì)進(jìn)行透視除法,利用它能夠使遠(yuǎn)處的幾何物體看起來(lái)比近處的物體小。然后,我們?cè)賹?duì)數(shù)據(jù)進(jìn)行視口和景深的操作。至此,我們得到的結(jié)果是幾何圖元,這些圖元與相關(guān)的顏色值和景深值,以及光柵化步驟的指標(biāo)等一同進(jìn)行轉(zhuǎn)換。像素操作:在幾何數(shù)據(jù)通過(guò)OpenGL渲染管線的一條路徑的同時(shí),像素?cái)?shù)據(jù)則通過(guò)
5、了另外一條路徑。系統(tǒng)內(nèi)存中的一個(gè)數(shù)組中的像素首先被解壓,從若干格式中的一種轉(zhuǎn)換成擁有恰當(dāng)數(shù)目的分量的那種。然后,我們對(duì)數(shù)據(jù)進(jìn)行尺度放縮,偏移,再根據(jù)像素映射處理,隨后這些結(jié)果被發(fā)送至光柵化步驟。光柵化:光柵化是指將幾何數(shù)據(jù)和像素?cái)?shù)據(jù)都轉(zhuǎn)換成片段的過(guò)程。各方形片段對(duì)應(yīng)幀緩存中的一個(gè)像素。當(dāng)頂點(diǎn)被連接起來(lái)形成直線,或者計(jì)算填充的多邊形的內(nèi)部像素時(shí),直線的寬度,點(diǎn)的大小,著色模型,以及用以支持抗鋸齒的覆蓋計(jì)算等都被考慮在內(nèi)。顏色值和深度值被賦予各方形片段。然后,處理后的片段被存入合適的緩存中,在那里,它最終被轉(zhuǎn)化成一個(gè)像素,從而完成了它的最終使命。庫(kù)文件OpenGL提供了一組強(qiáng)大但原始的渲染命令,而
6、且所有的高層繪制都必須通過(guò)這些命令來(lái)完成。有若干庫(kù)文件能夠簡(jiǎn)化您的編程任務(wù),包括: OpenGL Utility Library (GLU),它包含若干調(diào)用底層OpenGL命令的函數(shù),這些函數(shù)能夠進(jìn)行諸如為某一特定觀察方向和透視以及渲染表面設(shè)定矩陣的任務(wù)。 OpenGL Utility Toolkit (GLUT),它是一個(gè)視窗-系統(tǒng)分離的工具箱,由Mark Kilgard編寫(xiě),用于隱藏不同視窗的API所帶來(lái)的復(fù)雜性。包含文件對(duì)于所有OpenGL應(yīng)用程序,你都需要在所有文件中包含gl.h。幾乎所有OpenGL應(yīng)用程序使用GLU,即上文提到的OpenGL實(shí)用庫(kù)(OpenGL Utility Li
7、brary),它也需要包含gl.h才能使用。所以幾乎所有OpenGL源文件這樣開(kāi)頭:1#include 2#include 如果你用OpenGL實(shí)用工具集(OpenGL Utility Toolkit,即GLUT)來(lái)管理窗體事務(wù),你需要包含:1#include 記住glut.h保證會(huì)正確包含gl.h和glut.h,所以把三個(gè)文件全包含是多此一舉。為使你的GLUT程序通用性更佳,包含glut.h而不要明確包含gl.h或glu.h。設(shè)置編譯器在Windows上使用MS Visual Studio C+安裝GLUT1. 如果你已經(jīng)安裝了MS Visual Studio C+ 5.0或以上版本,那么下
8、列文件中的大多數(shù)就已經(jīng)在您的機(jī)器上了。下列的GLUT文件需要復(fù)制到指定的路徑下。2. 要開(kāi)始安裝: 右鍵單擊各鏈接 選擇另存為. 接受默認(rèn)名稱(只需點(diǎn)擊保存即可) 庫(kù)文件(放置到Visual C+下的lib子路徑中) opengl32.lib glu32.lib glut32.lib 包含文件(放置到Visual C+下的includeGL子路徑中) gl.h glu.h glut.h 動(dòng)態(tài)鏈接庫(kù)文件(放置到WindowsSystem路徑中) opengl32.dll glu32.dll glut32.dll編譯OpenGL/GLUT程序1. 創(chuàng)建一個(gè)新項(xiàng)目: 從菜單中點(diǎn)選文件 | 新建 點(diǎn)選
9、項(xiàng)目選項(xiàng)卡 點(diǎn)選Win32控制臺(tái)應(yīng)用程序 Console Application 輸入您的項(xiàng)目名稱2. 為鏈接器指定要用到的庫(kù)文件: 從菜單中點(diǎn)選項(xiàng)目 | 設(shè)置 在對(duì)象/庫(kù)模塊中:輸入opengl32.lib glu32.lib glut32.lib3. 向項(xiàng)目中添加或創(chuàng)建文件: 從文件菜單中點(diǎn)選項(xiàng)目 | 向項(xiàng)目添加 | 文件 添加需要的程序文件4. 構(gòu)建并運(yùn)行Silicon Graphics WorkstationMakefile:view sourceprint?01# insert the name of your source file here (omit the .c)02TARG
10、ET = progname0304LIBS = -lglut -lGLU -lGL -lXmu -lXext -lXi -lX11 -lm0506CC = /usr/gnu/bin/gcc0708default: $(TARGET)0910all:default1112.c.o:13$(CC) -c $1415$(TARGET): $.o16$(CC) $.o -Wall $(LIBS) -o $1718clean:19-rm -f *.o $(TARGET)開(kāi)始3D編程前需注意的十件事:開(kāi)始3D編程不是一件容易完成的任務(wù)。這里有很多新的東西可以發(fā)揮作用,從選擇語(yǔ)言到選擇合適的3d建模軟件。當(dāng)
11、這10個(gè)事情完成時(shí),無(wú)論你選擇何種語(yǔ)言,使用何種建模軟件,你都可以認(rèn)為自己是這方面的半個(gè)專家了。1:建立自己的圖形初始化函數(shù)現(xiàn)在有種類繁多的3d引擎和平臺(tái),所以這個(gè)任務(wù)一般交給它們來(lái)完成。我還記得以前的事情,你必須使用windows函數(shù)來(lái)初始化OpenGL,并管理窗口句柄和資源的加載。了解事情是如何進(jìn)行內(nèi)部管理的會(huì)讓你更深刻理解你現(xiàn)在在干什么,這是非常有用的。 我建議從NEHE的教程開(kāi)始。在教程的第一章中包含了一個(gè)C語(yǔ)言編寫(xiě)的利用Windows API的圖形初始化函數(shù)。如果這里有很多東西需要你控制,你可以試試C+的相對(duì)的函數(shù),或者使用托管語(yǔ)言,像C#、Java或者Python。在網(wǎng)絡(luò)中有很多例
12、子。2:實(shí)現(xiàn)自己的相機(jī)您可以從互聯(lián)網(wǎng)上復(fù)制和粘貼攝像頭的代碼,使用它并沒(méi)有大的問(wèn)題, 但它不是自己的相機(jī),直到你從頭開(kāi)始,充分了解一些概念,如向量處理,矩陣變化,角度轉(zhuǎn)換等等。你應(yīng)該先從一個(gè)FPS(第一人稱射擊)的攝像頭開(kāi)始,它會(huì)給你需要的一切并讓你為接下來(lái)的學(xué)習(xí)做好準(zhǔn)備。如果你以后想構(gòu)建自己的游戲,你不能使用它。我建議你閱讀這篇文章,以找出最適合您的需求類型的相機(jī)。3:了解初級(jí)的3D概念當(dāng)我開(kāi)始,我就開(kāi)始聽(tīng)到了很多新詞,如抗鋸齒,各向異性過(guò)濾,阻塞測(cè)試,Z-緩沖,alpha測(cè)試,著色器語(yǔ)言,凹凸貼圖等。如果你是一個(gè)玩家,也許你已經(jīng)在配置游戲的圖形設(shè)置時(shí)看過(guò)它們了。請(qǐng)確保你花費(fèi)一些時(shí)間來(lái)閱讀相
13、關(guān)內(nèi)容,因?yàn)檫@將會(huì)給你一個(gè)3D編程的概述。4:學(xué)習(xí)所有向量和矩陣的知識(shí)這始終被低估。我強(qiáng)烈建議,為了正確地管理如相機(jī),光線追蹤,地形跟蹤的東西,你應(yīng)該知道關(guān)于這個(gè)的一切。當(dāng)然,你也需要學(xué)會(huì)最基礎(chǔ)的三角知識(shí)?,F(xiàn)在我才明白,如果我愿意花幾分鐘研究這個(gè)問(wèn)題,我的生活本應(yīng)該很輕松。5:編寫(xiě)你自己的3D模型加載器我建議從使用OBJ文件或STL文件開(kāi)始,因?yàn)樗麄冇靡粋€(gè)ASCII格式表示。之后你可以遷移到其他根偉復(fù)雜的格式上,比如3DS格式。有了這個(gè),你不僅將了解如何保存3D模型,你還會(huì)理解如何繪制三角形,然后你就會(huì)明白圖形引擎是如何繪制一切的。6:成功實(shí)現(xiàn)自己的碰撞算法一個(gè)事情是繪制世界,另外一個(gè)是管理其
14、他中幾何形狀。在一個(gè)虛擬的3D世界中,這里沒(méi)有物理定律,所以你必須創(chuàng)建它們。如果你想要一個(gè)對(duì)象不能穿越墻壁,那么你必須在墻壁中創(chuàng)建一個(gè)幾何圖形并計(jì)算所有東西。有幾種方法來(lái)管理碰撞,我建議從在一個(gè)迷宮項(xiàng)目實(shí)現(xiàn)兩體碰撞開(kāi)始。試試這個(gè)鏈接,了解更多信息。7:實(shí)現(xiàn)一個(gè)小的粒子引擎當(dāng)我發(fā)現(xiàn)3D游戲中火焰、煙霧、照明和一些其他令人驚艷的效果是由粒子組成,而那些粒子是由相機(jī)面前的貼圖組成。你添加更多的粒子,效果看起來(lái)更加逼真,但是性能就有所損失了。我的第一個(gè)粒子引擎是為火箭的煙霧制作的,而且我這樣做的時(shí)候還沒(méi)有不參看粒子引擎教程。后來(lái)我意識(shí)到了,我已經(jīng)改造了車輪。通過(guò)實(shí)現(xiàn)這些東西,你會(huì)明白一些諸如粒子發(fā)射器
15、、粒子行為等想法。8:了解一個(gè)3D建模軟件的基本知識(shí)為了修改在你的應(yīng)用中使用的3D模型,你應(yīng)該知道基本的操作,比如平移,縮放,旋轉(zhuǎn),變形,導(dǎo)出為其他格式,并制作簡(jiǎn)單的模型。如果你不這樣做,你在制作第一個(gè)游戲時(shí)遇到事事依賴別人的情況。我曾用過(guò)幾個(gè)建模軟件,我強(qiáng)烈推薦3D MAX或Maya。9 :加載和播放動(dòng)畫(huà)我做過(guò)的最困難的事情是加載并正確播放動(dòng)畫(huà)。我不得不對(duì)3D max的XAF文件進(jìn)行大量的逆向。我不得不學(xué)習(xí)骨骼層次,矩陣插值等東西。在最后,看到自己的模型自行移動(dòng)是一件讓人相當(dāng)高興的事情。我建議從一個(gè)機(jī)器人動(dòng)畫(huà)開(kāi)始,因?yàn)閯?dòng)物模型什么的還需要一種名為蒙皮的技術(shù)。#10 編寫(xiě)2D自定義GUI控件當(dāng)
16、我開(kāi)始使用XNA時(shí),由于XNA沒(méi)有實(shí)現(xiàn)窗體控件,我不得不構(gòu)建自己的圖形用戶接口。這也導(dǎo)致了兩件事:第一:我有了構(gòu)建自定義的GUI控件的能力。第二:我懂得了一些重要的概念,如事件控制和事件捕捉。這不是容易的事,我實(shí)現(xiàn)的最難的一個(gè)控件是listbox,但是一旦做出來(lái)了,就可以在很多地方使用了。結(jié)論在這個(gè)過(guò)程中你將會(huì)遇到很多問(wèn)題。你不得不花費(fèi)很多時(shí)間來(lái)使你的代碼可以正常工作,即使你很聰明。但是我可以告訴你的是,從一個(gè)程序猿的角度來(lái)說(shuō),沒(méi)有什么快樂(lè)比的上你看著你的代碼能順利的工作。我仍然不能忘記當(dāng)我第一次編出OBJ模塊加載器時(shí)的喜悅。當(dāng)時(shí),我想要加載個(gè)人臉圖像,然后數(shù)個(gè)小時(shí)過(guò)去了,在凌晨3:50時(shí),突
17、然一個(gè)非常詭異的人臉出現(xiàn)在我的屏幕,真是嚇?biāo)赖耍慨?dāng)我想起這件事時(shí),就哈哈大笑.我確信當(dāng)你設(shè)法完成這10件事后,你可以說(shuō)你已經(jīng)了解了3D編程的基礎(chǔ)。我寫(xiě)篇文章是因?yàn)槲一撕芏鄷r(shí)間來(lái)完成它(指走了彎路了),所以我希望每個(gè)開(kāi)始接觸3D編程的人,能有一個(gè)小小的指南。我的建議是開(kāi)始做一個(gè)小小的游戲,并不斷的完善它。我覺(jué)得這是一個(gè)很好的方式,因?yàn)槿绻皇菃渭兊娜W(xué)習(xí)而看不到實(shí)際的效果的話,積極性不高。一段時(shí)間之后,你會(huì)覺(jué)得游戲?qū)δ銇?lái)說(shuō)不一樣了,因?yàn)槟銜?huì)花很多時(shí)間來(lái)想它們是怎么解決你曾經(jīng)碰到的技術(shù)難點(diǎn)的。以上,我試圖使這篇文章結(jié)構(gòu)保持清晰和易懂,如果你喜歡,你可以訪問(wèn)我的博客來(lái)獲取更多的這方面的內(nèi)容。下
18、附原文原文:Introduction to OpenGLOpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric primitives - points, lines, polygons, images, and bitmaps. OpenGL provides a set of commands that allow the specification of geometric objects in two or thr
19、ee dimensions, using the provided primatives, together with commands that control how these objects are rendered (drawn).Since OpenGL drawing commands are limited to those that generate simple geometric primitives (points, lines, and polygons), the OpenGL Utility Toolkit (GLUT) has been created to a
20、id in the development of more complicated three-dimensional objects such as a sphere, a torus, and even a teapot. GLUT may not be satisfactory for full-featured OpenGL applications, but it is a useful starting point for learning OpenGLGLUT is designed to fill the need for a window system independent
21、 programming interface for OpenGL programs. The interface is designed to be simple yet still meet the needs of useful OpenGL programs. Removing window system operations from OpenGL is a sound decision because it allows the OpenGL graphics system to be retargeted to various systems including powerful
22、 but expensive graphics workstations as well as mass-production graphics systems like video games, set-top boxes for interactive television, and PCs.GLUT simplifies the implementation of programs using OpenGL rendering. The GLUT application programming interface (API) requires very few routines to d
23、isplay a graphics scene rendered using OpenGL. The GLUT routines also take relatively few parameters.Rendering PipelineMost implementations of OpenGL have a similar order of operations, a series of processing stages called the OpenGL rendering pipeline. Although this is not a strict rule of how Open
24、GL is implemented, it provides a reliable guide for predicting what OpenGL will do. Geometric data (verices, line, and polygons) follow a path through the row of boxes that includes evaluators and per-vertex operations, while pixel data (pixels, images and bitmaps) are treated differently for part o
25、f the process. Both types of data undergo the same final step (raterization) before the final pixel data is written to the framebuffer.Display Lists:All data, whether it describes geometry or pixels, can be saved in a display list for current or later use. (The alternative to retaining data in a dis
26、play list is processing the data immediately-known as immediate mode.) When a display list is executed, the retained data is sent from the display list just as if it were sent by the application in immediate mode.Evaluators:All geometric primitives are eventually described by vertices. Evaluators pr
27、ovide a method for deviving the vertices used to represent the surface from the control points. The method is a polynomial mapping, which can produce surface normal, colors, and spatial coordinate values from the control points.Per-Vertex and Primitive Assembly:For vertex data, the next step convert
28、s the vertices into primitives. Some types of vertex data are transformed by 4x4 floating-point matrices. Spatial coordinates are projected from a position in the 3D world to a position on your screen. In some cases, this is followed by perspective division, which makes distant geometric objects app
29、ear smaller than closer objects. Then viewport and depth operations are applied. The results at this point are geometric primitives, which are transformed with related color and depth vlaues and guidelines for the rasterization step.Pixel Operations:While geometric data takes one path through the Op
30、enGL rendering papeline, pixel data takes a different route. Pixels from an array in system memory are first unpacked form one of a variety of formats into the proper number of components. Next the data is scaled, biased, processed by a pixel map, and sent to the rasterization step.Rasterization:Ras
31、terization is the conversion of both geometric and pixel data into fragments. Each fragment square corresponds to a pixel in the framebuffer. Line width, point size, shading model, and coverage calculations to support antialiasing are taken ito consideration as vertices are connected into lines or t
32、he interior pixels are calculated for a filled polygon. Color and depth values are assigned for each fragment square. The processed fragment is then drawn into the appropriate buffer, where it has finally advanced to be a pixel and achieved its final resting place.LibrariesOpenGL provides a powerful
33、 but primitive set of rendering command, and all higher-level drawing must be done in terms of these commands. There are several libraries that allow you to simplify your programming tasks, including the following: OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL co
34、mmands to perform such tasks as setting up matracies for specific viewing orientations and projections and rendering surfaces. OpenGL Utility Toolkit (GLUT) is a window-system-independent toolkit, written by Mark Kilgard, to hide the complexities of differing window APIs.Include FilesFor all OpenGL
35、applications, you want to include the gl.h header file in every file. Almost all OpenGL applications use GLU, the aforementioned OpenGL Utility Library, which also requires inclusion of the glu.h header file. So almost every OpenGL source file begins with:Setting Up Compilers Windows Using MS Visual
36、 C+Installing GLUT1. Most of the following files (ie. OpenGL and GLU) will already be present if you have installed MS Visual C+ v5.0 or later. The following GLUT files will need to be copied into the specified directories.2. To install: right-click each link chooseSave Link As. accept the default n
37、ame (just clickSave) libraries (place in thelib subdirectory of Visual C+) opengl32.lib glu32.lib glut32.lib include files (place in theincludeGL subdirectory of Visual C+) gl.h glu.h glut.h dynamically-linked libraries (place in the WindowsSystemsubdirectory opengl32.dll glu32.dll glut32.dllCompili
38、ng OpenGL/GLUT Programs1. Create a new project: chooseFile | Newfrom the File Menu select theProjectstab chooseWin32 Console Application fill in your Project name2. Designate library files for the linker to use: chooseProject | Settingsfrom the File Menu underOject/library modules:enter opengl32.lib
39、 glu32.lib glut32.lib3. Add/Create files to the project: chooseProject | Add to Project | Filesfrom the File menu add the required program files4. Build and ExecuteSilicon Graphics WorkstationMakefile:view sourceprint?01# insert the name of your source file here (omit the .c)02TARGET = progname0304L
40、IBS = -lglut -lGLU -lGL -lXmu -lXext -lXi -lX11 -lm0506CC = /usr/gnu/bin/gcc0708default: $(TARGET)0910all:default1112.c.o:13$(CC) -c $1415$(TARGET): $.o16$(CC) $.o -Wall $(LIBS) -o $1718clean:19-rm -f *.o $(TARGET)Ten Things to Achieve When Starting 3D Programming:Starting 3D programming is not an e
41、asy task to accomplish. There are a lot of new things that come into play, and they vary from choosing a programming language to selecting the correct 3D modeling software. These 10 goals are the things that when they are done, no matter in what language and with what rendering engine, you can consi
42、der yourself a semi-expert on this matter.#1: Build your own custom graphic initialization functionToday with the great variety of 3D engines and platforms, this task is always delegated to those. I still remember the times when you had to initialize OpenGL with all the windows functions, and how yo
43、u had to manage windows handles and resource loading yourself. This is useful to understand how things are managed internally and will give you more comprehension of what you are doing. My advice is to start looking atNEHE tutorials, it has a graphic initialization function written in C and with win
44、dows APIs in chapter one. If this is a lot for you to handle, you should look at C+ equivalent functions or try to port them to managed languages like C#, Java or Python. There are plenty of examples on the internet.#2: Implement your own cameraYoucan copy and paste a camera code from the internet,
45、and use it without major problems, but it is not until you make your own camera from scratch that you will fully understand some concepts like vector handling, translation matrices, angle conversion, etc. You should start by coding a FPS (First Person Shooter) camera; it has everything it needs to g
46、et you ready. Later if you want to make your own game and you cant use it, I recommend you to readthis articleto find out the type of camera that best suits your needs.#3: Understand primary 3D conceptsWhen I started, I began to hear a lot of new words like anti-aliasing, anisotropic filtering, occl
47、usion testing, z-buffer, alpha testing, shader language, bump mapping, etc. Maybe if you are a gamer, you have seen some of them while configuring the graphic settings of your game. Make sure you spent some time reading about this, because it will give an overview of what 3D programming is.#4: Learn
48、 everything you can about vectors and matricesThis is always underestimated, I strongly recommend that in order to correctly manage things like cameras, terrain following, ray tracing; you should know everything about this. You should also learn minimum trigonometry basis. Now I understand how easy
49、my life would have been if I would had spent only a few hours studying this matter.#5: Code yourself a 3D model loaderI recommend beginning with a .OBJ file or a .STL file because they have an ASCII format representation. Later, you can move to other more complex formats like .3DS. With this, you no
50、t only will understand more how 3D models are saved, you will have to draw it in its raw manner: triangles, and then you will understand how everything is drawn in a graphics engine.#6: Successfully make your own collision algorithmIt is one thing to draw a world and another thing to manage its geom
51、etry. In a virtual 3D world, there are no physics laws, so you have to create them. If you want an object not to go through a wall, then you have to create an internal geometric representation of the wall and make all the calculations yourself. There are several approaches to handle collisions; I re
52、commend starting with binary collisions with a labyrinth project. Trythis linkfor more information.#7: Implement a small particle engineI was disappointed when I found out that fire, smoke, some lighting and other stunning effects that you see in 3D games are made by particles and that particles are
53、 in essence planes with textures facing the camera. The more particles you add, the more realistic the effect looks but the performance is more compromised. The first particle engine I made was for rocket smoke and I did it without looking at a particle engine tutorial. Later I realized I had reinve
54、nted the wheel but I was really into this. By carrying out this, you will understand concepts like particle emitters, particle behavior and bill boarding techniques, among others.#8: Learn the basics in a 3D modeling softwareIn order to make changes to the 3D models you want to use in your applicati
55、on, you should at least know operations like translating, scaling, rotating, texturing, exporting to other formats and making simple models. If you dont do that, you will suffer from depending on other people to do your first game. Ive worked with a few modeling software and I strongly recommend 3D
56、Max or Maya.#9: Load and play an animationLoading and correctly playing an animation was the most difficult thing in 3D that I ever did. I had to do reverse engineering to a 3D max .XAF file. I had to also learn stuff like bone hierarchy, matrix interpolation, among others. At the end, it was very gratifying to look at your own models moving by themselves. I recommend starting with animating a
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 小額放貸公司合同范本
- 按揭車轉(zhuǎn)讓合同范本
- 液晶聚合物L(fēng)CP戰(zhàn)略市場(chǎng)規(guī)劃報(bào)告
- 數(shù)字電視調(diào)制器產(chǎn)業(yè)分析報(bào)告
- 借錢擔(dān)保合同范本
- 廠區(qū)電線維修合同范本
- 付費(fèi)攝影合同范本
- 新余小學(xué)英語(yǔ)試卷
- 中醫(yī)工作計(jì)劃
- 個(gè)體戶減稅申請(qǐng)書(shū)
- 富血小板血漿(PRP)臨床實(shí)踐與病例分享課件
- 跨文化交際教程 課件 杜平 Unit 1 Cultural Awareness and Intercultural Communication-Unit 3 Nonverbal Communication
- 光伏工程施工組織設(shè)計(jì)
- 社保知識(shí)競(jìng)賽考試題及答案
- 華為HCSA-Presales-IT售前認(rèn)證備考試題及答案
- 2024-2030年中國(guó)纖維板行業(yè)發(fā)展趨勢(shì)與投資戰(zhàn)略研究報(bào)告
- 小學(xué)二年級(jí)上冊(cè)數(shù)學(xué)思維訓(xùn)練題100道及答案解析
- 2024年品酒師職業(yè)技能大賽理論考試題庫(kù)及答案
- 2024-2025學(xué)年全國(guó)中學(xué)生天文知識(shí)競(jìng)賽考試題庫(kù)(含答案)
- 2024至2030年中國(guó)細(xì)胞農(nóng)業(yè)動(dòng)向追蹤與發(fā)展前景現(xiàn)狀探索報(bào)告
- 2025初級(jí)社會(huì)工作實(shí)務(wù)考試要點(diǎn)速記
評(píng)論
0/150
提交評(píng)論