我的代码中有一个错误,想知道这是不正确的.
我的代码中有一个2D视图矩阵,但要将我的世界显示在屏幕上,我需要将2D视图矩阵转换为3D视图矩阵.这是我正在使用的过程:
| a b c | | a b c 0 |
| d e f | => | d e f 0 |
| g h i | | g h i 0 |
| 0 0 0 1 |
Run Code Online (Sandbox Code Playgroud)
当我对2D矩阵使用单位矩阵时它起作用,但是一旦我将任何变换应用于2D矩阵,我绘制的所有对象都会消失.
对于使用3D绘制2D,我使用此投影矩阵:
_basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1);
Run Code Online (Sandbox Code Playgroud)
将2D矩阵转换为3D的正确方法是什么?