I have a background image on a Direct3D canvas. I am drawing a circle at a specific position on the background. After the canvas is zoomed/panned with a camera (using world/view/projection), the background is updated.
Now the problem is, I can't find the previous position on the image to redraw the circle. I'm using the following function (DirectX 11.1) to find the coordinate. But it's not working.
XMVECTOR Camera::Unproject(Windows::Foundation::Rect viewPort, Windows::Foundation::Point location)
{
XMFLOAT3 worldPosition(location.X, location.Y, 0.0f);
XMVECTOR worldVector = XMLoadFloat3(&worldPosition);
return XMVector3Unproject(worldVector, viewPort.X, viewPort.Y, viewPort.Width, viewPort.Height, 0.0f, 1.0f, this->Projection(), this->View(), this->World());
}
I even tried with XMMatrixIdentity as the world. But no success. Can anyone please help me?