Understanding view matrix I've been reading several sources in the web about transforming world-space points into camera-space ones.
I am building my view-matrix from the following parameters

1. Camera position
2. Point the camera is looking at
3. Up vector


I perfectly understand the meaning of each of the parameters, however, there are still some doubts.


How is the direction vector built? We have camera position and lookat position, is it camPos-lookatPos or lookatPos-camPos? In other words, does the direction vector aligns with (goes in the same direction of) the world +z-axis or is opposite to it? Direction is a bit confusing since it makes me think it goes the direction the camera lens is pointing to.
What's the reasoning behind translating the camera to the origin? How does this simplifies math?


My view matrix looks like follows

$$V = \begin{matrix}
  Rx &amp; Ry &amp; Rz &amp; 0 \\
  Ux &amp; Uy &amp; Uz &amp; 0 \\
  Fx &amp; Fy &amp; Fz &amp; 0 \\
  -CamPosx &amp; -CamPosy &amp; -CamPosz &amp; 1
 \end{matrix}$$


Will this V matrix convert from camera to world or from world to camera coordinates? How can I understand which direction it is going?
There is no relation between direction's direction and the world axis. And that's fortunate otherwise it would mean your camera is not a free view, it's some kind of a axis bound camera, which has its usages but most likely nothing in your mind right now.

The default camera matrix is looking at +z when everything is Identity, that's most surely where you got confused. Know that this is purely a convention, but sticking to a widely adopted convention allows for easy compatibility with libraries like glm.

the direction vector goes outward, so its normalize(lookat - campos). 

The view matrix can be constructed directly with TBN vectors in rows 0 1 2 :)
(that's your RUF)

Point 2. There is no translating of the camera to the origin, that's just how you chose to view (pun) it. There is translation of world objects toward the origin. Because the rasterizer will work in device coordinates (NDC) which is not configurable, so having a roaming camera (that travels) makes it necessary to indicate its translation in world as part of the last row (row 3), and in reverse since it's not a world matrix representing the camera position, it's the matrix that will bring back points into the view space. (by the way, incidentally meaning the actual camera world matrix is the inverse of the view matrix).


oh, that was the last phrase of pt 2.