I have an issue with roll/rotation. I have a Camera defined to move along X and Y axis at a given Z for zoom. The camera is always pointed straight down the Z axis so there is not any yaw or pitch. I do however need to roll or rotate. The problem I have is that when I roll/rotate left or right I am modifying up in the view. So, when the mouse or keyboard are moved up toward the top, the target actually moves toward the new up. If I rotate 90 right degrees when I move mouse up or arrow up it moves right. I fully understand why it is behaving this way. I need to find a way to make it not behave that way. I need to roll/rotate independent of x, y. My first thought is to use the view when moving camera along x and y. Then rotate the target (1-9 quads) in the world space. Any thoughts on this? Any Examples would help and would be greatly appreciated.
1 Answer
\$\begingroup\$
\$\endgroup\$
1
I found a solution. I added a world matrix and moved the rotation to the world. This corrected the mouse panning issue. I Still need to roll on the local mouse location. However, this was the answer to the post.
//Mouse
protected override void Roll(Vector2 mousePosition)
{
var normalizedMousePosition = mousePosition.Normalize(ViewportSize);
var screenDelta = normalizedMousePosition - LastMousePosition;
LastMousePosition = normalizedMousePosition;
RotationAngle += screenDelta.X;
UpdateWorld();
}
//Keyboard Q/E
protected override void KeyRoll(float angle)
{
angle *= RotationScaler;
RotationAngle += angle;
UpdateWorld();
}
protected override void UpdateWorld()
{
var zRotation = Matrix.RotationZ(RotationAngle);
World = Matrix.Transpose(zRotation);
}
-
\$\begingroup\$ Hey, I noticed that this answer has not been accepted yet but answers your issue. If you get the chance, you should consider accepting it :) \$\endgroup\$2018-05-12 23:59:10 +00:00Commented May 12, 2018 at 23:59