have a look at osgWidget::Input. There is a code snippet that calculates the text bounds ....
-Nick On Wed, Apr 14, 2010 at 1:03 AM, Chris Innanen <[email protected]> wrote: > Shortly after my last post, I got moved away from working on a HUD, before > I had actually solved the above problem. > > I've spent the better part of today working on this again, and have been > unable to get a valid BoundingBox from my osgText object. Here's the code > chunk in question: > > > Code: > // create a transform and geode to hold the text drawable > m_pTransform = new osg::MatrixTransform; > m_pGeode = new osg::Geode; > m_pText = new osgText::Text; > > // link them all together > UIManager::I()->GetUISubRoot()->addChild( m_pTransform ); > m_pTransform->addChild( m_pGeode ); > m_pGeode->addDrawable( m_pText ); > > // create text from string > m_pText->setCharacterSize( aiSize ); > m_pText->setFont( "C:/WINDOWS/Fonts/impact.ttf" ); > m_pText->setText( asText.c_str() ); > m_pText->setAxisAlignment( osgText::Text::SCREEN ); > m_pText->setColor( osg::Vec4( aiR, aiG, aiB, aiA ) ); > m_pText->setPosition( osg::Vec3( 0, 0, 0 ) ); > m_pText->setCharacterSizeMode( osgText::Text::OBJECT_COORDS ); > if ( m_bRightJustified ) > m_pText->setAlignment( osgText::TextBase::RIGHT_BASE_LINE ); > else > m_pText->setAlignment( osgText::TextBase::LEFT_BASE_LINE ); > > // determine size extents of the text > osg::BoundingBox box = m_pText->computeBound(); > int w = box.xMax() - box.xMin(); > int h = box.yMax() - box.yMin(); > > > > w and h are not correct at this point. The text does display correctly, but > I need to adjust its placement based on its height and width. > > I've tried far more that just this, running through quite a number of > functions both in Text and TextBase. I've looked through some example apps > for this. I've searched the forums and the web at large for examples. I'm > stuck. > > ~ Chris Innanen > ~ Nonsanity > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=26746#26746 > > > > > > _______________________________________________ > 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

