vtkInteractorStyleTerrain confused by FlyTo()
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Set the interactor style to Terrain. Set the camera like so: ren->GetActiveCamera()->SetPosition(1,1,0); ren->GetActiveCamera()->SetFocalPoint(0,0,0); ren->GetActiveCamera()->SetViewUp(0,0,1);
View a model.
Confirm that you cannot rotate the model all the way past the 'up' axis, the most you can go is to look directly down onto the model. That is a terrible description but I hope you get the gist.
Angle the model so you look at it from above, say from 45 degrees. Press 'f' to fly to a point in the model.
The camera's Up is now no longer 0,0,1. This screws up Terrain, now if you move the mouse up and down, you will go "over the top" of the model, rather than stopping at looking directly down on the model.
To "fix" this, I have had to do the following:
class CameraUp_Callback : public vtkCommand { public: virtual void Execute(vtkObject * caller, unsigned long, void*) { vtkRenderer * ren = vtkRenderer::SafeDownCast(caller); vtkCamera * camera = ren->GetActiveCamera(); if (camera) { double * view = camera->GetViewUp(); if (view[0] != 0 and view[1] != 0 and view[2] != 1) camera->SetViewUp(0,0,1); } } };
ren->AddObserver(vtkCommand::ResetCameraClippingRangeEvent, new CameraUp_Callback);