我的代码库很小,你可以在my current commit on GitHub看到完整的代码。我将尝试将相关代码放在这里。基本上,如果我移动一个改变World矩阵的三角形Position
,它就会变得不可见。有什么想法吗?
GraphicsDevice.RasterizerState.CullMode = CullMode.None;
this.vertices = new[]
{
new VertexPositionColor(new Vector3(1.0f, -1.0f, 0.0f), color),
new VertexPositionColor(new Vector3(-1.0f, -1.0f, 0.0f), color),
new VertexPositionColor(new Vector3(0.0f, 1.0f, 0.0f), color)
};
this.effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
device.Viewport.AspectRatio, 0.001f, 50.0f);
this.effect.View = Matrix.CreateLookAt(Position, Vector3.Down, Vector3.Forward);
this.effect.World = Matrix.CreateTranslation(entity.Position);
foreach (var pass in this.effect.CurrentTechnique.Passes)
{
pass.Apply();
this.device.DrawUserPrimitives(PrimitiveType.TriangleList, this.vertices,
0, 1);
}
答案 0 :(得分:1)
问题最终导致我的远剪辑太靠近我绘制三角形的位置了(我正在绘制远剪辑)。
简单!