freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于opengl動(dòng)態(tài)三維地形設(shè)計(jì)論文-資料下載頁(yè)

2024-11-08 00:54本頁(yè)面

【導(dǎo)讀】一個(gè)好的、優(yōu)秀的室外地形場(chǎng)景實(shí)時(shí)渲染技術(shù)在。保證實(shí)時(shí)性以外還能創(chuàng)造出非常逼真的虛擬自然環(huán)境。高出,要可以看見低的地方,所有有可能看見的。需要無(wú)限的場(chǎng)景數(shù)據(jù),當(dāng)然這是不可能的。所以如何保存這些地形數(shù)據(jù)成了首要的問題,但是在隨著存儲(chǔ)器成本迅速。下降的今天,這個(gè)問題已經(jīng)變的不是十分的突出。OpenGL/Direct3DSDK),這也是不可能。圖元的數(shù)量是以場(chǎng)景大小的平方的速。光考慮地形數(shù)據(jù),一個(gè)2048X2048的地形,如果不考慮減低細(xì)節(jié)程。這兩種API各自有各自的優(yōu)點(diǎn),這里使用的OpenGL完成的設(shè)計(jì)。它是由微軟一手樹立的3DAPI規(guī)范,微軟公司擁有該。自1996年發(fā)布以來(lái),Direct3D. 的具有3D圖形加速的主流顯示卡都對(duì)Direct3D提供良好的支持。是,由于平臺(tái)的局限性等原因,D3D應(yīng)用至今仍主要集中于游戲和多媒體方面,作站開發(fā)的IRISGL,在跨平臺(tái)移植過程中發(fā)展成為OpenGL。SGI等ARB成員以投票方式產(chǎn)生標(biāo)準(zhǔn),8月ARB批準(zhǔn)了版本,2020年7月24日通過版本。形,而是用的一種線性插值的辦法來(lái)形成自然連續(xù)的起伏地形。

  

