I have a question about how to get the world coordinate along with a mouse cursor.
I’m using the vtkRenderWindow to the Picture control on the MFC project.
And I’m trying to get the world coordinate of the Point Cloud Data along with the mouse cursor on the Picture control.
Please refer to as below my sample code:
class CCustomMouseInteractorStyle : public vtkInteractorStyleTrackballCamera
static CCustomMouseInteractorStyle* New();
virtual void OnMouseMove() override
int* pos = this->GetInteractor()->GetEventPosition();
vtkNew<vtkPropPicker> picker; picker->Pick(pos, pos, 0, this->GetDefaultRenderer()); double* picker_coordinate = picker->GetPickPosition(); //Picker coordinate vtkNew<vtkCoordinate> coordinate; coordinate->SetCoordinateSystemToDisplay(); coordinate->SetValue(pos, pos, 0); double* world_coordinate = coordinate->GetComputedWorldValue(this->GetDefaultRenderer()); //World coordinate vtkInteractorStyleTrackballCamera::OnMouseMove();
The world coordinate and the actual point coordinate obtained by mouse cursor when zoomed in is different.
I will explain the detail with the below picture.
- Load the same PCD file on the CloudCompare and my sample program.
- Check the coordinate of the same point.
“Display:” means that XY coordinate of the Picture control obtained by ‘this->GetInteractor()->GetEventPosition();’.
“World:” means that the world coordinate computed by the vtkCoordinate.
“Picker:” means that the coordinate of the point obtained by the vtkPropPicker.
You can see that the coordinates of the point obtained by the CloudComapre and the “Picker” are the same.
But there are different world coordinate and the “Picker” coordinate.
I would like to know how to get the correct world coordinate along with the mouse cursor.