I need to create an up vector for when the camera looks at any angle (except directly down or up because the up vector would be perpendicular to the y-axis).
The up vector has to be perpendicular to the line of sight of-course. When the line of sight isn’t along the y-axis, you can imagine a circle around the eye and the line of sight where the up vector could be. On this circle, there will be a point which goes further up the y-axis than any other point. This is what I want my up-vector to be.
I’m sure I can work out a solution but I’m guessing people would have done this plenty of times before and I want to have the most effective solution.
My camera, when using this at least, wont look directly down or up the y-axis so there is no problem there.
gluLookAtdoes not require that the up vector you provide be perpendicular to the direction you’re looking. So you can just use 0,1,0.If you really, really want to come up with a perpendicular vector, take a look at the man page for
gluLookAtand do what they’re doing to make u