<HTML>
<HEAD>
<TITLE>Re: [vtkusers] VtkCamera -- Zoom method</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Chris,<BR>
I actually figured out that my understanding of the “zoom” operation was incorrect after querying on another list.<BR>
;)<BR>
I can’t use this functionality because I have large models (spatially) with small details and after a couple of “zooms” the view angle is really small which causes problems later in the render pipeline.<BR>
Gerrick<BR>
On 9/24/08 1:16 PM, "Chris Volpe ARA/SED" <<a href="cvolpe@ara.com">cvolpe@ara.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><FONT COLOR="#1F497D">I read this post mainly because I thought it might have something to do with my Dolly question from a couple weeks ago. I’m not sure why you’re questioning this implementation, or what you mean by “translation”, since there’s no translation going on here. “Zooming” doesn’t mean moving the camera closer to what it’s looking at (that’s called “dollying”). Zooming is what happens when you put a zoom-lens (or “telephoto” lens) on your camera, which basically has the effect of reducing the camera’s view angle so that objects that subtend a smaller view angle fill the image. This is basically synonymous with “magnification”. <BR>
<BR>
</FONT><BR>
</SPAN></FONT><FONT COLOR="#1F497D"><FONT SIZE="6"><FONT FACE="Monotype Corsiva"><SPAN STYLE='font-size:24pt'>Chris<BR>
</SPAN></FONT></FONT><FONT SIZE="2"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:10pt'>--<BR>
Christopher R. Volpe, Ph.D. Email: </SPAN></FONT></FONT></FONT><FONT SIZE="2"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:10pt'><FONT COLOR="#0000FF"><a href="cvolpe@ara.com">cvolpe@ara.com</a></FONT><FONT COLOR="#1F497D"> <<a href="mailto:cvolpe@ara.com">mailto:cvolpe@ara.com</a>> <BR>
Senior Scientist, Information Exploitation Systems Main Desk: 919-582-3300<BR>
</FONT><FONT COLOR="#0000FF">Applied Research Associates, Inc</FONT><FONT COLOR="#1F497D"> <<a href="http://www.ara.com/">http://www.ara.com/</a>> Direct: 919-582-3380<BR>
8537 Six Forks Rd., Suite 6000 Fax : 919-582-3301<BR>
Raleigh, NC 27615 Web: </FONT><FONT COLOR="#0000FF"><a href="http://www.ara.com/offices/NC.htm">http://www.ara.com/offices/NC.htm</a></FONT><FONT COLOR="#1F497D"> <<a href="http://www.ara.com/offices/NC.htm">http://www.ara.com/offices/NC.htm</a>> <BR>
</FONT></SPAN></FONT></FONT><FONT COLOR="#1F497D"><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'> <BR>
<BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Tahoma, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:10pt'><B>From:</B> <a href="vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> [<a href="mailto:vtkusers-bounces@vtk.org">mailto:vtkusers-bounces@vtk.org</a>] <B>On Behalf Of </B>Gerrick Bivins<BR>
<B>Sent:</B> Monday, September 15, 2008 6:26 PM<BR>
<B>To:</B> VTK-users<BR>
<B>Subject:</B> [vtkusers] VtkCamera -- Zoom method<BR>
</SPAN></FONT></FONT><FONT FACE="Times New Roman"><SPAN STYLE='font-size:12pt'> <BR>
</SPAN></FONT><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="Courier New"><SPAN STYLE='font-size:7pt'>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>
<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>