TextShape::TextShape(std::string command, std::string name) { // check for changed values createParameter("pos", new Vec3Type()); createParameter("color", new Vec4Type()); createParameter("bcolor", new Vec4Type()); createParameter("enableOutline", new BoolType()); createParameter("size", new FloatType()); createParameter("label", new StringType()); createParameter("font", new StringType()); _type = SimpleShape::TEXT; BasicShape::setName(name); // default color is white for font setColor(osg::Vec4(1.0, 1.0, 1.0, 1.0)); // set a default background color setBackdropColor(osg::Vec4(0.0, 0.0, 0.0, 1.0)); setCharacterSize(10.0f); setFontResolution(40,40); osgText::Font* font = NULL; // check if fontMap has been constucted if ( _fontMap == NULL ) _fontMap = new ThreadMap< std::string, osgText::Font* >(); // check if font exists in map else load it and add it if( ! _fontMap->get(std::string("/usr/share/fonts/liberation/LiberationSans-Regular.ttf"), font) ) { font = osgText::readFontFile("/usr/share/fonts/liberation/LiberationSans-Regular.ttf"); _fontMap->add(std::string("/usr/share/fonts/liberation/LiberationSans-Regular.ttf"), font); } setFont(font); if( Globals::G_ROTAXIS ) setAxisAlignment(osgText::TextBase::XY_PLANE); else setAxisAlignment(osgText::TextBase::XZ_PLANE); // off by default setBackdropType(osgText::Text::NONE); osg::StateSet* state = osgText::Text::getOrCreateStateSet(); state->setMode(GL_BLEND, osg::StateAttribute::ON); state->setMode(GL_LIGHTING, osg::StateAttribute::OFF); //osg::Material* mat = new osg::Material(); //mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); //state->setAttributeAndModes(mat, osg::StateAttribute::ON); setUpdateCallback(new TextUpdateCallback()); update(command); }
TextShape::TextShape(std::string command, std::string name) { _type = SimpleShape::TEXT; BasicShape::setName(name); setColor(osg::Vec4(1.0, 1.0, 1.0, 1.0)); setCharacterSize(10.0f); setFontResolution(40,40); setFont ("/usr/share/fonts/liberation/LiberationSans-Regular.ttf"); setAxisAlignment(osgText::TextBase::XZ_PLANE); setBackdropType(osgText::Text::NONE); osg::StateSet* state = osgText::Text::getOrCreateStateSet(); state->setMode(GL_BLEND, osg::StateAttribute::ON); state->setMode(GL_LIGHTING, osg::StateAttribute::OFF); //osg::Material* mat = new osg::Material(); //mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); //state->setAttributeAndModes(mat, osg::StateAttribute::ON); setUpdateCallback(new TextUpdateCallback()); update(command); }