1

我正在使用带有 C# 的 XNA,并且我正在尝试创建一种基于顶点的图形系统。所以到目前为止我有以下代码

public class vertex {
    private Vector2 position;
    private Color color;

    public vertex(Vector2 position, Color color) {
        this.position = position;
        this.color = color;
    }

    public Vector2 Position {
        get { return position; }
        set { position = value; }
    }

    public Color Color {
        get { return color; }
        set { color = value; }
    }
}

public class mesh {
    private vertex[] vertecies;

    public mesh(int vertecies) {
        this.vertecies = new vertex[vertecies];
        for (int i = 0; i < vertecies; i++)
            this.vertecies[i] = new vertex(Vector2.Zero, Color.White);
    }

    public vertex[] Vertecies {
        get { return vertecies; }
        set { vertecies = value; }
    }
}

然后我有这个功能可以在屏幕上呈现一个点

 private void RenderVertex(vertex v)
 {
     sb.Draw(world.blankTexture, v.Position, new Rectangle(1, 1, 2, 2), v.Color);
 }

现在我要创建的是一个名为 RenderMesh(mesh m) 的函数,它使用 RenderVertex(vertex v) 函数将给定的网格从点(顶点)中渲染出来。所以基本上我想找到网格顶点之间的每个点并用点填充它。有算法吗?还是我应该采取完全不同的方法。因为我试图让我的系统呈现和处理动态形状。所以请帮忙。谢谢阅读 :)

4

0 回答 0