簡體   English   中英

WP7和XNA-如何在橫向模式下乘以RotationMatrix

[英]WP7 & XNA - How to multiply RotationMatrix in Landscape mode

我在結合Silverlight和XNA的WindowsPhone頁面上支持縱向和橫向模式。

為了使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以獲得正確的值?

提前致謝!

矩陣乘法是階數敏感的(抱歉,我不知道它的英文稱呼)。 首先,使用姿態矩陣對場景進行定向,然后可以將變換后的場景繞Z軸旋轉90°。 憑借我對英語的豐富了解,我不知道如何更清楚地解釋這一點,所以請嘗試以下操作:

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

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM