WP7 y XNA - Cómo multiplicar RotationMatrix en modo horizontal

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?

¡Gracias por adelantado!

preguntado el 09 de marzo de 12 a las 13:03

1 Respuestas

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);

¡Espero que esto ayude!

respondido 11 mar '12, 16:03

The proper term you're looking for is conmutatividad. In other words, matrix multiplication does not commute. - Stephane Beniak

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.