<HTML>
<HEAD>
<TITLE>VtkCamera -- Zoom method</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi All, Long email but please bear with me.<BR>
;)<BR>
I have had this problem of zooming in with vtkInteractorStyleRubberBandZoom.<BR>
Today was the day to tackle is and eventually I realized that zoom works fine when I use parallel projection but not perspective. <BR>
When I switch to perspective projection and zoom in, at some point the view angle gets set to 0 (1e-8). <BR>
<BR>
I’ve dug down into the code and ran across this implementation for Zoom in vtkCamera which is being called by vtkInteractorStyleRubberBandZoom:<BR>
<BR>
//----------------------------------------------------------------------------<BR>
// Change the ViewAngle (for perspective) or the ParallelScale (for parallel)<BR>
// so that more or less of a scene occupies the viewport. A value > 1 is a<BR>
// zoom-in. A value < 1 is a zoom-out.<BR>
void vtkCamera::Zoom(double amount)<BR>
{<BR>
if (amount <= 0.0)<BR>
{<BR>
return;<BR>
}<BR>
<BR>
if (this->ParallelProjection)<BR>
{<BR>
this->SetParallelScale(this->ParallelScale/amount);<BR>
}<BR>
else<BR>
{<BR>
this->SetViewAngle(this->ViewAngle/amount);//<==Why is zoom implemented like this? Why isn’t it a function of translation?<BR>
}<BR>
}<BR>
<BR>
Which is defined here:<BR>
</SPAN></FONT><FONT SIZE="1"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:7.5pt'>void vtkCamera::SetViewAngle(double angle)<BR>
{<BR>
double min = 0.00000001;<BR>
double max = 179.0;<BR>
<BR>
if ( this->ViewAngle != angle )<BR>
{<BR>
this->ViewAngle = (angle<min?min:(angle>max?max:angle));<BR>
this->Modified();<BR>
this->ViewingRaysModified();<BR>
}<BR>
}<BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
At this point(when min is set ), rendering becomes messed up (backfaces and bad z-fighting) and the only way to fix things is to restart the application.<BR>
This 0 can be seen as problematic in functions like<BR>
<BR>
vktRenderer::ResetCamera(double bounds[6])<BR>
{<BR>
...<BR>
//around line 990<BR>
distance = radius/sine(this->ActiveCamera()->GetViewAngle()*vtkMath::Pi()/360.0);//<== (radius/some really small number if view angle is small) == some really big number(e12)!!!!!<BR>
...<BR>
//around line 1004<BR>
this->ActiveCamera->SetPosition(center[0]+distance*vn[0], center[1]+distance*vn[1], center[2]+distance*vn[2]); //<==Uh Oh distance is a really big number(e12)!!<BR>
}<BR>
So finally, my question deals with trying to get a better understanding of the “Zoom” method in vtkCamera.<BR>
I don’t understand why zoom is implemented by changing the view angle. <BR>
Why isn’t it a function of translating the camera along it’s view vector toward or away from it’s lookAt point?<BR>
<BR>
Hopefully someone made it this far and can shed some light here.<BR>
;)<BR>
Gerrick<BR>
<BR>
<BR>
<BR>
</SPAN></FONT><FONT SIZE="1"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:7.5pt'><BR>
<BR>
</SPAN></FONT></FONT>
</BODY>
</HTML>