Why does osg::AutoTransform node disappear when the scene is first created?

33 views
Skip to first unread message

mirr...@gmail.com

unread,
Mar 8, 2021, 12:08:51 AM3/8/21
to OpenSceneGraph Users
   evn is win10&osg3.6.4 

   Why does osg::AutoTransform disappears after using the set setAutoRotateMode           method to be  true .  
    //
    std::string timesFont("fonts/arial.ttf");
    osgText::Text* text = new osgText::Text;
    text->setCharacterSize(characterSize);
    text->setText(message);
    text->setFont(timesFont);
    text->setAlignment(osgText::Text::CENTER_CENTER);

    osg::Geode* geode = new osg::Geode;
    geode->addDrawable(text);
    geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

    osg::AutoTransform* at = new osg::AutoTransform;
    at->addChild(geode);

    at->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
    at->setAutoScaleToScreen(true);
    at->setMinimumScale(minScale);
    at->setMaximumScale(maxScale);
    at->setPosition(position);

QQ图片20210308125825.jpg 

Robert Osfield

unread,
Mar 8, 2021, 4:25:41 AM3/8/21
to OpenSceneGraph Users, OpenSceneGraph Users
Hi ?

There isn't any way to know what settings are provoking these errors, the best thing you can do is compile a debug version of the OSG and then setup into the AutoTransform traverse method to figure out what maths is being invoked and when the errors are occurring.

The only thing I can add is that osgText::Text has support for rotating to screen and automatically scaling that for most purposes will make osg::AutoTransform rendundent.  I would try to just use osgText::Text's support for scaling and rotating and ditch the osg::AutoTransform. You'll get better performance too.

Cheers,
Robert.

mirr...@gmail.com

unread,
Mar 10, 2021, 6:39:24 AM3/10/21
to OpenSceneGraph Users
Thank you for your question and answer.I have tested Geode to add OSG ::Geometry and this error will also occur?
Reply all
Reply to author
Forward
0 new messages