[vtkusers] Rotate the camera around a specific point

Dowhan, Lukasz Lukasz.Dowhan at isko-engineers.de
Thu Nov 27 06:34:32 EST 2014


I am using VTK 6.1 as Python wrapper. For some time I have been struggling with a vtkCamera problem.
I would like to rotate the camera around a specific point. By default the camera rotates around the focal point. The focal point can be set wit camera.SetFocalPoint() method. But using this method the scene is moved to the center of the viewport (and then it is possible to rotate around that defined point). And that I would like to avoid. I would like to rotate the camera around a specific point (as it is with focal point) but without moving the scene to the center.
A small example that demonstrates the problem (it interacts with left mouse click on the cone, then the new point is defined):

## code ##
from vtk import vtkConeSource, vtkPolyDataMapper, vtkActor, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor, vtkInteractorStyleTrackballCamera

class MyInteractorStyle(vtkInteractorStyleTrackballCamera):
    def __init__(self):
        self.AddObserver('LeftButtonPressEvent', self.OnLeftButtonDown, -1)

    def OnLeftButtonDown(self, obj, event):
        picker = self.GetInteractor().GetPicker()
        camera = self.GetCurrentRenderer().GetActiveCamera()

        if self.PositionPicked() != 0:


    def PositionPicked(self):
        click_pos = self.GetInteractor().GetEventPosition()
        picker = self.GetInteractor().GetPicker()
        t = picker.Pick(click_pos[0], click_pos[1], 0, self.GetCurrentRenderer())
        return t

if __name__ == "__main__":
    cone = vtkConeSource()

    mapper = vtkPolyDataMapper()

    actor = vtkActor()

    renderer = vtkRenderer()

    renderWindow = vtkRenderWindow()

    renderWindowInteractor = vtkRenderWindowInteractor()

    style = MyInteractorStyle()



## end code ##

I have dealt with the camera’s transformations after setting the focal point, but without any success.
I have also tried to implement my own Camera class (that inherits vtkCamera) in order to rewrite/modify the Azimuth() and Elevation() methods as they are responsible for the rotation. For some reason it does not work with the modified SetPosition() and SetFocalPoint() methods (they also have to be reimplemented in order to update the transformations from Azimuth() and Elevation()). I wrote that class based on the original vtkCamera.cxx implementation.
The code with my camera is pretty long, but I can provide it if needed.

I have search probably every vtk post on the internet and I did not found a solution for my issue. Maybe I am missing something? ☺
Thanks in advance for any help!

Best regards,

Dr.-Ing. Lukasz Dowhan

CAE Prozesse und Optimierung

ISKO engineers AG
Taunusstr. 42, 80807 München
Fon: +49 89 37062-247
Fax: +49 89 37062-191

Mail: Lukasz.Dowhan at isko-engineers.de

[cid:image85a5dd.PNG at 56fbcc64.4197f06c]<http://www.isko-engineers.de/loesungen/software/aktionen/msc-fem-einsteigerpaket/?utm_source=Mailsignatur&utm_medium=E-Mail&utm_term=MSC%20FEM%20Einstiegspaket&utm_campaign=MSC%20FEM%20Aktion>

[cid:imageabe85f.PNG at 3f98ebe7.4a876f46]<http://www.isko-engineers.de/events/konferenzen/?utm_source=Signatur&utm_medium=E-Mail&utm_term=Simvec&utm_campaign=Simvec%20Konferenz>


Sitz der AG: D-80807 Muenchen, Registergericht Muenchen HRB 129 078
Vorsitzender des Aufsichtsrates: Michael Welzel
Vorstand: Michael Probst, Michael Krause
USt-IdNr.: DE 812 837 909

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141127/925e2815/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image85a5dd.PNG
Type: image/png
Size: 27099 bytes
Desc: image85a5dd.PNG
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141127/925e2815/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imageabe85f.PNG
Type: image/png
Size: 24254 bytes
Desc: imageabe85f.PNG
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141127/925e2815/attachment-0003.png>

More information about the vtkusers mailing list