新华社视图矩阵 - 寻找解释新华社、矩阵、视图

2023-09-08 00:40:28 作者:等在十字路口

我有一些严重的无法理解在XNA视图矩阵。我来到pretty的远与所有其他部位因为我刚刚得知自己所需要的数学,我不希望使用内置的矩阵函数不理解他们做什么第一。

I'm having some serious trouble understanding the view matrix in XNA. I've come pretty far with all the other parts and since I've just learnt myself the required maths I don't want to use the built in Matrix-functions without understanding what they do first.

现在我明白了旋转,投影和翻译的基础知识,但我不能为我的生活了解视图矩阵工作在XNA。

Now I understand the basics of rotation, projection and translation but I can't for the life of me understand how the view matrix works in XNA.

从我收集的,视图矩阵应该改变世界,以它自己的空间。似乎是合理的,但在库中的Matrix.CreateLookAt方法是颇令人费解。

From what I've gathered, the view matrix should transform the "world" to it's own space. Seems reasonable, but the Matrix.CreateLookAt method in the library is quite puzzling.

我已经建立(通过检查哪些库函数输出),这两件code产生相同的结果:

I've established (through examining what the library function outputs) that these two pieces of code yield the same results:

Matrix view = Matrix.CreateReflection(new Plane(Vector3.UnitX, 0)) * Matrix.CreateReflection(new Plane(Vector3.UnitZ, 0)) * Matrix.CreateTranslation(Position);
// ..equals this if (Position = (0 0 -5), since LookAt "looks at" but the above just looks straight down Z)..
Matrix blah = Matrix.CreateLookAt(Position, Vector3.Zero, Vector3.UnitY);

为什么翻转X轴和Z轴?我想你应该根据摄像机旋转而旋转世界,但在相反的方向,然后按相同的量在相反方向平移世界

Why flip the X and Z axes? I thought you should rotate the world according to the cameras rotation, but in the opposite direction, and then translate the world by the same amount in the opposite direction.

或者是不作为转型都只是连接codeS的位置和摄像头的旋转的世界?

Or is the view matrix not used as a transformation at all but just encodes the position and rotation of the camera in the world?

推荐答案

视图矩阵变换场景进入视野空间。鉴于空间的虚拟相机是在原点,并期待在正z方向。有不同的方式来实现这一点,但最常见的是视图基质由一个平移和围绕每个轴三个旋转的。

The view matrix is transforming the scene into view space. In view space the virtual camera is at the origin and is looking in the positive z-direction. There are different ways to achieve this, but most commonly the view matrix consists of a translation and three rotations around each axis.

变换=翻译* *的rotationZ *将RotationY的rotationX

Transform = Translate * RotationZ * RotationY * RotationX

 
精彩推荐