<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi OSG community,<br>
    <br>
    my application needs "zoom keys". As a result the cursor position<br>
    gets centered in the window and depending on key the scene gets <br>
    zoomed.<br>
    I do this with this short method:<br>
    <br>
    <span style=" color:#000080;">/**</span><span style="
      color:#c0c0c0;"> </span><span style=" color:#c0c0c0;"></span><span
      style=" color:#000080;">A zoom key was pressed (ESC,</span><span
      style=" color:#c0c0c0;"> </span><span style=" color:#000080;">F1</span><span
      style=" color:#c0c0c0;"> </span><span style=" color:#000080;">-</span><span
      style=" color:#c0c0c0;"> </span><span style=" color:#000080;">F5)</span><span
      style=" color:#000080;"></span>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">  </span><span style=" color:#000080;">*</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">_x</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">and</span><span style=" color:#c0c0c0;"> _</span><span style=" color:#000080;">y is the cursor position in the window scaled to</span><span style=" color:#c0c0c0;"></span><span style=" color:#000080;"></span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">-1.0</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">..</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">+1.0</span></pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">  </span><span style=" color:#000080;">*/</span></pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">void</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Cl_3Dview_osg</span>::<span style=" font-style:italic; color:#000000;">handleZoom</span>(<span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span>_x,<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span>_y,<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">double</span><span style=" color:#c0c0c0;"> </span>_scale)<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Matrix</span><span style=" color:#c0c0c0;"> </span>offsetMatrix<span style=" color:#c0c0c0;"> </span>=</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Matrix</span>::scale(_scale,<span style=" color:#c0c0c0;"> </span>_scale,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1.0</span>)<span style=" color:#c0c0c0;"> </span>*</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Matrix</span>::translate(-_scale<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>_x,<span style=" color:#c0c0c0;"> </span>_scale<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>_y,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0.0</span>);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800000;">view</span>->getCamera()->setProjectionMatrix(<span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">view</span>->getCamera()->getProjectionMatrix()<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>offsetMatrix<span style=" color:#c0c0c0;"> </span>);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">}</pre>
    <pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
    The camera has a TrackballManipulator. After my offset is applied
    the home position of the manipulator is lost.<br>
    I guess I have to control the manipulator instead of the projection
    matrix of the camera.<br>
    <br>
    Unfortunately I get stock because I don't manage to convert this
    accordingly.<br>
    <br>
    I hope for some help here.<br>
    <br>
    Many thanks for any hints.<br>
    <br>
    - Werner -<br>
  </body>
</html>