Cleaned up example

This commit is contained in:
Robert Osfield 2011-04-19 09:53:34 +00:00
parent c1cd0c4f3b
commit 36f755670b

View File

@ -386,6 +386,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
osg::Geode* geode = new osg::Geode; osg::Geode* geode = new osg::Geode;
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Examples of how to set up axis/orientation alignments // Examples of how to set up axis/orientation alignments
@ -393,6 +394,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
float characterSize=radius*0.2f; float characterSize=radius*0.2f;
osg::Vec3 pos(center.x()-radius*.5f,center.y()-radius*.5f,center.z()-radius*.5f); osg::Vec3 pos(center.x()-radius*.5f,center.y()-radius*.5f,center.z()-radius*.5f);
osgText::Text* text1 = new osgText::Text; osgText::Text* text1 = new osgText::Text;
@ -419,6 +421,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
text3->setText("XZ_PLANE"); text3->setText("XZ_PLANE");
geode->addDrawable(text3); geode->addDrawable(text3);
osg::Vec4 characterSizeModeColor(1.0f,0.0f,0.5f,1.0f);
osgText::Text* text4 = new osgText::Text; osgText::Text* text4 = new osgText::Text;
text4->setFont("fonts/times.ttf"); text4->setFont("fonts/times.ttf");
@ -426,7 +429,12 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
text4->setPosition(center); text4->setPosition(center);
text4->setAxisAlignment(osgText::Text::SCREEN); text4->setAxisAlignment(osgText::Text::SCREEN);
osg::Vec4 characterSizeModeColor(1.0f,0.0f,0.5f,1.0f); // reproduce outline bounding box compute problem with backdrop on.
text4->setBackdropType(osgText::Text::OUTLINE);
text4->setDrawMode(osgText::Text::TEXT | osgText::Text::BOUNDINGBOX);
text4->setText("SCREEN");
geode->addDrawable(text4);
osgText::Text* text5 = new osgText::Text; osgText::Text* text5 = new osgText::Text;
text5->setColor(characterSizeModeColor); text5->setColor(characterSizeModeColor);
@ -436,6 +444,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
text5->setPosition(center - osg::Vec3(0.0, 0.0, 0.2)); text5->setPosition(center - osg::Vec3(0.0, 0.0, 0.2));
text5->setAxisAlignment(osgText::Text::SCREEN); text5->setAxisAlignment(osgText::Text::SCREEN);
text5->setCharacterSizeMode(osgText::Text::SCREEN_COORDS); text5->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
text5->setDrawMode(osgText::Text::TEXT | osgText::Text::BOUNDINGBOX);
text5->setText("CharacterSizeMode SCREEN_COORDS(size 32.0)"); text5->setText("CharacterSizeMode SCREEN_COORDS(size 32.0)");
geode->addDrawable(text5); geode->addDrawable(text5);
@ -459,14 +468,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
text7->setText("CharacterSizeMode OBJECT_COORDS (default)"); text7->setText("CharacterSizeMode OBJECT_COORDS (default)");
geode->addDrawable(text7); geode->addDrawable(text7);
#if 1
// reproduce outline bounding box compute problem with backdrop on.
text4->setBackdropType(osgText::Text::OUTLINE);
text4->setDrawMode(osgText::Text::TEXT | osgText::Text::BOUNDINGBOX);
#endif
text4->setText("SCREEN");
geode->addDrawable(text4);
osg::ShapeDrawable* shape = new osg::ShapeDrawable(new osg::Sphere(center,characterSize*0.2f)); osg::ShapeDrawable* shape = new osg::ShapeDrawable(new osg::Sphere(center,characterSize*0.2f));
shape->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::ON); shape->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::ON);
@ -679,6 +681,7 @@ int main(int argc, char** argv)
// make sure the root node is group so we can add extra nodes to it. // make sure the root node is group so we can add extra nodes to it.
osg::Group* group = new osg::Group; osg::Group* group = new osg::Group;
if (true)
{ {
// create the hud. // create the hud.
osg::Camera* camera = new osg::Camera; osg::Camera* camera = new osg::Camera;
@ -692,7 +695,10 @@ int main(int argc, char** argv)
group->addChild(camera); group->addChild(camera);
} }
group->addChild(create3DText(center,radius)); if (true)
{
group->addChild(create3DText(center,radius));
}
// set the scene to render // set the scene to render
viewer.setSceneData(group); viewer.setSceneData(group);