[osg-users] Changes in the way of compute intersections or in eventAdapter?

Robert Osfield robert.osfield at gmail.com
Mon Sep 1 06:12:53 PDT 2008


Hi Björn,

The GUIEventHandler has a field that tells you what way up the y axis
is, and also provides the range of the mouse values as well.  From
include/osgGA/GUIEventAdapter

        /** get mouse minimum x. */
        float getXmin() const { return _Xmin; }

        /** get mouse maximum x. */
        float getXmax() const { return _Xmax; }

        /** get mouse minimum y. */
        float getYmin() const { return _Ymin; }

        /** get mouse maYimum y. */
        float getYmax() const { return _Ymax; }

..

        MouseYOrientation getMouseYOrientation() const { return
_mouseYOrientation; }

Have a look at these values, also have a look how QGLWidget is feeding
values into osgViewer.


Robert.

On Mon, Sep 1, 2008 at 2:07 PM, Björn Hein <hein at ira.uka.de> wrote:
> Hello Robert,
>
> Sorry... You are right. We are using an
> - osgViewer::Viewer integrated in an QGLWidget.
> - GUI events (Keys, mouse move, and so on) are recieved via Qt, translated
> and entered in the EventQueue.
> - There is also an PickHandler registered to the eventqueue, that is called
> during eventTraversal every time a mouse button is pushed.
> - At this position x y from osgViewer::Viewer the computeIntersection(
> ea.getX(), ea.getY(), hitlist) is called.
> - the first hit is returned
>
> First of all: We found a "work around". Instead of directly setting the
> given mouse positions by the event adapter we ask for the heigt of the
> QGLWidget and subtract the y values:
>
> ----snip :
> Input : ea --> osgGA::GUIEventAdpater
>          q --> QGLWidget*
>          v --> osgViewer::Viewer*
>
>      float mx = ea.getX();
>      float my = ea.getY();
>
>      // :Problem: Inverted y-axis since OSG 2.6.0
>      if (OPENSCENEGRAPH_MAJOR_VERSION==2 &&
> OPENSCENEGRAPH_MINOR_VERSION>=6) {
>              float ww = q->width();
>              float wh = q->height();
>        my = wh - my;
>      }
>
>      if (v->computeIntersections( mx, my, lastHitList_) )
>
> ---- snip:
>
> For our point we have some kind of solution, I just wanted to know if there
> was a general "concept" change we didn't recognize in between 2.4 to 2.6 or
> do we have to investigate more in this because we have some weired code in
> our application using some of OSG concepts wrongly...
>
> So I will have a closer look at osgpick - as you recommended.
>
> Best regards
>
> Björn
>
>
>
> Hi Björn,
>
> You will need to give a bit more context before anyone can help give a
> useful answer.
>
> To start could explain what viewer setup you have.  My best guess is
> that you have a CompositeViewer, with at least two Cameras/viewports,
> but this guess is just that.  Also you'll need to explain what values
> you using to at what point in the program flow.
>
> Also please see if osgpick works for you.
>
> Robert.
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list