【正文】 PSTR strName) { FILE *pFile = NULL。 pFile = fopen( strName, rb )。//二進(jìn)制模式讀取指定文件 if ( pFile == NULL ) { MessageBox(NULL, Can39。t find the height map!, Error, MB_OK)。 return。 } fseek(pFile,0,SEEK_END)。 long nLen = ftell(pFile)。 rewind(pFile)。 m_nMapSize = sqrt(nLen)。 if(m_pHeightMap) delete []m_pHeightMap。 m_pHeightMap = new BYTE[m_nMapSize*m_nMapSize]。//分配給 heightmap大小的空間 if(!m_pHeightMap) { MessageBox(NULL, Alloc memory error!, Error, MB_OK)。 return。 } int nRead = fread( m_pHeightMap, 1, m_nMapSize*m_nMapSize, pFile )。 int result = ferror( pFile )。 23 if (result) { MessageBox(NULL, Can39。t get data!, Error, MB_OK)。 } fclose(pFile)。 (m_nMapSize,m_nMapSize)。 m_nMapSize = m_nMapSize*m_nScale 1。 = m_nScale。 } 用來(lái)讀取擴(kuò)展名為 bmp 的紋理圖的函數(shù) LoadTexture(); 成員函數(shù) Height() 通過 X,Y 坐標(biāo)從高度圖數(shù)據(jù)索引中計(jì)算出相應(yīng)位置的高度值,公式為 index = (x + (y * arrayWidth))。 源代碼示例如下: int Terrain::Height(int X, int Y) { //確認(rèn)沒有超出數(shù)組的范圍 int x = int(X/m_nScale) % int(m_nMapSize/m_nScale)。 int y = int(Y/m_nScale) % int(m_nMapSize/m_nScale)。 if(x0||y0||x=m_nMapSize/m_nScale||y=m_nMapSize/m_nScale) return 0。 if(!m_pHeightMap) return 0。 //index = (x + (y * arrayWidth) )從緩沖區(qū)讀出高度值 return m_nScale/2*m_pHeightMap[x + int(y * m_nMapSize/m_nScale)]。 } 成員函數(shù) Render()繪制渲染地形。其中進(jìn) 行一系列的紋理和渲染設(shè)置, 接著進(jìn)行地形繪制: 標(biāo)記數(shù)組空間清零,即通過調(diào)用 Bit 類的 Reset()函數(shù)。 在細(xì)分標(biāo)記數(shù)組記錄需要細(xì)分的網(wǎng)格,通過調(diào)用成員函數(shù) Update()函數(shù) 根據(jù)細(xì)分標(biāo)記數(shù)組遞歸渲染網(wǎng)格,即通過調(diào)用成員函數(shù) RenderQuad()實(shí)現(xiàn),并計(jì)算出繪制的三角形的數(shù)量。 將繪制的三角形的數(shù)量以 %d Trigles形式輸出到屏幕 源代碼示例解釋如下: void Terrain::Render() { glActiveTextureARB(GL_TEXTURE0_ARB)。 glEnable(GL_TEXTURE_2D)。 glBindTexture(GL_TEXTURE_2D, ())。 24 //給目標(biāo)一個(gè)指定的紋理 glEnable(GL_TEXTURE_2D)。 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB)。 //設(shè)置紋理的外圍參數(shù) glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2)。 glBindTexture(GL_TEXTURE_2D, ())。 //約定多維紋理 glMatrixMode(GL_TEXTURE)。 glLoadIdentity()。 glScalef((float)32, (float)32, 1)。 glMatrixMode(GL_MODELVIEW)。 glEnable(GL_DEPTH_TEST)。 //無(wú)論繪制的先后,讓距離遠(yuǎn)的物體總在距離近的物體后面。 glCullFace(GL_FRONT)。 glEnable(GL_CULL_FACE)。//不渲染看不見的面 ()。 //細(xì)分標(biāo)記數(shù)組清 0(這里為了節(jié)約內(nèi)存,一個(gè)網(wǎng)格用一個(gè) bit 表示) Update((m_nMapSize1)/2,(m_nMapSize1)/2,(m_nMapSize1)/2,1)。 //在細(xì)分標(biāo)記數(shù)組記錄需要細(xì)分的網(wǎng)格 //根據(jù)細(xì)分標(biāo)記數(shù)組遞歸渲染網(wǎng)格 int nCount = RenderQuad((m_nMapSize1)/2,(m_nMapSize1)/2,( m_nMapSize1)/2)。 glActiveTextureARB(GL_TEXTURE1_ARB)。 glDisable(GL_TEXTURE_2D)。 glActiveTextureARB(GL_TEXTURE0_ARB)。 glDisable(GL_TEXTURE_2D)。 glDisable(GL_DEPTH_TEST)。 glDisable(GL_CULL_FACE)。 char sPrint[MAX_PATH]。 wsprintf(sPrint,%d Trigles,nCount)。 if(m_pText) m_pTextEditItem(m_nTextID,sPrint)。 } 成員函數(shù) RenDerQuad()是渲染網(wǎng)格的遞歸程序,其中步驟如下: 通過 Height()函數(shù)計(jì)算出網(wǎng)格中 5 個(gè)點(diǎn)的高度最大值與最小值。 通過 CubeInFrustum()函數(shù),判斷網(wǎng)格是不是在視野內(nèi)。 通過判斷細(xì)分標(biāo)記數(shù)組中的紀(jì)錄,當(dāng)需要細(xì)分時(shí),遞歸調(diào)用 RenDerQuad()渲染 4 個(gè)網(wǎng)格。 如果不需要細(xì)分,使用 glBegin() glEnd()其中進(jìn)行三角形繪制,為了 避免出現(xiàn)裂縫所以使用 RemedyTop(), RemedyRight(), RemedyBottom(), RemedyLeft 在四個(gè)方向上多畫三角形扇。 計(jì)算出三角形數(shù)量,并作為返回值輸出。 25 源代碼示例解釋如下: int Terrain::RenderQuad(int nXCenter,int nZCenter,int nSize) { int nCount = 0。 int nH0 = Height(nXCenter,nZCenter)。 int nH1 = Height(nXCenternSize,nZCenternSize)。 int nH2 = Height(nXCenter+nSize,nZCenternSize)。 int nH3 = Height(nXCenter+nSize,nZCenter+nSize)。 int nH4 = Height(nXCenternSize,nZCenter+nSize)。 //求網(wǎng)格 5 個(gè)點(diǎn)中高度最大和最小值 int nMax = nH0,nMin = nH0。 if(nMaxnH1)nMax = nH1。 if(nMaxnH2)nMax = nH2。 if(nMaxnH3)nMax = nH3。 if(nMaxnH4)nMax = nH4。 if(nMinnH1)nMin = nH1。 if(nMinnH2)nMin = nH2。 if(nMinnH3)nMin = nH3。 if(nMinnH4)nMin = nH4。 SIZE size。 = nSize。=(nMaxnMin)/2。 //如果此網(wǎng)格不在視野內(nèi),返回 if(!m_pFrustumCubeInFrustum(nXCenter,(nMax+nMin)/2,nZCenter,max(size.cx,))) return 0。 if((nXCenter,nZCenter))//需要細(xì)分 ,遞歸渲染 4 個(gè)子網(wǎng)格 { nCount += RenderQuad(nXCenternSize/2,nZCenternSize/2,nSize/2)。 nCount += RenderQuad(nXCenter+nSize/2,nZCenternSize/2,nSize/2)。 nCount += RenderQuad(nXCenter+nSize/2,nZCenter+nSize/2,nSize/2)。 nCount += RenderQuad(nXCenternSize/2,nZCenter+nSize/2,nSize/2)。 } else//渲染此網(wǎng)格 { glBegin( GL_TRIANGLE_FAN )。 SetTextureCoord(nXCenter,nZCenter)。 // center glVertex3i(nXCenter, nH0, nZCenter)。 SetTextureCoord(nXCenternSize,nZCenternSize)。 //left top glVertex3i(nXCenternSize,nH1 , nZCenternSize)。 //為了避免出現(xiàn)裂縫而多畫三角形扇(就是多加那些紅線) RemedyTop(nXCenter,nZCenter,nSize)。 SetTextureCoord(nXCenter+nSize,nZCenternSize)。 //right top glVertex3i(nXCenter+nSize, nH2, nZCenternSize)。 RemedyRight(nXCenter,nZCenter,nSize)。 26 SetTextureCoord(nXCenter+nSize,nZCenter+nSize)。 //right bottom glVertex3i(nXCenter+nSize, nH3, nZCenter+nSize)。 RemedyBottom(nXCenter,nZCenter,nSize)。 SetTextureCoord(nXCenternSize,nZCenter+nSize)。//left bottom glVertex3i(nXCenternSize, nH4, nZCenter+nSize)。 RemedyLeft(nXCenter,nZCenter,nSize)。 SetTextureCoord(nXCenternSize,nZCenternSize)。 //left top glVertex3i(nXCenternSize, nH1, nZCenternSize)。 glEnd()。 nCount += 4。//這里為求簡(jiǎn)單,計(jì)算渲染的三角形數(shù)目并不是十分準(zhǔn)確 ,比實(shí)際要小些 } return nCount。 } 成員函數(shù) CalcError() 用來(lái)計(jì)算誤差 (坡度 )。即計(jì)算某些點(diǎn)細(xì)分與不細(xì)分的高度值差的和。 源代碼示例解釋如下: inline int Terrain::CalcError(int nXCenter,int nZCenter,int nSize) { int nError = 0。 int nH0 = Height(nXCenter,nZCenter)。 int nH1 = Height(nXCenternSize,nZCenternSize)。 int nH2 = Height(nXCenter+nSize,nZCenternSize)。 int nH3 = Height(nXCenter+nSize,nZCenter+nSize)。 int nH4 = Height(nXCenternSize,nZCenter+nSize)。 nError += abs(Height(nXCenter,nZCenternSize)(nH1+nH2)/2)。 nError += abs(Height(nXCenter+nSize,nZCenter)(nH2+nH3)/2)。 nError += abs(Height(nXCenter,nZCenter+nSize)(nH3+nH4)/2)。 nError += abs(Height(nXCenternSize,nZCenter)(nH4+nH1)/2)。 nError +=abs(Height(n
點(diǎn)擊復(fù)制文檔內(nèi)容
研究報(bào)告相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1