将 2D 仿射变换矩阵转换为 3D 仿射变换矩阵
我的代码中有一个错误,想知道这是否不正确。
我的代码中有一个 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 |
当我对 2D 矩阵使用单位矩阵时,它会起作用,但是一旦我对 2D 矩阵应用任何变换,所有绘制的对象都会消失。
对于使用 3D 进行 2D 绘图,我使用此投影矩阵:
_basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1);
What is the right way totransform the 2D matrix to 3D?
I have a bug somewhere in my code, was wondering if this is incorrect.
I have a 2D view matrix in my code, but to display my world to the screen I need to convert the 2D view matrix to a 3D one. This is the process that I am using:
| 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 |
It works when I use an identity matrix for the 2D matrix, but as soon as I apply any transforms to the 2D matrix all my objects being drawn disappear.
For drawing in 2D using 3D, I use this projection matrix:
_basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1);
What is the correct way to transform the 2D matrix to 3D?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仿射变换使用变换矩阵的额外行/列进行平移。所以我认为你想要做的是将最后一行/列向下/向右移动,然后对于新轴只需插入恒等转换。
我不确定,但至少尝试一下。
Affine transformations use the extra row/column of the transformation matrix for translation. So I think what you want to do is to move the last row/column down/right and then for the new axis simply insert the identity transformation.
I'm not sure, but give it a try at least.