HI Deniz, On quick review I couldn't spot the problem, but have a look at the osgtext example, it has code for placing text on a HUD and should be roughly what you are after.
Robert. On 18 October 2013 16:04, Deniz Koçak <[email protected]> wrote: > Hi all, > > I am trying to put a text on my screen by creating a HUD camera. I create > a camera object and add nodes to it (as in HUD examples). However, when I > select XY_PLANE or SCREEN as AxisAlignment for osgText::Text object, it > dows not show anything, but works (no really works, but I can see rotated > text) with REVERSED_XY_PLANE. When I select REVERSED_XY_PLANE, the result > can be seen on attached screenshot and of course this not what I want. I > tried many combinations, but the result was always same. What can I do in > that case? > > Cheers, > Deniz > > > --------------------------------------------------------------------------------------------- > > osg::Camera* createHUDText() > { > m_hudHeadingText = new osgText::Text(); > m_hudHeadingText->setText("Test"); > //m_hudHeadingText->setFont(osgText::Font::getDefaultFont()); > > m_hudHeadingText->setCharacterSizeMode(osgText::TextBase::OBJECT_COORDS); > m_hudHeadingText->setAlignment(osgText::TextBase::LEFT_BASE_LINE); > m_hudHeadingText->setAxisAlignment(osgText::TextBase::XY_PLANE); > //m_hudHeadingText->setAutoRotateToScreen(true); > //m_hudHeadingText->setColor( osg::Vec4(1.0, 1.0, 1.0, 1.0) ); > m_hudHeadingText->setCharacterSize(24); > m_hudHeadingText->setPosition( osg::Vec3(100.0f, 100.0f, -1.0f) ); > > osg::Geode* textGeode = new osg::Geode(); > textGeode->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, > osg::StateAttribute::OFF); > textGeode->getOrCreateStateSet()->setMode(GL_LIGHTING, > osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED); > > osg::MatrixTransform* textTransform = new osg::MatrixTransform; > osg::Matrix* textMatrix = new GMatrix; > //textTransform->setMatrix(osg::Matrix::translate(osg::Vec3d(300, 300, > 0))); > textTransform->setMatrix(osg::Matrix::identity()); > textTransform->addChild(textGeode); > > ////////////////////////////////////////////////////////////////////////// > > m_hudTransformable = new osg::Camera(); > m_hudTransformable->setReferenceFrame(GCamera::ABSOLUTE_RF); > m_hudTransformable->setAllowEventFocus(false); > m_hudTransformable->setRenderOrder(GCamera::POST_RENDER, 3); > m_hudTransformable->setProjectionMatrixAsOrtho2D(0.0, 500.0, 0.0, > 500.0); > m_hudTransformable->setViewport(0.0, 0.0, 500, 500); > m_hudTransformable->setClearMask(GL_DEPTH_BUFFER_BIT); > m_hudTransformable->setViewMatrix(GMatrix::identity()); > m_hudTransformable->getOrCreateStateSet()->setMode(GL_LIGHTING, > osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED); > m_hudTransformable->addChild(textTransform); > > return m_hudTransformable.get(); > } > > _______________________________________________ > 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

