나는 C#을 사용하여 비행기를 만들고있다. 나는 비행기를 얻는다. 그러나 삼각형이 제대로 연결되지 않는 것 같아서 왜 작동하지 못합니다. 당신이 그림에서 볼 수 있듯이 내가 할 수있는 것보다비행기를 하나 만들면 삼각형이 제대로 보이지 않는다.
은 그것을 더 잘 설명합니다.
필자는 잘 모르겠지만이 문제는 내 색인에 불과하다고 생각합니다.
나는 또한 거기에없는 삼각형이있을 것이라고 생각한다. 그래서 내 배열은 어떤 이유로도 작다고 생각한다.
Mesh CreatePlane(int width, int depth)
{
Mesh m = new Mesh();
int numVert=(width+1)*(depth+1);
Vector3[] vertecies = new Vector3[numVert];
Vector2[] uvs = new Vector2[numVert];
int[] triangles = new int[width*depth*6];
float uvx = 1.0f/width;
float uvy = 1.0f/depth;
int index = 0;
for (int i = 0;i<width;i++)
{
for(int j = 0;j<depth;j++)
{
vertecies[index] = new Vector3(i,0,-j);
uvs[index++] = new Vector2(j*uvx,i*uvy);
}
}
index = 0;
for(int j=0; j<depth; j++)
{
for(int i=0; i<width; i++)
{
triangles[index++] = (j * (width+1)) + i;
triangles[index++] = ((j+1) * (width+1)) + i;
triangles[index++] = (j * (width+1)) + i + 1;
triangles[index++] = ((j+1) * (width+1)) + i;
triangles[index++] = ((j+1) * (width+1)) + i + 1;
triangles[index++] = (j * (width+1)) + i + 1;
}
}
m.name = "ScriptPlane";
m.vertices = vertecies;
m.uv = uvs;
m.triangles = triangles;
m.RecalculateNormals();
return m;
}
질문 제목에 사용 된 언어에 대한 정보가 없으면 이해할 수없는 정보를 포함하지 마십시오. 태그는 이러한 용도로 사용됩니다. –