Hi all,

My problem is solved my I flip my FrameBuffer vertically (in Qt), which I 
should not be doing.


So anyone has an idea of what can flip my OSG view vertically?


Thanks,


Antoine.


________________________________
From: osg-users <[email protected]> on behalf of 
Antoine Rennuit <[email protected]>
Sent: 02 August 2016 18:37
To: [email protected]
Subject: Re: [osg-users] Left handed scene


Hi all,


Going a bit forward with my left handedness problem...


My viewport actually appears upside down vertically: the HUD coordinate system 
on the left is up when it should be down and the text is also written upside 
(see joined picture). It behaves as if the viewport had its y origin at the 
bottom of the viewport (and not at the top as usual).


Any idea?


Kind regards,


Antoine.


________________________________
From: osg-users <[email protected]> on behalf of 
Antoine Rennuit <[email protected]>
Sent: 02 August 2016 14:36
To: [email protected]
Subject: [osg-users] Left handed scene


Hi all,


I have a QtWidget app which I am converting to QtQuick. My app works well with 
QtWidget but after transitioning to QtQuick I have observed that the whole 
scene is now left handed: not only the geometry is left handed (the z axis is 
down when it should be up - check joined file) but also the 
TrackballManipulator behavior (e.g. when I pan up with the mouse the scene goes 
down, and it's the same opposite reaction for rotate).


I do not understand where this is coming from. I was able to easily put the 
geometry back right handed using a scale -1 on Z but I should not have to do 
that and this does not solve the TrackballManipulator behavior.


I have used https://bitbucket.org/leon_manukyan/qtquick2osgitem as a starting 
point and my code does the following:


I have a RendererImpl class, created by an OsgItem and which is responsible for 
maintaining the osgViewer::Viewer and the osgViewer::GraphicsWindow, here is 
its init method:


void RendererImpl::init()
{
    m_sceneRoot = new osg::Group();

    m_viewer = new osgViewer::Viewer;
    m_viewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
    m_viewer->setSceneData(m_sceneRoot);
    m_viewer->setCameraManipulator(new osgGA::TrackballManipulator);
    m_viewer->getCameraManipulator()->setHomePosition(osg::Vec3d(4.0, -4.0, 
2.0), osg::Vec3d(0.0, 0.0, 1.0), osg::Vec3d(0.0, 0.0, 1.0));
    m_viewer->home();

    m_sceneRoot->addChild(setupLight());
    m_sceneRoot->addChild(setupGrid(6.0f, 2.0f));

    m_window = new FrameBufferWindow(this);
    updateSize();

    osg::Camera* camera = m_viewer->getCamera();
    camera->setGraphicsContext( m_window.get() );

    camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
}


And its update method on window size change:


void RendererImpl::updateSize()
{
    m_window->getEventQueue()->windowResize(0, 0, osgItem().width(), 
osgItem().height() );
    m_window->resized(0, 0, osgItem().width(), osgItem().height());

    osg::Camera& camera = *m_viewer->getCamera();
    const osg::GraphicsContext::Traits& t = *m_window->getTraits();
    camera.setViewport( 0, 0, t.width, t.height );
    double aspectRatio = t.height ? (double)t.width / (double)t.height : 1.0;
    camera.setProjectionMatrixAsPerspective(30.0f, aspectRatio, 1.0f, 10000.0f 
);
}


And I have an item which streams the events to the window, e.g.:


void OsgItem::mouseMoveEvent(QMouseEvent *event)
{
    m_renderer->m_window->getEventQueue()->mouseMotion(event->x(), event->y());

    update();
}


Does anyone have an idea of what is wrong in my code? I have looked for days 
and I am stuck!


Thanks,


Antoine.

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

Reply via email to