WP7&;XNA-如何在横向模式下乘以RotationMatrix

本文关键字:模式 横向 RotationMatrix amp XNA- WP7 | 更新日期: 2023-09-27 18:27:19

我支持WindowsPhone页面的纵向和横向模式,在该页面中我结合了silverlight和XNA。

为了在人像模式下将RotationMatrix放入XNA坐标系,我将矩阵绕x轴旋转90°,如下所示:

viewMatrix = Matrix.CreateRotationX(MathHelper.PiOver2) * motion.CurrentValue.Attitude.RotationMatrix;

RotationMatrix似乎在横向模式下随页面一起旋转。我试着额外地围绕z轴旋转矩阵。至少我的物体显示正确,但俯仰/偏航是混合的。

viewMatrix = (Matrix.CreateRotationZ(MathHelper.PiOver2) * (Matrix.CreateRotationX(MathHelper.PiOver2) * motion.CurrentValue.Attitude.RotationMatrix));

在横向模式下,我必须如何乘以RotationMatrix才能获得正确的值?

提前感谢!

WP7&;XNA-如何在横向模式下乘以RotationMatrix

矩阵乘法是顺序敏感的(对不起,我不知道它在英语中是怎么叫的)。首先,使用姿态矩阵来确定场景的方向,然后可以将变换后的场景绕Z轴旋转90°。由于我的英语知识渊博,我不知道如何更清楚地解释这一点,所以试试这个:

viewMatrix = motion.CurrentValue.Attitude.RotationMatrix * Matrix.CreateRotationZ(MathHelper.PiOver2);

希望这能有所帮助!