lost
01-Dec-2003, 03:37
Hi, I am making a simple raytracer and am having troubles with setting up a camera position. First, let me say that I know my intersection functions are working properly and just my algorithm for creating a "camera" is not working properly.
I am inputting the camera position, where it is looking, and up vectors from a file (much like the gluLookAt function) and adding a FOV value. For his ray tracer I am having difficulty figuring out exactly how the camera should work.
For example, in a 640x480 window, with a FOV of 90 degrees, would the resulting vertical FOV only be 67.5 degrees?
My idea for a camera is something like this:
Figure out look at direction (camPosition-camLookAt)
Rotate the vector by the distance it is from the center times the cos of half the fov
trace the resulting vector
Is this a proper way of setting up a camera in this instance? The more I think, the more I believe that x=0 should be equivalent to cos(-fov/2) and y=0 should be equal to cos(fov/2) and then each unit moving would just add to those values.
Then the code would be (value x * camX vector + value y * camY vector + look direction) I am thinking then it might need to be multiplied by the camZ vector but not sure.
Then the resultant vector should be normalized and point in the correct direction.
Blah, I am rambling, but nothing Ive tried has worked, anyone have any ideas or relevant links? Thanks
I am inputting the camera position, where it is looking, and up vectors from a file (much like the gluLookAt function) and adding a FOV value. For his ray tracer I am having difficulty figuring out exactly how the camera should work.
For example, in a 640x480 window, with a FOV of 90 degrees, would the resulting vertical FOV only be 67.5 degrees?
My idea for a camera is something like this:
Figure out look at direction (camPosition-camLookAt)
Rotate the vector by the distance it is from the center times the cos of half the fov
trace the resulting vector
Is this a proper way of setting up a camera in this instance? The more I think, the more I believe that x=0 should be equivalent to cos(-fov/2) and y=0 should be equal to cos(fov/2) and then each unit moving would just add to those values.
Then the code would be (value x * camX vector + value y * camY vector + look direction) I am thinking then it might need to be multiplied by the camZ vector but not sure.
Then the resultant vector should be normalized and point in the correct direction.
Blah, I am rambling, but nothing Ive tried has worked, anyone have any ideas or relevant links? Thanks