Hello everyone! :D

We are porting our application from OSG 2.9.8 to OSG 3.0.0 but the 
osgText::Text is not working properly. I am creating an osgText::Text with 
SCREEN axis alignment and SCREEN_COORDS character size mode, but it does not 
show up. In order to make it show up I have to create a random drawable 
(drawables with zero size eg. sphere with zero radius won't work) and add it to 
the osgText::Text's Geode. At the start I thought I was doing something wrong. 
So, I stripped down the osgText Example and I realized that the example has the 
same problem. If you trip down everything but 'text5' text, and  remove the 
sphere that is attached on the 'text5' text's geode, then you won't be able to 
see the text. Now, If you  take this code and compile it using OSG 2.9.8 the 
text will be visible!
Am I missing something?
Here is a simple example of the problem. Ready to compile and run (just add the 
headers):

Code:

osgText::Text* createText( const osg::Vec3& position )
{
    osgText::Text* text = new osgText::Text();
    text->setColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
    text->setCharacterSize(32.0f);
    text->setPosition(position);
    text->setAxisAlignment(osgText::Text::SCREEN);
    text->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
    text->setDrawMode(osgText::Text::TEXT | osgText::Text::BOUNDINGBOX);
    text->setText("CharacterSizeMode SCREEN_COORDS(size 32.0)");
    return text;
}

int main( int agc, char** argv )
{
    osg::Group* root = new osg::Group;

    osgText::Text* text01 = createText( osg::Vec3(0.0f,0.0f,0.0f) );
    osg::Geode* text01Geode = new osg::Geode();
    text01Geode->addDrawable(text01);
    root->addChild(text01Geode);

    /// uncomment the following two lines and the text will appear!
    //osg::ShapeDrawable* shape = new osg::ShapeDrawable(new 
osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),0.00001f));
    //text01Geode->addDrawable(shape);
    
    osgViewer::Viewer viewer;
    viewer.setSceneData(root);
    viewer.setUpViewInWindow(50,50,800,600);
    viewer.run();

    return EXIT_SUCCESS;
}



Thank you for your time!

Cheers,
George

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41099#41099





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to