A bit of context: The GUI element for this question are made with QML.
I’m currently building a scene – i.e. several actor in the same space related to one another through a matrix transform hierarchy – and am adding a GUI element displaying a listing of all the actor residing in the scene. The purpose of this list is to offer a prospective user the ability to quickly focus on an actor of interest by clicking on the actor’s name in the list so that the camera then focuses on this actor through a fluid movement.
There are two requirements for this particular use case to produce a satisfactory effect.
- Once the user clicks on the actor’s name in the list, the camera should be properly focused on the actor. That is, it is properly positioned and oriented.
- Ideally, the camera should move from its pre-click position to its post-click position in a fluid way. That is, the camera should properly interpolate its movement from its pre-click to post-click location.
Now, I’ve been having some problem achieving both effects.
With respect to (1), one way of achieving something close to what I want is to use the ResetCamera
method of the vtkRenderer in the following way: vtkRenderer->ResetCamera(vtkProp->GetBounds())
. However, while this indeed does 80% of what’s desired, it does not properly orient the camera with respect to the Prop3D. That is, the roll, pitch and yaw isn’t adjusted. I’m still struggling to find a way to do this.
With respect to (2), I’ve been trying to achieve the effect with a vtkCameraInterpolator
but I’m struggling to succeed for the two following reasons. First, there does not seem to have a way to have vtkRenderer::ResetCamera
and vtkCameraInterpolator
to interact with one another. That is, use of vtkCameraInterpolator seem to preclude the use of the ResetCamera function. Second, I don’t fully understand how to setup vtkCameraInterpolator
in order to make the movement happen. Do I need to define the movement myself and then add as many camera to the interpolator as there are interpolation points in the camera path movement? This seems to be what the InterpolateCamera example does but when looking at the CameraOrientation example and CameraOrientationWidget, this appears less clear to me.
So what I’m basically asking is how to achieve (1) and (2). A user click on an actor’s name in a QML gui element and the camera moves in a fluid motion to focus on the actor with a pre-determined orientation. Any help or pointers appreciated.