Rotation for camera, cross product flipping
by Michael Bacon · in Technical Issues · 09/17/2007 (6:46 am) · 1 replies
I am using MathUtils::createOrientFromDir to create my camera orientation matrix.
I am having the trouble that while I am rotating my camera if my look at point becomes behind my camera (due to looking at an extreme angle) relative to world Up (0,0,1) (which is used in the above mentioned function to calculate the matrix). My right vector flips orientation. This gives the effect that when I look to far up or down the camera suddenly flips its orientation.
If I can detect this I can fix it by using (0,0,-1) as the world up vector instead this will correct the direction of the right vector in this scenario but may break when looking STRAIGHT up I may need another solution for that.
I am having the trouble that while I am rotating my camera if my look at point becomes behind my camera (due to looking at an extreme angle) relative to world Up (0,0,1) (which is used in the above mentioned function to calculate the matrix). My right vector flips orientation. This gives the effect that when I look to far up or down the camera suddenly flips its orientation.
If I can detect this I can fix it by using (0,0,-1) as the world up vector instead this will correct the direction of the right vector in this scenario but may break when looking STRAIGHT up I may need another solution for that.
Torque Owner Michael Bacon
Default Studio Name
I took the Dot product between the target object's forward vector and the camera's direction vector. When this became less than 0 I inverted the Up vector.
This works except when I look straight up!
Then I realized that I already have my right vector (in the target object's transform) so I don't need to calculate it. Hence I can use my forward and right to calculate my up rather than going the long way around...