I have done some debugging and have found out the there is only 1 input that is changing between mouse clicks, the D3DTS_WORLD transformation.
I have included another version of the SetupLocalMousePoints method, and the output from the method is below, and as you can see the _41 and _42 properties of the D3DTS_WORLD change...
Can someone please explain the issues here and how one would normally go about fixing this issue?
Thanks you very much
void GameEntity::SetupLocalMousePoints(IDirect3DDevice9* p_d3dDevice){ if (m_mousePoint) { D3DXVECTOR3 screenPoint; D3DVIEWPORT9 viewport; D3DXMATRIX matProjection; D3DXMATRIX matView; D3DXMATRIX matWorld; D3DXVECTOR3 screenVector; p_d3dDevice->GetViewport(&viewport); p_d3dDevice->GetTransform( D3DTS_PROJECTION, &matProjection ); p_d3dDevice->GetTransform( D3DTS_VIEW, &matView ); p_d3dDevice->GetTransform( D3DTS_WORLD, &matWorld ); screenPoint.x = m_mousePoint->x; screenPoint.y = m_mousePoint->y; screenPoint.z = m_zOffset; std::ostringstream outputStr; outputStr << "SetupLocalMousePoints Debug****************************************\n"; outputStr << "Mouse X: " << m_mousePoint->x << "\n"; outputStr << "Mouse Y: " << m_mousePoint->y << "\n"; outputStr << "m_zOffset: " << m_zOffset << "\n"; outputStr << "\nviewport details\n"; outputStr << "Height: " << viewport.Height << "\n"; outputStr << "MaxZ: " << viewport.MaxZ << "\n"; outputStr << "MinZ: " << viewport.MinZ << "\n"; outputStr << "Width: " << viewport.Width << "\n"; outputStr << "x: " << viewport.X << "\n"; outputStr << "y: " << viewport.Y << "\n"; outputStr << "\nmatProjection details\n"; outputStr << "11: " << matProjection._11 << " 12: " << matProjection._12 << " 13: " << matProjection._13 <<" 14: " << matProjection._14 << "\n"; outputStr << "21: " << matProjection._21 << " 22: " << matProjection._22 << " 23: " << matProjection._23 <<" 24: " << matProjection._24 << "\n"; outputStr << "31: " << matProjection._31 << " 32: " << matProjection._32 << " 33: " << matProjection._33 <<" 34: " << matProjection._34 << "\n"; outputStr << "41: " << matProjection._41 << " 42: " << matProjection._42 << " 43: " << matProjection._43 <<" 44: " << matProjection._44 << "\n"; outputStr << "\nmatView details\n"; outputStr << "11: " << matView._11 << " 12: " << matView._12 << " 13: " << matView._13 <<" 14: " << matView._14 << "\n"; outputStr << "21: " << matView._21 << " 22: " << matView._22 << " 23: " << matView._23 <<" 24: " << matView._24 << "\n"; outputStr << "31: " << matView._31 << " 32: " << matView._32 << " 33: " << matView._33 <<" 34: " << matView._34 << "\n"; outputStr << "41: " << matView._41 << " 42: " << matView._42 << " 43: " << matView._43 <<" 44: " << matView._44 << "\n"; outputStr << "\nmatWorld details\n"; outputStr << "11: " << matWorld._11 << " 12: " << matWorld._12 << " 13: " << matWorld._13 <<" 14: " << matWorld._14 << "\n"; outputStr << "21: " << matWorld._21 << " 22: " << matWorld._22 << " 23: " << matWorld._23 <<" 24: " << matWorld._24 << "\n"; outputStr << "31: " << matWorld._31 << " 32: " << matWorld._32 << " 33: " << matWorld._33 <<" 34: " << matWorld._34 << "\n"; outputStr << "41: " << matWorld._41 << " 42: " << matWorld._42 << " 43: " << matWorld._43 <<" 44: " << matWorld._44 << "\n"; //transform the mouse clicked location D3DXVec3Unproject( &screenVector, &screenPoint, &viewport, &matProjection, &matView, &matWorld ); m_xOffset = screenVector.x; m_yOffset = screenVector.y; outputStr << "screenVector.x: " << screenVector.x << "\n"; outputStr << "screenVector.y: " << screenVector.y << "\n"; OutputDebugStringA(outputStr.str().c_str()); m_mousePoint = 0; }}
SetupLocalMousePoints Debug****************************************
Mouse X: 407
Mouse Y: 167
m_zOffset: 0.971619
viewport details
Height: 480
MaxZ: 1
MinZ: 0
Width: 640
x: 0
y: 0
matProjection details
11: 1.81066 12: 0 13: 0 14: 0
21: 0 22: 2.41421 23: 0 24: 0
31: 0 32: 0 33: 1.0101 34: 1
41: 0 42: 0 43: -1.0101 44: 0
matView details
11: -1 12: 0 13: 0 14: 0
21: 0 22: 0.952424 23: -0.304776 24: 0
31: -0 32: -0.304776 33: -0.952424 34: 0
41: -0 42: -4.76837e-007 43: 26.2488 44: 1
matWorld details
11: 1 12: 0 13: 0 14: 0
21: 0 22: 1 23: 0 24: 0
31: 0 32: 0 33: 1 34: 0
41: 0 42: 0 43: 0.971619 44: 1
screenVector.x: -3.94132
screenVector.y: 3.14972
SetupLocalMousePoints Debug****************************************
Mouse X: 407
Mouse Y: 167
m_zOffset: 0.971619
viewport details
Height: 480
MaxZ: 1
MinZ: 0
Width: 640
x: 0
y: 0
matProjection details
11: 1.81066 12: 0 13: 0 14: 0
21: 0 22: 2.41421 23: 0 24: 0
31: 0 32: 0 33: 1.0101 34: 1
41: 0 42: 0 43: -1.0101 44: 0
matView details
11: -1 12: 0 13: 0 14: 0
21: 0 22: 0.952424 23: -0.304776 24: 0
31: -0 32: -0.304776 33: -0.952424 34: 0
41: -0 42: -4.76837e-007 43: 26.2488 44: 1
matWorld details
11: 1 12: 0 13: 0 14: 0
21: 0 22: 1 23: 0 24: 0
31: 0 32: 0 33: 1 34: 0
41: -3.94132 42: 3.14972 43: 0.971619 44: 1
screenVector.x: -6.2582e-006
screenVector.y: 2.07303e-005