【发布时间】:2020-11-01 06:31:34
【问题描述】:
我正在尝试为 monogame 创建一个渲染库,目前正在绘制 2D 多边形。但是,这些职位没有任何意义。不知何故,在 (0, 0, 0)、(100. 0, 0)、(0, 100, 0) 和 (100, 100, 0) 处绘制它们不会到达左上角坐标 (0, 0) )。我该如何解决这个问题?
我的代码:
BasicEffect basicEffect = new BasicEffect(GraphicsDevice);
VertexPositionColor[] vert = new VertexPositionColor[4];
vert[0].Position = new Vector3(0, 0, 0);
vert[1].Position = new Vector3(100, 0, 0);
vert[2].Position = new Vector3(0, 100, 0);
vert[3].Position = new Vector3(100, 100, 0);
short[] ind = new short[6];
ind[0] = 0;
ind[1] = 2;
ind[2] = 1;
ind[3] = 1;
ind[4] = 2;
ind[5] = 3;
foreach (EffectPass effectPass in basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
PrimitiveType.TriangleList, vert, 0, vert.Length, ind, 0, ind.Length / 3);
}
【问题讨论】: