Hi,
I have a problem with the rendering of the text on a osgWidget::Label. I have
attached an osgWidget to a PositionAttitudeTransform and positioned it in a 3D
scene. The Label is always rotated to the screen and has a fixed size. The
problem occurs when changing the view on the scene (zoom in/out, rotating),
then the text is flickering or is disappearing.
Any help would be appreciated very much :)
Code:
const unsigned int MASK_3D = 0x0F000000;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(this->getView(0),
1280.0f,1024.0f,MASK_3D,osgWidget::WindowManager::WM_PICK_DEBUG );
wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY);
osgWidget::Box* box= new osgWidget::Box("HBOX",osgWidget::Box::HORIZONTAL
,true);
box->getBackground()->setColor(0.6f, 0.6f, 0.6f, 0.8f);
box->setDataVariance(osg::Object::DYNAMIC);
QString labelText = "Test";
osgWidget::Label* label1 = new osgWidget::Label("", "");
label1->setFont("./data/fonts/arial.ttf");
label1->setFontSize(17);
label1->setFontColor(0.0f, 0.0f, 0.0f, 1.0f);
label1->setLabel(labelText.toStdString());
label1->setPadLeft(3.0f);
//State Set
box->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
label1->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::OFF);
label1->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
label1->getOrCreateStateSet()->setMode( GL_DEPTH_TEST,
osg::StateAttribute::OFF); label1->getOrCreateStateSet()->setMode( GL_DEPTH,
osg::StateAttribute::OFF);
label1->setAlignHorizontal(osgWidget::Widget::HA_LEFT);
label1->setDimensions(0,0,130,60);
osg::StateSet* stateTest = label1->getOrCreateStateSet();
stateTest->setMode( GL_POLYGON_OFFSET_FILL,
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
stateTest->setRenderBinDetails( 110, "RenderBin",
osg::StateSet::OVERRIDE_RENDERBIN_DETAILS );
stateTest->setAttributeAndModes( new osg::ColorMask( false, false, false, false
),
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
stateTest->setAttribute( new osg::CullFace( osg::CullFace::FRONT ),
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
stateTest->setMode( GL_CULL_FACE, osg::StateAttribute::OFF );
box->setPosition(400,0,100);
box->addWidget(label1);
wm->addChild(box);
//Location of label
osg::AutoTransform* xform = new osg::AutoTransform;
xform->addChild(box->getGeode());
xform->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
xform->setAutoScaleToScreen(true);
osg::ref_ptr<osgEarth::Util::ObjectLocatorNode> oln = new
osgEarth::Util::ObjectLocatorNode(this->mapNode->getMap());
oln->getLocator()->setPosition(osg::Vec3d(4.763889,52.308613, 100.0));
oln->addChild(xform);
this->root->addChild(oln);
Thank you!
Cheers,
Alex
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50046#50046
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org