gpt4 book ai didi

c++ - 使用 C++ 和 directx 创建地形

转载 作者:行者123 更新时间:2023-11-28 07:43:03 25 4
gpt4 key购买 nike

<分区>

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;这是创建 4*3 地形的代码,其中 z 为 0*

任何人都可以向我简要解释这段代码,在此先感谢..

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com