Anyways; In the editor I noticed when I move the mouse over the mesh the cursor sets to cross. This is good, however - calculation is totally wrong and off path. I believe I successfully Unprojected the 2D Mouse Coordiants to 3D World Space. This is what I did:
GetCursorPos(&MousePos); ScreenToClient(DXWindow,&MousePos); GetWindowRect(DXWindow,&DXWindowSize); const XMVECTOR RayOrigion = camera.CameraPosition; XMVECTOR Mouse2DSpace = XMVectorSet(MousePos.x,MousePos.y,0.0f,0.0f); XMVECTOR Mouse3DSpace = XMVector3Unproject(Mouse2DSpace,0,0,m_screenWidth,m_screenHeight,0.0f,1.0f,camera.CameraProjectionMatrix,camera.CameraViewMatrix,XMMatrixIdentity()); RayDirection = Mouse3DSpace - RayOrigion; RayDirection = XMVector3Normalize(RayDirection); RayDirection = RayDirection * 100.0f; XMVECTOR vEye; XMVECTOR vDir; XMStoreFloat3((XMFLOAT3*)&vEye,RayOrigion); XMStoreFloat3((XMFLOAT3*)&vDir,RayDirection); XMStoreFloat3(&MouseFloat3,RayDirection);
I stored the vectors into float3 because I can actually see what is going on. Onward the managed side, if the mouse moves inside the DX Window inside the editor; it goes back and calculates the intesection of Mouse point and Mesh Verticies.
I am having difficult time with finding p0, p1, p2 then finding center point of the triangle.
bool computeIntersection(XMFLOAT3 &p, XMFLOAT3 &target) {
bool result;
result = false;
float iX = (target.x );
float iY = (target.y );
float iZ = (target.z );
float iX1 = (target.x);
float iY1 = (target.y);
float iZ1 = (target.z);
t = XMFLOAT3((iX - p.x) + (iX1 - p.x),(iY - p.y) + (iY - p.y), 1.0f);
if(p.x > iX && p.y > iY) {
result = true;
}
return result;
}
Thanks for the help.






