3D Camera looking at arbitrary point, but never rolling to do so
Posted
by
Nektarios
on Stack Overflow
See other posts from Stack Overflow
or by Nektarios
Published on 2010-12-29T07:11:03Z
Indexed on
2010/12/29
7:54 UTC
Read the original article
Hit count: 221
(In C#/XNA 4.0)
I have Vector3 cameraPosition, Vector3 targetPosition
I want to have my camera look at the target, always 'facing' it, but never rolling
So roll always is neutral, to view the target the camera always either adjusts pitch or yaw
I've tried countless combinations of methods and information I find here and on the web but I haven't found anything that works properly. I think my issue may be my 'Up' vector (which I've tried .Up, 1,0,0, 0,1,0, 0,0,1)
When I move my camera I do:
CameraPosition += moveSpeed * vectorToAdd;
UpdateViewMatrix();
UpdateViewMatrix() is.. well, I've tried everything I have seen. At most simple...
View = Matrix.CreateLookAt(CameraPosition, targetPosition, upVector);
Where upVector has been Vector3.Up, 1, 0, 0; 0, 1, 0; 0, 0, 1, or other more 'proper' attempts to get my actual up vector. This sounds like it's probably my problem..
This should be dead simple, help!
© Stack Overflow or respective owner