diff --git a/src/ui/map3D/Pixhawk3DWidget.cc b/src/ui/map3D/Pixhawk3DWidget.cc index 931f1969b8b1392092872552ae775f9f20f5cb6d..ea3b7b5deed5826bf18434c18921c2c28d602278 100644 --- a/src/ui/map3D/Pixhawk3DWidget.cc +++ b/src/ui/map3D/Pixhawk3DWidget.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include "../MainWindow.h" #include "PixhawkCheetahGeode.h" @@ -236,6 +237,29 @@ Pixhawk3DWidget::localPositionChanged(UASInterface* uas, int component, geode->addDrawable(sd); group->addChild(geode); + // text indicates component id + osg::ref_ptr text = new osgText::Text; + text->setFont(m3DWidget->font()); + text->setText(QString::number(component).toStdString().c_str()); + text->setColor(color); + text->setCharacterSize(0.3f); + text->setAxisAlignment(osgText::Text::XY_PLANE); + text->setAlignment(osgText::Text::CENTER_CENTER); + text->setPosition(osg::Vec3(0.0, -0.8, 0.0)); + + sd = new osg::ShapeDrawable; + osg::ref_ptr textBox = + new osg::Box(osg::Vec3(0.0, -0.8, -0.01), 0.7, 0.4, 0.01); + + sd->setShape(textBox); + sd->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); + sd->setColor(osg::Vec4(0.0, 0.0, 0.0, 1.0)); + + geode = new osg::Geode; + geode->addDrawable(text); + geode->addDrawable(sd); + group->addChild(geode); + pat = new osg::PositionAttitudeTransform; pat->addChild(group); systemData.orientationNode()->addChild(pat);