[vtkusers] Correctly apply camera matrix
ken.martin at kitware.com
Mon Jul 16 12:12:47 EDT 2018
The best approach in VTK is to save the key variables, camera position,
focal point, vup, dop, view angle. This is because the interaction methods
directly adjust those parameters, not the computed matrix.
On Mon, Jul 16, 2018 at 4:13 AM, andyjk <andrewkeeling at hotmail.com> wrote:
> I am trying to save a particular camera view, then reapply it later (ie be
> able to reset the the view to a previous position)
> I see from here (
> ) that I can do this by saving position, focal_point, View-up and
> but I am trying to do this more neatly by saving just the 4x4
> matrix of the camera (and assuming view angle is unchanged).
> How can I grab the current camera transformation matrix, and later re-apply
> it ?
> I have tried :
> 1) GRAB
> vtkSmartPointer<vtkMatrix4x4> mat;
> mat =
> saveVTKMat4x4(mat, "VTKCamera.vmx");
> 2) LOAD and APPLY
> loadVTKMat4x4(mat, "VTKCamera.vmx");
> vtkSmartPointer<vtkMatrix4x4> mat_inverse =
> vtkMatrix4x4::Invert(mat, mat_inverse);
> vtkSmartPointer<vtkTransform> transform =
> vtkSmartPointer<vtkMatrix4x4> current_mat;
> current_mat = custom_camera->GetViewTransformMatrix();
> vtkSmartPointer<vtkMatrix4x4> current_mat_inverse =
> vtkMatrix4x4::Invert(current_mat, current_mat_inverse);
> vtkSmartPointer<vtkTransform> transformInv =
> [Where the save/load functions have been verified using vtk::print and are
> working fine]
> I presume when loading, I have to move the camera back to identity (via an
> inverse transform) before applying the new transform because I think
> ApplyTransform concatenates.
> I find that if I don't move the camera at all between saving and loading,
> If I nudge the camera a tiny bit between loading and saving, the new view
> displaced a bit more when loading, so I think I must be getting some
> transforms muddled up?
> Is there a neat way to the current camera matrix then reapply it later ?
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> Powered by www.kitware.com
> Visit other Kitware open-source projects at http://www.kitware.com/
> Please keep messages on-topic and check the VTK FAQ at:
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> Follow this link to subscribe/unsubscribe:
Ken Martin PhD
101 East Weaver Street
Carrboro, North Carolina
This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee. Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers