这里是生成三角形的代码,顶点是直接从文件中加载的:
int n = 10;
Vector3[] vertices = new Vector3[n * 2];
int vC = 0;
int[] tri = new int[6 * (n - 1)];
int tC = 0;
for(int i=0;i<2*(n-1);i++)
{
if(i%2==0)
{
tri[tC++] = i;
tri[tC++] = i + 2;
tri[tC++] = i + 1;
}
else
{
tri[tC++] = i;
tri[tC++] = i + 1;
tri[tC++] = i + 2;
}
}
从文件中加载顶点。
这是结果:
tri 0 2 1
tri 1 2 3
tri 2 4 3
tri 3 4 5
tri 4 6 5
tri 5 6 7
tri 6 8 7
tri 7 8 9
tri 8 10 9
tri 9 10 11
tri 10 12 11
tri 11 12 13
tri 12 14 13
tri 13 14 15
tri 14 16 15
tri 15 16 17
tri 16 18 17
tri 17 18 19
顶点(1707.8,0.0,1707.8)
顶点(1708.0,0.0,1708.0)
顶点(1708.1,0.0,1708.1)
顶点(1707.8,0.0,1707.8)
顶点(1707.8,0.0,1707.8)
顶点(1708.1,0.0,1708.1)
顶点(1708.2,0.0,1708.2)
顶点(1707.8,0.0,1707.8)
顶点(1708.1,0.0,1708.1)
顶点(1708.0,0.0,1708.0)
顶点(1708.1,0.0,1708.1)
顶点(1708.2,0.0,1708.2)
顶点(1708.2,0.0,1708.2)
顶点(1708.2,0.0,1708.2)
顶点(1708.0,0.0,1708.0)
顶点(1708.6,0.0,1708.6)
顶点(1708.5,0.0,1708.5)
顶点(1708.2,0.0,1708.2)
顶点(1708.5,0.0,1708.5)
顶点(1708.4,0.0,1708.4)
谁能告诉我为什么它没有渲染任何东西。