本文整理汇总了C#中Loader.loadToVao方法的典型用法代码示例。如果您正苦于以下问题:C# Loader.loadToVao方法的具体用法?C# Loader.loadToVao怎么用?C# Loader.loadToVao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader.loadToVao方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generateTerrain
private RawModel generateTerrain(Loader loader)
{
int count = VERTEX_COUNT * VERTEX_COUNT;
float[] vertices = new float[count * 3];
float[] normals = new float[count * 3];
float[] textureCoords = new float[count * 2];
int[] indices = new int[6 * (VERTEX_COUNT - 1) * (VERTEX_COUNT - 1)];
int vertexPointer = 0;
for (int i = 0; i < VERTEX_COUNT; i++)
{
for (int j = 0; j < VERTEX_COUNT; j++)
{
vertices[vertexPointer * 3] = (float)j / ((float)VERTEX_COUNT - 1) * SIZE;
vertices[vertexPointer * 3 + 1] = 0;
vertices[vertexPointer * 3 + 2] = (float)i / ((float)VERTEX_COUNT - 1) * SIZE;
normals[vertexPointer * 3] = 0;
normals[vertexPointer * 3 + 1] = 1;
normals[vertexPointer * 3 + 2] = 0;
textureCoords[vertexPointer * 2] = (float)j / ((float)VERTEX_COUNT - 1);
textureCoords[vertexPointer * 2 + 1] = (float)i / ((float)VERTEX_COUNT - 1);
vertexPointer++;
}
}
int pointer = 0;
for (int gz = 0; gz < VERTEX_COUNT - 1; gz++)
{
for (int gx = 0; gx < VERTEX_COUNT - 1; gx++)
{
int topLeft = (gz * VERTEX_COUNT) + gx;
int topRight = topLeft + 1;
int bottomLeft = ((gz + 1) * VERTEX_COUNT) + gx;
int bottomRight = bottomLeft + 1;
indices[pointer++] = topLeft;
indices[pointer++] = bottomLeft;
indices[pointer++] = topRight;
indices[pointer++] = topRight;
indices[pointer++] = bottomLeft;
indices[pointer++] = bottomRight;
}
}
return loader.loadToVao(vertices, textureCoords, normals, indices);
}