[osg-users] Draw text on osg Sphere

Inna Reddy narendra.nath418 at gmail.com
Wed Sep 21 09:14:05 PDT 2016


Hi,

I am very beginner for OSG and my first post in Forum. Currently  , I am able to draw the text on the Ellipsoid , suing the lat , log and height. How I achieve the same with sphere instead of Ellipsoid.


Code:
osgText::Text* createText(osg::EllipsoidModel* ellipsoid, double latitude, double longitude, double height, const std::string& str)
	{

		double X, Y, Z;
		ellipsoid->convertLatLongHeightToXYZ(osg::DegreesToRadians(latitude), osg::DegreesToRadians(longitude), height, X, Y, Z);


		osgText::Text* text = new osgText::FadeText;	
		text->setDrawMode(osgText::Text::TEXT | osgText::Text::BOUNDINGBOX);
	
		osg::Vec3 normal = ellipsoid->computeLocalUpVector(X, Y, Z);
		text->setCullCallback(new osg::ClusterCullingCallback(osg::Vec3(X, Y, Z), normal, 0.0));

		text->setText(str);
		text->setFont("fonts/arial.ttf");
		
		text->setPosition(osg::Vec3(X, Y, Z));		
		text->setCharacterSize(300000.0f);//can not be set the const font size. this varry basing on the weight of  the word
		text->setColor(osg::Vec4(0.0f, 1.0f, 1.0, 1.0f));
		//text->setFontResolution(256, 256);
		text->setCharacterSizeMode(osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT);
		text->setAutoRotateToScreen(true);

		return text;
	}


Thank you!

Cheers,
InnaReddy[/code]

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








More information about the osg-users mailing list