Hello All, I am currently new to DirectX and am trying to make a very simple, rotating cube to a position in 3d-space from a users mouse click.
I can do 90% of this, but when I try to convert the users mouse click into 3D-space, I get strange values (or at least I think they are strange).
I have placed a cube at and around the -3 to +3 vertex positions in 3D space. Then I setup the camera, etc... and I can see the cube in the middle of the black screen.
Then when I click the mouse, I call a self-defined method called
The method is defined as:
D3DXVECTOR3* GameEntity::SetupLocalMousePoints(IDirect3DDevice9* p_d3dDevice)
screenPoint.x = m_mousePoint->x;
screenPoint.y = m_mousePoint->y;
screenPoint.z = 0.0f;
m_mousePoint = 0;
p_d3dDevice->GetTransform( D3DTS_PROJECTION, &matProjection );
p_d3dDevice->GetTransform( D3DTS_VIEW, &matView );
p_d3dDevice->GetTransform( D3DTS_WORLD, &matWorld );
//transform the mouse clicked location
D3DXVec3Unproject( &result, &screenPoint, &viewport, &matProjection, &matView, &matWorld );
m_mousePoint is a private class member variable:
The rest should be pretty obvious.
Now, the issue is when I click in the TOP RIGHT corner of the screen, I am getting. X: -23, Y:8 and Z:0.44 (ish).
Why on earth would X be a negative number???
I am having real trouble here and would appreciate any help at all!