There are different ways of computing the view matrix. Yes, you can just use d3d_set_projection_ext at any time, and then from that you can get the view matrix with:
view_matrix = matrix_get(matrix_view);
Yes, the camera's aspect ratio should be -750/1334. Presuming that 750 is the width of your render target, and 1334 is the height. (make sure you haven't got that the other way around). However, I did suggest maybe it would be better after all to use a positive aspect ratio, and simply put the camera at a +z position instead of -z. The original rational for looking from -z and using a negative aspect ratio was that I was worried that if the camera was on the opposite side of the xy plane (at a +z position) that it might change the way in which certain 2d things would appear to be drawn. But after thinking about it for a while, I'm not sure that makes sense, so I would suggest use a positive aspect ratio, and put the camera at a +z position. This way, we won't need to remember that we've used a negative aspect ratio, and we won't have to worry about the effects that it will have, such as reversing texture orientation, and flipping backface culling.
The camera's field of view (fov) is the angular size of the vertical axis of your perspective projection. So in the d3d_set_projection_ext function call that you posted above, you used 30 degrees for the fov argument. In the mouse vector script, "f" is dtan(camera_fov/2), where camera_fov should be the same value you provided as the fov argument to d3d_set_projection_ext.
the camera's z position should have the same value as the "z from" argument provided to the d3d_set_projection_ext function.
You don't need to normalize the mouse vector for this function, but if you wanted to do it for other reasons, normalizing any vector is simple. All you have to do is divide each component of the vector by the length of the vector. So for example, say you had the vector (a,b,c). length=sqrt(a*a+b*b+c*c); And to normalize: a/=length; b/=length; c/=length;
----------------------------------------------------------------------------------------------------------------------------------------
You don't need to really know the following section in order to get things working, so just ignore it if you aren't interested.
The view matrix is stored as a 1d array of 16 elements in gml, hence v[0], v[3], etc....
However it is better to think of it as if it were mapped out as a 4x4 matrix:
Code:
0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15
In that diagram the number indicates the array index.
Ignore the rightmost column and the bottommost row for now, and just look at the upper 3x3 section of that matrix.
Encoded into that section of the matrix is the orientation of the camera.
The top row (0,4,8) is the xaxis, and is a vector which points to the camera's right (or left if you've used a negative aspect-ratio to flip coordinate systems).
The middle row (1,5,9) is the yaxis and is a vector which points the the camera's top.
And the bottom row (2,6,10) is the zaxis and is a vector which points forward toward whatever the camera is looking directly at.
All we're doing is taking the mouse vector in view space (x,y,1), and then using the transpose of that 3x3 section of the view matrix, to rotate the vector into world space. Normally, a view matrix would be used to transform things from world space to view space. But the transpose of a rotation matrix encodes a rotation in the opposite direction. So by multiplying the column vector (x,y,1) by the transpose of that part of the view matrix, we are bringing the mouse vector from view space into world space. The transpose of a matrix is just swapping rows for columns.
If you want to know how the x, y, and z axes are computed from the "from", "to" and "up" arguments provided to d3d_set_projection_ext, have a look here:
zaxis = normalize(cam_to - cam_from)
xaxis = normalize(cross(cam_up, zaxis))
yaxis = cross(zaxis, xaxis)
To normalize a vector is to divide each component of a vector by the length of the vector. The result is to change the vector into a vector that still points in the same direction, but has a length equal to 1.
The "cross" product of two vectors is computed like this:
c = cross(a,b) =
cx = ay*bz - az*by
cy = az*bx - ax*bz
cz = ax*by - ay*bx
----------------------------------------------------------------------------------------------------------------------------------------