Hi Gerald, Your code creates an osg::Camera and assigns this to the View without ever setting any replacements for the OpenGL defaults - these defaults including the GL_DEPTH test being off which is what looks like it could be wrong with your image. So what you have is a setup where the OSG is doing exactly what you have told it to do, but not actually what you are want.
The solution is to defaults more appropriate to scene graph usage via camera->getOrCreateStateSet()->setGlobalDefaults() or simply use the View's default Camera rather than replacing it. The View by default call StateSet::setGlobalDefaults() on it's master Camera to works sensibly out of the box. Robert. On 12 October 2014 17:04, Gérald Lelong <[email protected]> wrote: > Hi, > > I'm using a simple class in order to render an OSG view into a Qt > environment and I'm having trouble trying to render a simple model. > > Here is the constructor of the class I use : > > > Code: > > OSGWidget::OSGWidget(QWidget * parent, const QGLWidget * shareWidget, > Qt::WindowFlags f): > QGLWidget(parent, shareWidget, f), > root(new osg::Group), > graphicsWindow_(new osgViewer::GraphicsWindowEmbedded(this->x(), > this->y(), this->width(), this->height())), > viewer_(new osgViewer::CompositeViewer) > { > float aspectRatio = static_cast<float>(this->width()) / > static_cast<float>(this->height()); > > osg::Camera * camera = new osg::Camera; > camera->setViewport(0, 0, this->width(), this->height()); > camera->setClearColor(osg::Vec4(1.f, 1.f, 1.f, 1.f)); > camera->setProjectionMatrixAsPerspective(30.f, aspectRatio, 1.f, 1000.f); > camera->setGraphicsContext(graphicsWindow_); > > osgViewer::View * view = new osgViewer::View; > view->setCamera(camera); > view->setSceneData(root.get()); > view->addEventHandler(new osgViewer::StatsHandler); > view->setCameraManipulator(new osgGA::TrackballManipulator); > > viewer_->addView(view); > viewer_->setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); > > osg::Node * node = > osgDB::readNodeFile("/home/sisyphe/Programs/OpenSceneGraph-Data-3.0.0/cessna.osg"); > root->addChild(node); > > this->setFocusPolicy(Qt::StrongFocus); > this->setMinimumSize(100, 100); > > this->setMouseTracking(true); > > QTimer * timer = new QTimer(this); > connect(timer, SIGNAL(timeout()), this, SLOT(updateView())); > timer->start(10); > } > > > > > All the OSG stuff is done here and you can see in attachment how the > cessna model is rendered. It looks like if faces were rendered in wrong > order. > > I didn't find anyone having similar issue. > > Is it related to Qt or something like face culling or normals ? > > Thank you![/code] > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=61281#61281 > > > > > Attachments: > http://forum.openscenegraph.org//files/cessna_245.png > > > _______________________________________________ > 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

