在C#中渲染2D网格

时间:2012-09-15 15:16:47

标签: c# xna geometry 2d vertex

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

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)函数渲染出点(椎体)的给定网格。所以基本上我想找到网格的椎体之间的每个点,并用点填充它。有算法吗?或者我应该采取完全不同的方法。因为我试图让我的系统渲染和处理动态形状。所以请帮忙。感谢阅读:)

0 个答案:

没有答案