Ok, so we dug deeper into the problem and found we have a problem with
intersection code. We call osgViewer::View::ComputeIntersections to
intersect an x, y position in screen coordinates to a grid in the scene to
produce a position in world space. osgViewer::View::ComputeIntersections is
reporting the wrong intersection points. The problem occurs when the
application is first started and after the wxGLCanvas window is resized. The
only way to fix the problem is to move the mouse pointer over the wxGLCanvas
window and click a mouse button. Sending the window a mouse event to hack a
fix does not work.
We've tracked down this problem to bad valued in the eventState class in the
eventQueue. The sequence of events are as follows:
osgViewer::View::ComputeIntersections calls
osgViewer::View::getCameraContainingPosition which calls
getEventQueue()->getCurrentEventState()

Hopefully someone has crossed this before.

The event state before the mouse click is:

-    eventState    0x18560430 {_handled=false _eventType=NONE _time=
0.00000000000000000 ...}    const osgGA::GUIEventAdapter *
+    osg::Object    {_name={""} _dataVariance=UNSPECIFIED
_userData={_ptr=0x00000000 {_refMutex=??? _refCount=??? _observers=??? } }
}    osg::Object
    _handled    false    bool
    _eventType    NONE    osgGA::GUIEventAdapter::EventType
    _time    0.00000000000000000    double
    _windowX    0    int
    _windowY    0    int
    _windowWidth    1280    int
    _windowHeight    1024    int
    _key    0    int
    _button    0    int
    _Xmin    0.00000000    float
    _Xmax    938.00000    float
    _Ymin    0.00000000    float
    _Ymax    250.00000    float
    _mx    5.6843419e-014    float
    _my    249.00000    float
    _pressure    0.00000000    float
    _buttonMask    1    unsigned int
    _modKeyMask    0    unsigned int
    _scrollingMotion    SCROLL_NONE
osgGA::GUIEventAdapter::ScrollingMotion
    _scrollingDeltaX    0.00000000    float
    _scrollingDeltaY    0.00000000    float
    _mouseYOrientation    Y_INCREASING_UPWARDS
osgGA::GUIEventAdapter::MouseYOrientation
    _tabletPointerType    UNKNOWN
osgGA::GUIEventAdapter::TabletPointerType

After the mouse click it is:

-    eventState    0x0a809358 {_handled=false _eventType=NONE _time=
0.00000000000000000 ...}    const osgGA::GUIEventAdapter *
+    osg::Object    {_name={""} _dataVariance=UNSPECIFIED
_userData={_ptr=0x00000000 {_refMutex=??? _refCount=??? _observers=??? } }
}    osg::Object
    _handled    false    bool
    _eventType    NONE    osgGA::GUIEventAdapter::EventType
    _time    0.00000000000000000    double
    _windowX    0    int
    _windowY    0    int
    _windowWidth    1280    int
    _windowHeight    1024    int
    _key    0    int
    _button    0    int
    _Xmin    0.00000000    float
    _Xmax    656.00000    float
    _Ymin    0.00000000    float
    _Ymax    250.00000    float
    _mx    367.00000    float
    _my    48.000000    float
    _pressure    0.00000000    float
    _buttonMask    0    unsigned int
    _modKeyMask    0    unsigned int
    _scrollingMotion    SCROLL_NONE
osgGA::GUIEventAdapter::ScrollingMotion
    _scrollingDeltaX    0.00000000    float
    _scrollingDeltaY    0.00000000    float
    _mouseYOrientation    Y_INCREASING_UPWARDS
osgGA::GUIEventAdapter::MouseYOrientation
    _tabletPointerType    UNKNOWN
osgGA::GUIEventAdapter::TabletPointerType

The values for _Xmax, _mx and _my are wrong before the mouse click which
results in the wrong mapping from screen coordinates to world coordinates.

Tamer El Nashar wrote:

 i do that, the following is my resize code:

void SS3DCanvas::OnSize(wxSizeEvent& event)
{
    // this is also necessary to update the context on some platforms
    wxGLCanvas::OnSize(event);

    // set GL viewport (not called by wxGLCanvas::OnSize on all
platforms...)
    int width = event.GetSize().x, height = event.GetSize().y;
    //GetClientSize(&width, &height);

    width = max(5, width);
    height = max(5, height);

    // update the window dimensions, in case the window has been resized.
    getEventQueue()->windowResize(0, 0, width, height);
    resized(0, 0, width, height);

    m_HUD->OnSize(width, height);

    // This is a HACK to un-stick the canvas windows on startup.
    // For some unknown reason, the canvas windows require a single mouse
event before they'll start
    // responding to user events. By posting a single, mouse up event we
un-stick the windows so they'll
    // respond to the first user event.
    //wxMouseEvent mouseEvent;
    //mouseEvent.m_x = 10;
    //mouseEvent.m_y = 10;
    //mouseEvent.m_leftDown = true;
    //mouseEvent.SetEventType(wxEVT_MOTION);
    //wxPostEvent(this, mouseEvent);
}

Thibault Genessay wrote:

Hi Tamer,

Have you tried to pass the new graphics window size to the OSG when it
changes ? Your canvas should intercept the resize events and send the
updated sizes to all OSG views, e.g.
myView->getEventQueue()->windowResize(0, 0, width, height);

Thibault

On Jan 20, 2008 1:37 AM, Tamer El Nashar <[EMAIL PROTECTED]>
<[EMAIL PROTECTED]> wrote:

 Hi,

I am using OSG with wx and I am getting a strange bug on my  canvas when
dragging and dropping on the canvas, specifically after resizing the canvas.
So initially after the canvas is resized and I drag and drop, items show up
in the wrong place.  Then I click once on the canvas and then when I drag
and drop they show up in the write place, as if clicking initializes/fixes
something, then everything works.  I tried sending my own wxMouseEvent in
every size event, and the event does get handled by the osgGA::EventQueue,
however that doesnt work.  Only actually clicking on the canvas fixes the
problem. The code that reports the wrong values is:
osgUtil::LineSegmentIntersector::getWorldIntersectPoint().  After clicking
once on the canvas, the same code reports correct values!  Anyone crossed
this before, or any ideas what it could be?  I wouldn't even qualify as a
OSG novice, so any tips would be much appreciated.





 Thanks in advancce




 Tamer El Nashar

VRSonic Inc.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


     _______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to