I am using vtkCoordinate to convert mouse click pixel to world coordinate,
When I do the convert, I backup the current camera clipping range and change to a clipping range when first click, then do the convert.
var pos = GetInteractor().GetEventPosition();
var camera = renderer.GetActiveCamera();
var clipOld = camera.GetClippingRange();
try
{
if (points.Count == 0)
{
clipRange = camera.GetClippingRange();
}
camera.SetClippingRange(clipRange[0], clipRange[1]);
vtkCoordinate coordinate = vtkCoordinate.New();
coordinate.SetCoordinateSystemToDisplay();
coordinate.SetValue(pos[0], pos[1]);
return coordinate.GetComputedWorldValue(renderer);
}
finally
{
camera.SetClippingRange(clipOld[0], clipOld[1]);
}
This works fine in the beginning, but when I zoom in the camera to a certain level, I always get almost the same point, but I think it should have some distance.
[13:58:30 INF] Point:[96.892307717881508, 76.743746693872936, -38.267776752685485]
[13:58:30 INF] Point:[96.883216117087429, 76.7392462461047, -38.311059009029137]