vtkCamera problem with setPosition
While working on a VTK project, I had to change the position of the camera so by looking at the API, I used the setPosition() function.
The problem that I faced that sometimes after changing the position I would get a blank black screen. Update() or Render() or Invalidate() did not work. The only way to āre-renderā the window and show something was by interacting with the mouse: A click, or a pan would immediately redraw everything correctly with the vtkCamera in the position that I had set up using setPosition() !
This problem drove me crazy for days and I finally gave up without finding a solution, until yesterday!
So basically when you use the setPosition() of the vtkCamera class inĀ VTKĀ you change the position of the vtkCamera.
The clipping range is not changed though, and if it happens that your new camera position is OUTSIDE the clipping range, then you see nothing!! By clicking on the window, you basically slightly change the position of the camera andĀ VTKĀ forces a recalculation of the clipping range based on the new camera position and thus you see the object again!
So basically to fix the problem, you have to do is run the ResetCameraClippingRange() on the vtkRenderer object.
So for example:
theRenderer->GetActiveCamera()->setPosition(0.0, 0.0, 0.0);
theRenderer->ResetCameraClippingRange();