我有一个小的代码库,你可以在我当前提交的 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);
}