Created
December 5, 2018 00:55
-
-
Save baobao/4759b5773de6cc8bcd4683bb1b38dd1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 開始Index番号 | |
int startIndex = indices[1]; | |
// 天面、底面を除いたIndex要素数 | |
int sideIndexLen = divideX * (divideY - 2) * 2 * 3; | |
int lap1stIndex = 0; | |
int lap2ndIndex = 0; | |
// 一周したときのindex数 | |
int lapDiv = divideX * 2 * 3; | |
int createSquareFaceCount = 0; | |
for (int i = 0; i < sideIndexLen; i++) | |
{ | |
// 一周の頂点数を超えたら更新(初回も含む) | |
if (i % lapDiv == 0) | |
{ | |
lap1stIndex = startIndex; | |
lap2ndIndex = startIndex + divideX; | |
createSquareFaceCount++; | |
} | |
if (i % 6 == 0 || i % 6 == 3) | |
{ | |
indices[cnt++] = startIndex; | |
} | |
else if (i % 6 == 1) | |
{ | |
indices[cnt++] = startIndex + divideX; | |
} | |
else if (i % 6 == 2 || i % 6 == 4) | |
{ | |
if (i > 0 && | |
(i % (lapDiv * createSquareFaceCount - 2) == 0 || | |
i % (lapDiv * createSquareFaceCount - 4) == 0) | |
) | |
{ | |
// 1周したときのループ処理 | |
// 周回ポリゴンの最後から2番目のIndex | |
indices[cnt++] = lap2ndIndex; | |
} | |
else | |
{ | |
indices[cnt++] = startIndex + divideX + 1; | |
} | |
} | |
else if (i % 6 == 5) | |
{ | |
if (i > 0 && i % (lapDiv * createSquareFaceCount - 1) == 0) | |
{ | |
// 1周したときのループ処理 | |
// 周回ポリゴンの最後のIndex | |
indices[cnt++] = lap1stIndex; | |
} | |
else | |
{ | |
indices[cnt++] = startIndex + 1; | |
} | |
// 開始Indexの更新 | |
startIndex++; | |
} | |
else | |
{ | |
Debug.LogError("Invalid : " + i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment