First off, thanks to every who has helped explain things to me thus far.
I am stuck… Again.
Here are the 3 classes my camera movement depends upon.
Transform.cs
Camera.cs
ExampleInput.cs
Camera pan and zoom works until rotation is applied. The pan left-right should move along the camera’s view right axis, pan up-down is always along the Vector3.Up axis, and zoom should move along the camera’s view forward axis.
After rotating the camera (which I am sure I am not doing correctly) console output tells me that the camera’s view forward has changed, the pan zoom console’s output says it is moving along the correct now changed axis, but it doesn’t, it only moves along Vector3.Forward and Vector3.Right.
I am not sure how to properly tell my program to take one quaternion and then add a rotation to that quaternion from a another quaternion.
Since I was clueless on how to do that, I was originally trying to use Quaternion.CreateFromYawPitchRoll() but was getting gimble locked sometimes, and having my axis flipped other times, like the link @willmotil just gave me.
To solve this I did something similar to the code they use:
Matrix matrix = Matrix.CreateFromAxisAngle(camerasWorld.Up, MathHelper.ToRadians(radians));
LookAtDirection = Vector3.TransformNormal(LookAtDirection, matrix);
I handle rotation in the Transform class itself, as I need to be able to rotate more things than just a camera, and that code is in UpdateMatrix().
I also used to store a separate View matrix on the camera which would update itself to look in the same direction as the Transform.Forward direction, but that just resulted in two identical matrices, and there was no difference in my case from storing 2 identical matrices or just one, so I stuck with one.
I think the only problem is how I am applying rotation in the ExampleInput class. I think if someone could explain how to properly rotate there, things will work properly, but who knows, maybe I have some glaring errors elsewhere I just can not see.
I have searched online and to rotate form one quaternion the other I gathered that you had to Quaternion.Conjugate the first, then add the second, that didn’t work. Somewhere else said you could just Quaternion.Concatenate(From, To), but that didn’t work either.
Any ideas?
Thanks.
EDIT: I added a separate view matrix back in, and zooming along the forward axis works as intended, but panning left right is still locked to Vector3.Right axis…
All the examples I have been given are great if you lock the cameras freedom in one way or another, but don’t work at all if you are trying to make a fly cam like I am. A camera you can move about all axies, and flip 360 in all directions.
EDIT2: Turns out I was moving along the views right axis, not the transform’s right axis, now pan zoom works great. I need to figure out how to properly rotate now…
EDIT3: I stopped using the transform class all together and just added in a world matrix for the camera, camera now disappears when rotating, as opposed to not rotating the way I would like.