2

我正在尝试使用 3D 原语DrawUserPrimitives和在 Monogame(适用于 Windows8)上绘制一个简单的彩色矩形VertexPositionColor,但我唯一能看到的是一个覆盖屏幕上半部分的矩形,如下面的屏幕截图所示。绘制三角形时也会发生这种情况。

截屏

这是我的代码:

// camera code
Camera.Position = new Vector3(0, 1500, 0);
Camera.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), GraphicsDevice.Viewport.AspectRatio, 1, 5000);
Camera.View = Matrix.CreateLookAt(Camera.Position, Vector3.Down, Vector3.Forward); 

VertexPositionColor[] vertexList = new VertexPositionColor[4]; 
BasicEffect basicEffect;  
VertexBuffer vertexBuffer;

// initializations
vertexList[0] = new VertexPositionColor(new Vector3(-957, 10, -635), Color.Red);  
vertexList[1] = new VertexPositionColor(new Vector3(957, 10, -635), Color.Lime);  
vertexList[2] = new VertexPositionColor(new Vector3(-957, 10, 635), Color.Yellow);  
vertexList[3] = new VertexPositionColor(new Vector3(957, 10, 635), Color.Blue);

vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), 4, BufferUsage.WriteOnly);  
vertexBuffer.SetData<VertexPositionColor>(vertexList);

basicEffect = new BasicEffect(GraphicsDevice);  
basicEffect.VertexColorEnabled = true;  
basicEffect.LightingEnabled = false;  
basicEffect.Projection = Camera.Projection;

// draw code
GraphicsDevice.RasterizerState = RasterizerState.CullNone;
GraphicsDevice.SetVertexBuffer(vertexBuffer);

foreach (EffectPass p in basicEffect.CurrentTechnique.Passes)
{
   p.Apply();
   GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vertexList, 0, 2);
}

如您所见,我为所有四个顶点使用了不同的颜色,但程序实际上似乎只绘制了其中两个:vertexList[0]vertexList[1]. 有什么建议吗?怎么了?

4

1 回答 1

3

我想你不见了

basicEffect.View = Camera.View;
于 2013-08-13T00:21:53.627 回答