-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
I am looking at the source code for pcl_visualizer.cpp (located in pcl/visualization/src) and in the function renderViewTesselatedSphere there is this snippet of code:
//rotate model so it looks the same as if we would look from the new position
vtkSmartPointer<vtkMatrix4x4> view_trans_inverted = vtkSmartPointer<vtkMatrix4x4>::New ();
vtkMatrix4x4::Invert (cam->GetViewTransformMatrix (), view_trans_inverted);
vtkSmartPointer<vtkTransform> trans_rot_pose = vtkSmartPointer<vtkTransform>::New ();
trans_rot_pose->Identity ();
trans_rot_pose->Concatenate (view_trans_inverted);
trans_rot_pose->Concatenate (cam_tmp->GetViewTransformMatrix ());
vtkSmartPointer<vtkTransformFilter> trans_rot_pose_filter = vtkSmartPointer<vtkTransformFilter>::New ();
trans_rot_pose_filter->SetTransform (trans_rot_pose);
trans_rot_pose_filter->SetInputConnection (trans_filter_scale->GetOutputPort ());
//translate model so we can place camera at (0,0,0)
vtkSmartPointer<vtkTransform> translation = vtkSmartPointer<vtkTransform>::New ();
translation->Translate (first_cam_pos[0] * -1, first_cam_pos[1] * -1, first_cam_pos[2] * -1);
vtkSmartPointer<vtkTransformFilter> translation_filter = vtkSmartPointer<vtkTransformFilter>::New ();
translation_filter->SetTransform (translation);
translation_filter->SetInputConnection (trans_rot_pose_filter->GetOutputPort ());
//modify camera
cam_tmp->SetPosition (0, 0, 0);
cam_tmp->SetFocalPoint (first_cam_pos[0] * -1, first_cam_pos[1] * -1, first_cam_pos[2] * -1);
cam_tmp->Modified (); ```
Which is supposed to translate and rotate the model so that it looks the same as if the camera were at the position described, but now we can put the camera at the origin.
However the following two lines:
trans_rot_pose->Concatenate (view_trans_inverted);
trans_rot_pose->Concatenate (cam_tmp->GetViewTransformMatrix ());
show that it is applying the inverse of the view matrix followed by the view matrix to the mesh which to me looks like a bug as this is not rotating it at all (correct?) as it does apply the inverse rotation but then multiplies it by that inverse with the net effect of nothing?
Am I correct in thinking this is a bug, or have I misunderstood.