0
我正在嘗試按照這個在線教程創建一些波 http://nehe.gamedev.net/tutorial/flag_effect_(waving_texture)/16002/。opengl中的旗幟效果
我想讓波形變得更大,但我不知道如果我正確地做了這件事,目前的四邊形網格在教程中大小爲45,所以我增加到了450,但是大小似乎並沒有增加太多。
有人可以指出我正確的方向,需要修改什麼使四邊形更大。
我正在嘗試按照這個在線教程創建一些波 http://nehe.gamedev.net/tutorial/flag_effect_(waving_texture)/16002/。opengl中的旗幟效果
我想讓波形變得更大,但我不知道如果我正確地做了這件事,目前的四邊形網格在教程中大小爲45,所以我增加到了450,但是大小似乎並沒有增加太多。
有人可以指出我正確的方向,需要修改什麼使四邊形更大。
如果您只是想讓這些四邊形更大,那麼您需要修改頂點位置代碼。在訥河教程張貼變化這一部分:
// Loop Through The X Plane
for(int x=0; x<45; x++)
{
// Loop Through The Y Plane
for(int y=0; y<45; y++)
{
// Apply The Wave To Our Mesh
points[x][y][0]=float((x/5.0f)-4.5f);
points[x][y][1]=float((y/5.0f)-4.5f);
points[x][y][2]=float(sin((((x/5.0f)*40.0f)/360.0f)*3.141592654*2.0f));
}
}
向該:
// Loop Through The X Plane
float spacing = 0.5f;
float spacingInv = 1.0f/spacing;
float offset = (45/spacingInv)/2.0f; // The 45 comes from the number of points (if you change this, change the for loop and the variable creation)
for(int x=0; x<45; x++)
{
// Loop Through The Y Plane
for(int y=0; y<45; y++)
{
// Apply The Wave To Our Mesh
// We change the x/5.0f-4.5f to change the size of the quads
// See text after for more details
points[x][y][0]=float((x/spacingInv)-offset);
points[x][y][1]=float((y/spacingInv)-offset);
points[x][y][2]=float(sin((((x/spacingInv)*40.0f)/360.0f)*3.141592654*2.0f));
}
}
說明: X/5.0F給你值0,0.2,0.4,0.6,0.8,1.0,。 .....,9.0。
如果你只是採取這些值,你現在會有一個偏心的四邊形網格。現在採取x/5.0f - 4.5f給你的值-4.5 -4.3,-4.1,...... 4.1,4.3,4.5
如果你想使得四邊形更大,你需要增加間距點之間(即將x/5.0f更改爲x/2.0f之類的東西(這就是我給出的例子中發生的情況))。然後你想要更新(即改變-4.5f)。
目前尚不清楚究竟應該做些什麼更大。波的幅度或頻率?四邊形數量?它們的大小? –
四邊形的尺寸,所以水面積更大 – user195257
只需在旋轉後用'glScalef'對其進行縮放即可。 –