I need to convert a 2D mouse coordinate to a 3D world coordinate based on a specific depth (it's for raycasting). I'm not directly using DirectX in C++, I'm using a proprietary language, but if you give me an answer in C++ or pseudocode (C++ preferred) I can convert it.
I have access to the world matrix, view matrix and projection matrix and a variety of matrix manipulation functions.
If it's necessary to multiply a vector4 by a matrix4, the only function I have available that takes both a vector4 and a matrix4 is transformVector4(vector4Source,matrix4Source)
. I'm not sure which order it multiplies them in, if that matters.
Any help would be much appreciated :) I've been working on this for hours and I just don't get 3D maths...
See Question&Answers more detail:os