Okay, in the custom geometry tutorial the problem is solved with vertex shifting. I solved the problem by making the vertex positions -50, 50 instead of 0, 100. But I don’t know how to do this in projected grid.
Can someone tell me how to shift vertexes in these codes?
public Mesh CreateQuad(int numVertsX, int numVertsY)
{
Vector3[] vertices = new Vector3[numVertsX * numVertsY];
Vector2[] texcoords = new Vector2[numVertsX * numVertsY];
int[] indices = new int[numVertsX * numVertsY * 6];
for (int x = 0; x < numVertsX; x++)
{
for (int y = 0; y < numVertsY; y++)
{
Vector2 uv = new Vector3(x / (numVertsX - 1.0f), y / (numVertsY - 1.0f));
texcoords[x + y * numVertsX] = uv;
vertices[x + y * numVertsX] = new Vector3(uv.x, uv.y, 0.0f);
}
}
int num = 0;
for (int x = 0; x < numVertsX - 1; x++)
{
for (int y = 0; y < numVertsY - 1; y++)
{
indices[num++] = x + y * numVertsX;
indices[num++] = x + (y + 1) * numVertsX;
indices[num++] = (x + 1) + y * numVertsX;
indices[num++] = x + (y + 1) * numVertsX;
indices[num++] = (x + 1) + (y + 1) * numVertsX;
indices[num++] = (x + 1) + y * numVertsX;
}
}
//mesh.UpdateMesh here
}
EDIT: Here is the solution:
vertices[x + y * numVertsX].X -= 0.5f;
vertices[x + y * numVertsX].Y -= 0.5f;