一、osg::Text
特点:
可以加载在节点下,标签位置可以每一帧设置,但是内容无法每帧设置。
文字可以一直朝向屏幕
#include <osgViewer/Viewer>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osgText/Font>
#include <osgText/Text>
#include <osgDB/ReadFile>
int main()
{
osgViewer::Viewer viewer;
osg::Group* root = new osg::Group;
osg::Geode* geode = new osg::Geode;
root->addChild(geode);
osgText::Text* text1 = new osgText::Text;
text1->setFont("fonts/simhei.ttf");
text1->setCharacterSize(100.0);
text1->setPosition(osg::Vec3(0.0, 0.0, 0.0));
text1->setAxisAlignment(osgText::Text::SCREEN);
text1->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
text1->setText(L"中国");
geode->addDrawable(text1);
viewer.setSceneData(root);
return viewer.run();
}