0
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

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);
}
\$\endgroup\$
1
  • \$\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\$ Commented May 12, 2018 at 23:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.