Converting from World space to Camera space
Posted 06 December 2008 - 09:13 PM
I am trying to do some work for the University, but I am stuck. I would apperciate any help. (I'm not asking to some do it for me).
My problem is the following:
I have these values:
Target - that is the target point of the camera
Elevation - elevation angle in degrees
Azimuth - azimuth angle in degrees
Distance - distance beetween the camera/eye and the target
I have to generate a homogene 4x4 matrix wich transform from world space to camera space.
I tried to use some Formula that is:
x' = (-sin(azimuth);
y' = (-cos(azimuth)*sin(elevation);
z' = (cos(azimuth)*cos(elevation);
and the Matrix would be
but it is not working.
Does anyone know how a formula to implement, using these arguments, to generate a Matrix wich transform from world space to camera space?
Any help would be appreciated, I am really stuck.
Posted 06 December 2008 - 09:48 PM
Anyway, I think way to do this is to approach it as a sequence of transformations. To create an orbiting camera, you want to first translate so that the target point moves to the origin, then rotate so that the camera's view direction moves to the Z axis, then finally translate along the Z axis by the orbit radius so that the camera arrives at the origin.
You'll need to create a matrix for each of these, then multiply them together. The formulas for individual transformations are here. (Note that if you're using a row vector convention you'll need to transpose the matrices on that page.)
Posted 06 December 2008 - 10:27 PM
I am sorry, I forgot to mention that. It is really an Orbiting Camera.
And thank you for the spell correction, next time I will write it right.
And, finally, I will check this page.
thank you a lot for your help.
edit: it endeed worked.. thank you a lot.
Posted 08 December 2008 - 02:43 AM
What I need to do now, is get the X and Y axis from the camera and convert to World space coordinates in order to calculate the camera in a "strafe" view. (Strafe as in FPS game).
The calculation of the camera is already done, but how can I get the axis in the camera and transform it to world coordinates? I tried to get the first and second columns of the Modlel View Matrix and calculate with the inverse Matrix of the post above, but it didn't work. What I have as a strange camera that performs loops, or something. I need it to go up, down, strafe left and right.
Posted 08 December 2008 - 03:03 AM
Posted 08 December 2008 - 11:55 PM
Thank you again for your help.
What I did was: I calculated the World to Camera matrix, and used the first 2 columns, the first one for Left/Right movement and the second for up/down.
I didn't used the inverse, but, to have the same behavior, I had to negate the values in the vectors.
Thank you for your help.
I know that I am asking some stupid questions, but I am studying as an exchange student in Germany, so I am having some problems with the language and I can't understand the classes. Thank you again, it really helped me in my work!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users