| | 152 | osg::Node* createAutoScale(const osg::Vec3& position, float characterSize, const std::string& message, float minScale=0.0, float maxScale=FLT_MAX) |
| | 153 | { |
| | 154 | std::string timesFont("fonts/arial.ttf"); |
| | 155 | |
| | 156 | osgText::Text* text = new osgText::Text; |
| | 157 | text->setCharacterSize(characterSize); |
| | 158 | text->setText(message); |
| | 159 | text->setFont(timesFont); |
| | 160 | text->setAlignment(osgText::Text::CENTER_CENTER); |
| | 161 | |
| | 162 | osg::Geode* geode = new osg::Geode; |
| | 163 | geode->addDrawable(text); |
| | 164 | geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); |
| | 165 | |
| | 166 | osg::AutoTransform* at = new osg::AutoTransform; |
| | 167 | at->addChild(geode); |
| | 168 | |
| | 169 | at->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN); |
| | 170 | at->setAutoScaleToScreen(true); |
| | 171 | at->setMinimumScale(minScale); |
| | 172 | at->setMaximumScale(maxScale); |
| | 173 | at->setPosition(position); |
| | 174 | |
| | 175 | return at; |
| | 176 | } |
| | 177 | |
| 159 | 185 | root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1000.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_SCREEN,osgText::Text::XY_PLANE, "ROTATE_TO_SCREEN")); |
| 160 | 186 | root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE, "NO_ROTATION")); |
| 161 | | |
| | 187 | |
| | 188 | root->addChild(createAutoScale(osg::Vec3(500.0,500.0,500.0), 25.0, "AutoScale with no min, max limits")); |
| | 189 | root->addChild(createAutoScale(osg::Vec3(500.0,500.0,300.0), 25.0, "AutoScale with minScale = 1, maxScale = 2.0 ", 1, 2.0)); |
| | 190 | root->addChild(createAutoScale(osg::Vec3(500.0,500.0,700.0), 25.0, "AutoScale with minScale = 0.0, maxScale = 5.0 ", 0.0, 5.0)); |