版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Ogre中級(jí)教程7 翻譯by CatDTable of contents目錄 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Introduction Introduction先決條件 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Setting_Up_the_Scene Setting
2、Up the Scene創(chuàng)建場(chǎng)景 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Creating_a_Texture Creating a Texture創(chuàng)建紋理 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Writing_Our_Texture_to_a_File Writing O
3、ur Texture to a File寫(xiě)出我們的紋理到文件 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Implementing_the_Miniscreen Implementing the Miniscreen實(shí)現(xiàn)迷你場(chǎng)景 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Creat
4、ing_a_Material_From_Scratch Creating a Material From Scratch從頭創(chuàng)建一個(gè)材質(zhì) HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Using_a_RenderTargetListener Using a RenderTargetListener使用一個(gè)渲染目標(biāo)監(jiān)聽(tīng)器 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Interm
5、ediate+Tutorial+7&structure=Tutorials l Render_to_Texture_and_Shaders Render to Texture and Shaders渲染到紋理和陰影 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Exercises Exercises練習(xí) HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+T
6、utorial+7&structure=Tutorials l Easy Easy簡(jiǎn)單 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Intermediate Intermediate中級(jí) HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Difficult Difficult困難 HYPE
7、RLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Advanced Advanced地獄(括弧笑) HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Conclusion Conclusion總結(jié) HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?pag
8、e=Intermediate+Tutorial+7&structure=Tutorials l Full_Source Full Source全部代碼 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+7&structure=Tutorials l Next Next下一節(jié)Introduction先決條件This tutorial covers the basics of rendering a scene to a texture. This technique is used for a
9、 variety of effects. It is particularly useful in combination with shaders. Motion blur effects can be created in this way.本教程涵蓋了渲染紋理到一個(gè)場(chǎng)景,這個(gè)技術(shù)用于制作出各種效果,它在結(jié)合著色器時(shí)格外的有用,可以用這種方法創(chuàng)建動(dòng)態(tài)模糊效果。The basic idea is rather simple. Instead of just sending render information strictly to our render window, we will al
10、so send the information to be rendered directly to a texture in our scene. This texture will then be used like a texture loaded from the hard drive.基本的想法非常簡(jiǎn)單,咱在咱的場(chǎng)景里發(fā)送直接渲染的信息到紋理來(lái)代替咱發(fā)送嚴(yán)格的渲染信息,這種結(jié)構(gòu)將用起來(lái)像是使用一個(gè)已經(jīng)被硬盤(pán)加載的紋理。The full source for this tutorial is HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.p
11、hp?page=IntermediateTutorial7SourceCurrent o IntermediateTutorial7SourceCurrent here.本教程的完整代碼鏈接。Note:There is also source available for the BaseApplication framework and Ogre 1.7 HYPERLINK http:/www.ogre3/tikiwiki/tiki-index.php?page=IntermediateTutorial7Source o Intermediate Tutorial 7 - source her
12、e.注意:我們同時(shí)也準(zhǔn)備了Baseapplication框架和Ogre1.7的資源鏈接。Setting Up the Scene建立場(chǎng)景First, as usual, we are going to set up a basic scene. Add the following variables to your project.首先,和往常一樣,咱準(zhǔn)備建立一個(gè)基本的場(chǎng)景,為你的工程添加下面的代碼:BasicApp.hOgre:MovablePlane* mPlane;Ogre:Entity* mPlaneEntity;Ogre:SceneNode* mPlaneNode;Ogre:Rect
13、angle2D* mMiniscreen;Remember to initalize them all in the constructor.記得在構(gòu)造器里面注冊(cè)這些:BasicApp.cppmPlane(0),mPlaneEntity(0),mPlaneNode(0),mMiniscreen(0)Finally, well set up the basic scene elements we need. Add the following tocreateScene:終于,咱準(zhǔn)備好了咱創(chuàng)建基本場(chǎng)景所需要的所有元素辣,將下面的代碼扔進(jìn)咱的createScene()創(chuàng)建場(chǎng)景函數(shù)里:mSceneM
14、gr-setAmbientLight(Ogre:ColourValue(0.2, 0.2, 0.2);/設(shè)置環(huán)境燈光顏色為0.2,0.2,0.2最大值為1Ogre:Light* light = mSceneMgr-createLight(MainLight);light-setPosition(20, 80, 50);/創(chuàng)建MainLight這里沒(méi)有設(shè)置燈光的類(lèi)型,采取了默認(rèn)的設(shè)置mCamera-setPosition(60, 200, 70);mCamera-lookAt(0,0,0);/設(shè)定了攝像機(jī)的位置和LookAt(指向)的點(diǎn)Ogre:MaterialPtr mat = Ogre:Ma
15、terialManager:getSingleton().create( PlaneMat, Ogre:ResourceGroupManager:DEFAULT_RESOURCE_GROUP_NAME);/使用材質(zhì)管理器創(chuàng)建了材質(zhì)Ogre:TextureUnitState* tuisTexture = mat-getTechnique(0)-getPass(0)-createTextureUnitState(grass_1024.jpg);/不知道在干啥(括弧笑mPlane = new Ogre:MovablePlane(Plane);mPlane-d = 0;mPlane-normal =
16、Ogre:Vector3:UNIT_Y;/創(chuàng)建一個(gè)平面Ogre:MeshManager:getSingleton().createPlane( PlaneMesh, Ogre:ResourceGroupManager:DEFAULT_RESOURCE_GROUP_NAME, *mPlane, 120, 120, 1, 1, true, 1, 1, 1, Ogre:Vector3:UNIT_Z);mPlaneEntity = mSceneMgr-createEntity(PlaneMesh);mPlaneEntity-setMaterialName(PlaneMat);/實(shí)體化平面mPlaneN
17、ode = mSceneMgr-getRootSceneNode()-createChildSceneNode();mPlaneNode-attachObject(mPlaneEntity);/將平面綁定到場(chǎng)景節(jié)點(diǎn)中If any of this is confusing, refer to previous tutorials. Compile and run your application. You should see a rotating grass-textured plane.加入你對(duì)上面的代碼有任何不太懂的地方,那么你需要復(fù)習(xí)一下前面的教程辣!完成并運(yùn)行一下你的程序,你應(yīng)該可以看
18、到一個(gè)在不停的旋轉(zhuǎn)的草地。Creating a TextureThe first step is to create a texture we can render to. Add the folowing tocreateScene:第一步咱要做的事情就是創(chuàng)建一個(gè)紋理以便咱渲染,添加下面的代碼到咱的createScenen()函數(shù)內(nèi):Ogre:TexturePtr rttTexture = Ogre:TextureManager:getSingleton().createManual( RttTex, Ogre:ResourceGroupManager:DEFAULT_RESOURCE_GR
19、OUP_NAME, Ogre:TEX_TYPE_2D, mWindow-getWidth(), mWindow-getHeight(), 0, Ogre:PF_R8G8B8, Ogre:TU_RENDERTARGET);The first parameter of this function is the name to give the texture (RttTex is somewhat standard). The second specifies the default resource group. The third specifies the type of the textu
20、re to be 2D. The fourth and fifth specify the width and height of the texture. The sixth parameter is the number of mipmaps to be used. The seventh is a texture format, and the last is a usage flag.這塊函數(shù)的第一個(gè)參數(shù)功能是給材質(zhì)命名,第二個(gè)參數(shù)則指定了默認(rèn)的資源包,第三個(gè)參數(shù)指定了材質(zhì)的類(lèi)型為2D,第四個(gè)參數(shù)和第五個(gè)參數(shù)指定了材質(zhì)的高和寬,第六個(gè)參數(shù)則是咱要使用的mipmaps(紋理圖片)的數(shù)量,
21、第七個(gè)則是材質(zhì)的格式,最后一個(gè)是用法標(biāo)記。There are many different texture formats, but the simplest one is PF_R8G8B8. This produces a 24-bit RGB texture. If you need an alpha channel, then PFR8G8B8A8 will work fine.材質(zhì)的格式有非常多種,但是最簡(jiǎn)單的一種就是PF_R8G8B8,是一種24-bit RGB材質(zhì),如果你想修改下透明圖,那么PFR8G8B8A8就能勝任。Next we need to get a pointer
22、to the render target of this texture in order to set some parameters. It will also be used later to add a RenderTargetListener.接下來(lái)我們需要獲得一只指針指向紋理的渲染目標(biāo)以便我們?cè)O(shè)定一些參數(shù),同時(shí)待會(huì)也會(huì)用于添加RenderTargetListener()渲染目標(biāo)監(jiān)聽(tīng)器:Ogre:RenderTexture* renderTexture = rttTexture-getBuffer()-getRenderTarget();renderTexture-addViewpo
23、rt(mCamera);renderTexture-getViewport(0)-setClearEveryFrame(true);renderTexture-getViewport(0)-setBackgroundColour(Ogre:ColourValue:Black);renderTexture-getViewport(0)-setOverlaysEnabled(false);After retrieving the RenderTexture, we add the cameras viewport to it. This is the viewport that will be r
24、endered to our texture. We also tell the viewport to clear itself every frame. If we didnt do this, then you would get the infinite trails effect. Try it, its fun. We also set the background color to black, and we disable overlays so that they wont be rendered on top of our texture if we were to use
25、 them.在完成檢索RenderTexture后,咱添加了攝像機(jī)的視口進(jìn)去;這個(gè)視口將是咱將要渲染咱的材質(zhì)的視口。咱同時(shí)也告訴了視口要清除每一幀,假如咱不這么做,你就會(huì)獲得infinite trails effec(無(wú)限軌跡效果)。你可以試試看,挺有意思的。同時(shí)咱還設(shè)定了背景顏色為黑色,咱還取消了覆蓋,所以呢,在咱不使用他們的時(shí)候,他們不會(huì)在我們的紋理上面被渲染。Writing Our Texture to a File寫(xiě)出咱的紋理成一個(gè)文件(括弧笑)We are now going to save our texture to a file. RenderTextures are deri
26、ved from RenderTargets so they already have a function to store their content to a file. Before saving the texture, be sure to update it once.咱現(xiàn)在準(zhǔn)備保存咱的紋理成一個(gè)文件,RenderTextures源于RenderTargets所以他們已經(jīng)有一個(gè)函數(shù)來(lái)存儲(chǔ)到一個(gè)文件的內(nèi)容,一定要記得更新一次。renderTexture-update();renderTexture-writeContentsToFile(start.png);If you comp
27、ile and run the application now, you will find start.png in the directory that includes your binary executable. It should show the content of your screen.假如你現(xiàn)在你完成了并且運(yùn)行了你的程序,你會(huì)發(fā)現(xiàn)start.png在存放程式碼的目錄里,它應(yīng)該顯示屏幕的內(nèi)容。Note there is also a function calledsetAutoUpdatedwhich will automatically update the Render
28、Texture if Ogres rendering loop orRoot:_updateAllRenderTargetsis being used. Keep in mind that it does not update the RenderTexture immediately when it is called.注意,那里有一個(gè)setAutoUpdated函數(shù),它可以自動(dòng)的更新RenderTexture(渲染紋理),只要Ogre的渲染循環(huán)或者Root:_updateAllRenderTargets開(kāi)始使用,記住辣!它是不會(huì)在被調(diào)用的時(shí)候立刻更新RenderTexture的。Imple
29、menting the Miniscreen實(shí)現(xiàn)小屏幕Now we will add a miniscreen to the upper right corner of our application window. To do this, well use a Rectangle2D with our RenderTexture applied to it. Our scene will be shown twice. It will be rendered to our RenderWindow normally and rendered a second time on to our m
30、iniscreen.現(xiàn)在咱要添加一個(gè)迷你屏幕到我們程序的窗口右下方,為了做到這點(diǎn),我們將使用一個(gè)Rectangle2D和咱的RenderTexture配合,咱的場(chǎng)景將會(huì)被展示兩次(或者說(shuō)咱的場(chǎng)景會(huì)有兩個(gè)屏幕可以同時(shí)觀察,迷你的嵌在大的窗口上),咱的場(chǎng)景將會(huì)被渲染到我們的大渲染窗口上,并且還會(huì)渲染到迷你的窗口上。You can use this method to create security camera monitors or computer screens with rendered graphics on them. Of course you dont need to simply
31、 replicate the cameras viewpoint. You can attach a different viewport to the RenderTexture, allowing you to do things like remote controlled robots with their own camera that feeds back to a miniscreen.你可以用這個(gè)方法創(chuàng)建安全的攝像頭監(jiān)聽(tīng)器或是電腦屏幕來(lái)呈現(xiàn)你繪制的圖形(括弧笑),當(dāng)然你不需要簡(jiǎn)單的復(fù)制你的攝像頭的視口,你可以添加一個(gè)不同的視口到渲染紋理,這允許你做很多事情,像遙控一個(gè)機(jī)器人將其
32、攝像頭穿回來(lái)到迷你屏幕上。First, well set up the Rectangle2D.首先,咱啟動(dòng)Rectangle2D:mMiniScreen = new Ogre:Rectangle2D(true);mMiniScreen-setCorners(.5, 1.0, 1.0, .5);mMiniScreen-setBoundingBox(Ogre:AxisAlignedBox:BOX_INFINITE);The first line tells the Rectangle2D to generate texture coordinates. These are what well u
33、se to apply our texture. In the second line we set the coordinates for our miniscreen. These are coordinates that run from the top-left (-1.0, 1.0) to the bottom-right (1.0, -1.0). This places our rectangle in the upper right corner of the screen with a width and height that are equal to 1/4 of the
34、screens dimensions. Youll just have to get used to the fact that a number of different coordinate systems are used in graphics programming. Its not a total loss because understanding simple coordinate transformations like this may help you understand the more complicated transformations youll see in
35、 other areas.第一行我們告訴Rectangle2D生成紋理的貼圖坐標(biāo),這咱準(zhǔn)備貼圖的矩形。在第二行中,咱設(shè)定了迷你屏幕的坐標(biāo),這些坐標(biāo)的范圍從左上角(-1.0,1.0)到右下角(1.0,-1.0)之間,這一塊在屏幕右上角的矩形是主屏幕的四分之一,你得習(xí)慣在圖形編程中使用許多的坐標(biāo)系統(tǒng)(這是冷冰冰的事實(shí)),學(xué)會(huì)這些你并不虧,因?yàn)槔斫膺@些簡(jiǎn)單的坐標(biāo)轉(zhuǎn)換可以幫助你理解復(fù)雜的系統(tǒng)轉(zhuǎn)換,在其他領(lǐng)域中你也會(huì)觸及滴! Now that we have the rectangle, we need to attach it to a SceneNode as usual.現(xiàn)在,咱已經(jīng)創(chuàng)建好了這個(gè)矩
36、形,咱依然需要將其綁定到場(chǎng)景節(jié)點(diǎn)中:Ogre:SceneNode* miniScreenNode = mSceneMgr-getRootSceneNode()-createChildSceneNode();miniScreenNode-attachObject(mMiniScreen);If you compile and run the application now, youll see a white rectangle where our texture will soon be.如果你完成并運(yùn)行了程序,你會(huì)在渲染完成的畫(huà)面上看到一塊白色的矩形。Creating a Material
37、From Scratch從頭創(chuàng)建一個(gè)材質(zhì)The next step is to apply our RenderTexture to the Rectangle2D weve just created. We have to create a material for it. This could be done in a material script or directly in code during runtime. We will use the second method to keep everything to one file for the tutorial.下一步中,咱將
38、應(yīng)用咱的RenderTexture到咱剛創(chuàng)建的Rectangle2D上,咱必需要從頭創(chuàng)建一個(gè)材質(zhì)給它,咱可以直接在材質(zhì)腳本中或是咱的代碼中完成它,咱將使用第二種方法以保存這個(gè)文件以配合咱的教程使用。Ogre:MaterialPtr renderMaterial = Ogre:MaterialManager:getSingleton().create( RttMat, Ogre:ResourceGroupManager:DEFAULT_RESOURCE_GROUP_NAME);renderMaterial-getTechnique(0)-getPass(0)-setLightingEnabled
39、(false);renderMaterial-getTechnique(0)-getPass(0)-createTextureUnitState(RttTex);The first part creates an empty material called RttMat. Then we disable the lighting to prevent our miniscreen from being darker than the actual texture (if we didnt, the lighting would essentially be applied twice to o
40、ur miniscreen rendering). The last line creates a new TextureUnitState using the RttTex we created earlier.第二部分的代碼創(chuàng)建了一個(gè)空的材質(zhì)并命名為:RttMat。然后咱禁用了燈光,一邊咱的迷你窗口變得比咱的實(shí)際紋理更暗(如果咱不這么做的話(huà),在咱渲染的時(shí)候燈光會(huì)被使用兩次!ps:真的變暗嗎?誰(shuí)去試試后告訴咱)。最后一串代碼創(chuàng)建了一個(gè)全新的TextureUnitState(紋理單元狀態(tài))使用咱之前創(chuàng)建的RttTex。Now we simply set this material to be
41、used by our miniscreen.現(xiàn)在,咱簡(jiǎn)單的設(shè)定這個(gè)材質(zhì)被咱的迷你窗口使用。mMiniScreen-setMaterial(RttMat);If you compile and run the application now, youll see that something is wrong. The miniscreen.has a miniscreen. To solve this well make use of a RenderTargetListener.如果你完成了并且運(yùn)行了程序,你會(huì)看到一些問(wèn)題,那及迷你窗口里面還有一個(gè)迷你窗口里面還有一個(gè)迷你窗口里面還有一個(gè)迷
42、你窗口里面還有一個(gè)迷你窗口*n,為了解決這個(gè)問(wèn)題,我們使用RenderTargetListener(渲染目標(biāo)監(jiān)聽(tīng)器)。Using a RenderTargetListenerThere may be cases where you only want certain objects from your scene to be used by your RenderTexture. In our case, we dont want our miniscreen to be rendered again in our miniscreen. What we have to do is hide
43、our miniscreen right before the window output is stored to our RenderTexture. This is what we can use the RenderTargetListener for.在很多中情況下,咱只希望一些對(duì)象被咱的RenderTexture使用,在咱的程序中,咱不希望咱的迷你窗口里面還有迷你窗口,咱要做的就是在主窗體被保存到咱的RenderTexture之前隱藏咱的迷你窗口,這就是咱的RenderTargetListener的作用!The listener has two important function
44、s for our problem:preRenderTargetUpdateandpostRenderTargetUpdate. The names practically tell you exactly what they do. The first function is called automatically by the listener before the RenderTexture is filled, and the second function is called after the RenderTexture has been filled.為了解決咱的問(wèn)題這個(gè)監(jiān)聽(tīng)
45、器有兩個(gè)函數(shù):preRenderTargetUpdate和postRenderTargetUpdate,這么命名是為了告訴你他們是干啥用的,第一個(gè)函數(shù)自動(dòng)在RenderTexture被填充之前調(diào)用監(jiān)聽(tīng)器,第二個(gè)則是自動(dòng)在RenderTexture被填充之后調(diào)用監(jiān)聽(tīng)器。To implement a RenderTargetListener we will simply have our application inherit from RenderTargetListener. This class can be included withOgreRenderTargetListener.h.
46、Add the following to your project:為了實(shí)施一個(gè)RenderTargetListener咱將讓咱的應(yīng)用程序繼承RenderTargetListener,這個(gè)類(lèi)可以被含OgreRenderTargetListener.h.里,添加如下代碼到你的程序中:BasicApp.h#include class BasicApp : public Ogre:WindowEventListener, public Ogre:FrameListener, public Ogre:RenderTargetListener, public OIS:KeyListener, publi
47、c OIS:MouseListener . / / Tutorial Section / / virtual void preRenderTargetUpdate(const Ogre:RenderTargetEvent& rte); virtual void postRenderTargetUpdate(const Ogre:RenderTargetEvent& rte); .;Then we will add these methods and toggle the visibility off right before updating the RenderTexture and the
48、n right back on afterwards.然后我們將添加這些方法之前,切換可見(jiàn)性更新RenderTexture然后回來(lái)之后。(不會(huì)翻譯辣,翻譯軟件是這么翻譯的。)BasicApp.cppvoid BasicApp:preRenderTargetUpdate(const Ogre:RenderTargetEvent& rte) mMiniScreen-setVisible(false);void BasicApp:postRenderTargetUpdate(const Ogre:RenderTargetEvent& rte) mMiniScreen-setVisible(true)
49、;All that is left is to add the listener to our RenderTexture so the methods are actually called automatically. Remember, our application has inherited from RenderTargetListener so it can be passed directly as the listener. Add the following tocreateScene, right after we set the miniscreen material:
50、所有這些其實(shí)是將咱的監(jiān)聽(tīng)器添加給咱的RenderTexture并實(shí)現(xiàn)自動(dòng)調(diào)用,記住,咱的程序繼承于RenderTargetListener渲染目標(biāo)監(jiān)聽(tīng)器,所以他能迅速傳參像一個(gè)監(jiān)聽(tīng)器一樣。添加下面的代碼到createScenen,就在咱設(shè)定迷你窗口的material的那行后面。renderTexture-addListener(this);Compile and run your application. You should have a working RTT texture mapped to your miniscreen.完成并運(yùn)行程序,你會(huì)發(fā)現(xiàn)一個(gè)正在工作的Rtt紋理運(yùn)作在迷你窗口
51、上。Render to Texture and Shaders渲染到紋理和著色器This process is often used together with shaders to create a vast array of effects. So it will be useful to know how to pass a RenderTexture to a shader.這項(xiàng)技術(shù)常于著色器一起工作以生產(chǎn)大量的酷炫特效,所以,知道怎么將一個(gè)RenderTexture傳送到一個(gè)著色器里是灰常有用的。The simplest case is where the texture never
52、 changes for the shader during runtime. You just have to tell your material script the name of the texture you create during runtime, in our case RttTex. So in your material script, thetexture_unitwould look like this:最簡(jiǎn)單的情況就是紋理材質(zhì)在運(yùn)行時(shí)從不改變,你只要告訴你的材質(zhì)腳本你在運(yùn)行時(shí)創(chuàng)建的紋理在我們的RttTex中的名字,所以呢,在你的材質(zhì)腳本中,texture_unti
53、應(yīng)該是這樣子滴:(PS:在這里,不知道你有沒(méi)有接觸過(guò)材質(zhì)腳本文件,Ogre文件夾下media文件夾內(nèi)的materials文件夾下的script文件夾內(nèi)有很多腳本材質(zhì)文件,均是以.material結(jié)尾,你可以試著用記事本或者是寫(xiě)字板打開(kāi)觀察一下材質(zhì)腳本文件)texture_unit texture RttTexIf you need to change the shaders texture during runtime, then you would use the following two lines:如果你需要在運(yùn)行時(shí)修改合成器內(nèi)的紋理,那么你就得使用下面的兩行代碼:Ogre:Mater
54、ialPtr material = Ogre:MaterialManager:getSingleton().getByName(Sepia);material-getTechnique(0)-getPass(0)-getTextureUnitState(0)-setTextureName( OtherRttTex);The first line gets a pointer to the material. The second line sets the desired texture name.第一行代碼獲得一個(gè)指針指向material,第二行則是想要得到的材質(zhì)名。After settin
55、g the correct texture name, you can access the texture in your Cg shader with the following line:在調(diào)整紋理名后,你可以進(jìn)入你的CG合成器,添加如下兩行:(PS:不知道你有沒(méi)有接觸CG合成器,OGRE自帶的CG合成器儲(chǔ)存在media/material/programs內(nèi),同樣使用記事本或者寫(xiě)字板打開(kāi)看看吧?。﹗niform sampler2D SceneSampler : register(s0)Thats all there is to it. Download the files and try
56、 it out with your application.這是咱所有需要的做的,下載下面連接里的文件然后配合你的程序試試吧。 HYPERLINK http:/www.ogre3/tikiwiki/tiki-download_wiki_attachment.php?attId=151&download=y o RAR archive with sepia material and sepia CG shader RAR archive with sepia material and sepia CG shader(PS:說(shuō)不定有些童鞋不知道這些文件應(yīng)該放在哪里,在debug和release模式
57、下,ogre/bin文件夾下有兩文件夾分別是debug和release,里面會(huì)有一個(gè)resources.cfg文件,用筆記本或是寫(xiě)字板打開(kāi)后,可以看到里面的資源文件路徑,將medial和cg shader放入這些目錄下!或者簡(jiǎn)單的說(shuō):放在materil和programs里面。)Exercises練習(xí)Easy簡(jiǎn)單Add more objects to your scene and then hide some of them from the RenderTexture using the listener.添加更多的物體到你的屏幕并且在RenderTexture中使用監(jiān)聽(tīng)器隱藏其中的一些。Intermediate中級(jí)Add a second miniscreen that displays the same scene from a different angle.添加第二個(gè)迷你屏幕以另外一個(gè)角度來(lái)查看場(chǎng)景。Difficult困難Set up and display a viewport in your miniscreen other than your main camera.使用一個(gè)不同于你的主攝
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 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ì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 44890-2024行政許可工作規(guī)范
- YC/T 620-2024煙草零售客戶(hù)滿(mǎn)意度調(diào)查規(guī)范
- 2025版凈化車(chē)間工程綠色施工管理合同3篇
- 2024年度大數(shù)據(jù)與云計(jì)算戰(zhàn)略聯(lián)盟協(xié)議書(shū)范本3篇
- 2024年車(chē)貸還款計(jì)劃表3篇
- 2025版建筑工地臨時(shí)工勞動(dòng)合同模板3篇
- 建筑工程財(cái)務(wù)結(jié)算承諾書(shū)
- 交通工具報(bào)廢更新管理辦法
- 電商配送司機(jī)招聘合同樣本
- 門(mén)店市場(chǎng)調(diào)研數(shù)據(jù)創(chuàng)業(yè)
- 2024年人教版小學(xué)三年級(jí)科學(xué)(上冊(cè))期末試卷及答案
- 大學(xué)期末考試《電路理論》試卷及答案解析
- 2024年天津市中考英語(yǔ)試題卷(含答案)
- 2024-2034年中國(guó)皮帶輸送機(jī)托輥行業(yè)發(fā)展趨勢(shì)及投資前景預(yù)測(cè)報(bào)告
- FZ∕T 73037-2019 針織運(yùn)動(dòng)襪行業(yè)標(biāo)準(zhǔn)
- 經(jīng)典導(dǎo)讀與欣賞-知到答案、智慧樹(shù)答案
- (圖文并茂)綠化工程施工組織設(shè)計(jì)
- 《居里夫人的故事》閱讀測(cè)試題及答案
- MOOC 生物醫(yī)學(xué)傳感器與測(cè)量-山東大學(xué) 中國(guó)大學(xué)慕課答案
- 上海市民辦華育中學(xué)2022-2023學(xué)年六年級(jí)上學(xué)期期末科學(xué)試卷
- 食品安全與衛(wèi)生智慧樹(shù)知到期末考試答案2024年
評(píng)論
0/150
提交評(píng)論