Zoom behavior in parallel vs perspective projection (camera position)

(Santosh Biradar) #1

I was trying to fix near plane clipping issues in the parallel projection mode. It is very easy to get into a scenario where, in the parallel projection mode, the camera is at a position where there are one or more actors BEHIND it. In this scenario, Zoom - out does not help to put those actors in FRONT so that they dont get clipped by the near plane. In perspective projection this problem does not occur because as we zoom out, the camera actually moves farther from the focal point. So the actors BEHIND the camera do come in FRONT eventually.

Looking at the Dolly method in the vtkInteractorStyleTrackballCamera, it is clear that the camera does not move in the parallel projection but does move in the perspective projection. By removing this check for projection mode and moving the camera irrespective of the projection mode, I am able to get rid of the near plane clipping issue in the parallel projection. I am still setting the parallel scale to ensure the zoom in/out makes objects appear larger/smaller in the parallel projection.

My question is why is the camera not moved in the parallel projection when zooming in/out in the VTK source code. Is there anything inherently wrong ?


(Utkarsh Ayachit) #2

In parallel projection moving closer to something doesn’t make that thing appear bigger – that’s just the nature of parallel projection. Making things appear bigger as you move closer is indeed the thing that defines perspective projection. Hence, to emulate zoom in parallel projection, VTK uses a scale factor instead.

(Santosh Biradar) #3

I understand that the parallel scale is used to give the effect of zooming. But what is the harm in moving the camera as well. That way the camera position will be the same when we toggle between parallel and perspective projections.

(Utkarsh Ayachit) #4

If we move the camera forward when zooming in parallel projection, there will be a point when the camera will just pass through the data. When that happens won’t necessarily be clear as parallel projection makes it really hard to realize how far the viewer is from the data.

Note, you can already add new interactor styles in VTK. So, if needed for you application, you should be able to create a new interactor style appropriately.

(Santosh Biradar) #5

The Dolly is moving the camera towards the focal point when we zoom in. So, if the focal point is within the data set (which is most likely the case), we will never cross the focal point and move outside the dataset.
Yes, I agree that I can look to create my own custom interactor style.

To add some context to this topic, I started off by looking at this thread:

I am facing the same issue reported in this thread (near plane clipping in parallel projection)

Now, the fix reported there was to allow the camera to have negative near plane clipping value so that it can SEE the objects behind it in the parallel projection mode. Also, that fix was not incorporated into the VTK source code.

The other way for me to fix the clipping issue was to MOVE the camera when zooming in parallel just like in perspective projection. In this case, the clipping planes are always in front of the camera.

I will, as suggested create my own interactor style but if you would have to pick the better of the two methods which one do you feel would not have any side-effects?