http://www.riemers.net/eng/Tutorials/DirectX/C++/Series1/tut10.php
在链接中给出的地形创建教程中,我无法理解代码,基本上这段代码中发生了什么
short s_Indices[(WIDTH-1)*(HEIGHT-1)*3];
for (int x=0;x< WIDTH-1;x++){
for (int y=0; y< HEIGHT-1;y++) {
s_Indices[(x+y*(WIDTH-1))*3+2] = x+y*WIDTH;
s_Indices[(x+y*(WIDTH-1))*3+1] = (x+1)+y*WIDTH;
s_Indices[(x+y*(WIDTH-1))*3] = (x+1)+(y+1)*WIDTH;
}
}
short s_Indices[(WIDTH-1)*(HEIGHT-1)*6];
for (int x=0;x< WIDTH-1;x++){
for (int y=0; y< HEIGHT-1;y++) {
s_Indices[(x+y*(WIDTH-1))*6+2] = x+y*WIDTH;
s_Indices[(x+y*(WIDTH-1))*6+1] = (x+1)+y*WIDTH;
s_Indices[(x+y*(WIDTH-1))*6] = (x+1)+(y+1)*WIDTH;
s_Indices[(x+y*(WIDTH-1))*6+3] = (x+1)+(y+1)*WIDTH;
s_Indices[(x+y*(WIDTH-1))*6+4] = x+y*WIDTH;
s_Indices[(x+y*(WIDTH-1))*6+5] = x+(y+1)*WIDTH;
}
}
什么是 (x+y (WIDTH-1))*3+2] 以及为什么它等于 x+y*WIDTH;这是创建 z 为 0* 的 4*3 地形的代码
任何人都可以向我简要解释一下这段代码吗,在此先感谢..