ThePointingMan, on 04 Apr 2013 - 19:44, said:
Firstly, thankyou very much Slice4Ever andEndurion, you two have been a great help. I'm still having a wee bit of trouble with the Unproject function though. D3d's unproject looks like this
D3DXVECTOR3* D3DXVec3Unproject(
_Inout_ D3DXVECTOR3 *pOut,
_In_ const D3DXVECTOR3 *pV,
_In_ const D3D10_VIEWPORT *pViewport,
_In_ const D3DXMATRIX *pProjection,
_In_ const D3DXMATRIX *pView,
_In_ const D3DXMATRIX *pWorld
);
As far as I can tell I should be putting the vector holding the mouse co-ords for pV,
the projection matrix and view matrix in their places,
but I'm unsure as to what I should be putting in the ViewPort section and pWorld. Honestly I don't even fully understand what a view port is!
Edit: Alright, funny that trying to setup the mouse would teach me so much about the camera, at one point I ended up accidentally turning my level editor into a first person shooter! Minus the bullets of course :/ I understand what the view port is now, all is good! Thank you all for your help! For others who may come across this issue, here is something that helped me out a bit. an example of what this should look like using directx's functions http://gamedev.stackexchange.com/questions/44364/zooming-into-mouse-position and MSDN's page on viewports http://msdn.microsoft.com/en-ca/library/windows/desktop/bb206341(v=vs.85).aspx
Edit*2: I have noticed one slight error though, I remember dealing with this with my last project but I don't quite remember how. The WS style SYSMENU includes a little bar at the top of the screen, and this is interfering with my mouse position, does anyone know of any ways to work around this?
In old openGL(i.e. 1.1/2.0) the view matrix was called the modelview matrix, which combines both the model matrix, and the view matrix. from my understanding of that function, it expects the view matrix(your camera matrix) is separate from the model(or world) matrix.
the viewport(as you've discovered), is simply the actual window rectangle that your world is drawn into, it's useful for making split-screen games, and for rendering to small framebuffers for post-processing effects.
as for your last edit, in my implementation of reading mouse input, i read the mouse messages passed from windows. Which takes care of making sure the mouse is actually the top left of the drawable window. however if i remember correctly(and it's been awhile since i've had to do it on windows) you needed to get the window client size, and subtract that from the total window size to get the correct offset? But you'll have to do a bit more googling as I don't remember the exact implementation.