I support Portrait and Landscape-Mode for the WindowsPhone-page where I combine silverlight and XNA.
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:
viewMatrix = Matrix.CreateRotationX(MathHelper.PiOver2) * motion.CurrentValue.Attitude.RotationMatrix;
The RotationMatrix seems to rotate with the page in landscape-mode. I tried to rotate the matrix around the z-axis additionaly. 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?
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. 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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.