简体   繁体   English

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

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

I support Portrait and Landscape-Mode for the WindowsPhone-page where I combine silverlight and XNA. 我在结合Silverlight和XNA的WindowsPhone页面上支持纵向和横向模式。

In order to get the RotationMatrix into the XNA coordinate-system in portrait-mode I rotate the matrix 90° around the x-axis like this: 为了使RotationMatrix以纵向模式进入XNA坐标系,我将矩阵绕x轴旋转90°,如下所示:

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

The RotationMatrix seems to rotate with the page in landscape-mode. RotationMatrix似乎随着页面在横向模式下一起旋转。 I tried to rotate the matrix around the z-axis additionaly. 我试图绕z轴附加旋转矩阵。 At least my objects are displayed correct, but the pitch/yaw is mixed up. 至少我的对象显示正确,但是俯仰/偏航混合在一起。

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

How do I have to multiply the RotationMatrix in order to get correct values in landscape-mode? 如何在横向模式下乘以RotationMatrix以获得正确的值?

Thank's in advance! 提前致谢!

Matrix multiplication is order sensitive (sorry, I don't know how it's called in english). 矩阵乘法是阶数敏感的(抱歉,我不知道它的英文称呼)。 First, use the attitude matrix to orient the scene, and after that you can rotate the transformed scene by 90° around the Z axis. 首先,使用姿态矩阵对场景进行定向,然后可以将变换后的场景绕Z轴旋转90°。 With my great knowledge of English, I don't know how to explain this more clearly, so just try this: 凭借我对英语的丰富了解,我不知道如何更清楚地解释这一点,所以请尝试以下操作:

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

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM