Rotation in a strict axis


I am wondering if there exists some kind of method with vtk to limit the rotation on an object, say point cloud to strictly to one axis when for example dragging left to right and up to down?

The problem is that when I am rotating, is that after a short rotation, the whole object has rotated in both x and y which is undesirable.

If I am dragging to the left, then I only want to rotate the x axis around itself, and the same thing for Y. But with current vtk implementation, both rotates at the same time so I have to correct the rotation with the ctrl+mouse drag every time.

Or do I have to create my own functions for this and read the mouse movements to where I am dragging?

Thank you.


One way to do it is by overriding`vtkInteractorStyleTrackballCamera’s callback methods to implement the behavior you want. Here is an example on how to derive it: gammaray/viewer3d/v3dmouseinteractor.h at master · PauloCarvalhoRJ/gammaray · GitHub and gammaray/viewer3d/v3dmouseinteractor.cpp at master · PauloCarvalhoRJ/gammaray · GitHub. Here is the source code of said methods: VTK/Interaction/Style/vtkInteractorStyleTrackballCamera.cxx at master · Kitware/VTK · GitHub . Maybe copy, paste and modify the ones you need in your derived class to suit your objectives.