OsgEarth rotate object

classic Classic list List threaded Threaded
1 message Options
marcoma9023 marcoma9023
Reply | Threaded
Open this post in threaded view
|

OsgEarth rotate object

Hi,

I needed to create an object that identified the selection on a target.
So I created 8 corners.

Each corner is created as: osgEarth::Symbology::Geometry* line1 = new LineString() using push_back.

Then, with 8 corner I created 8 different line. Then, to draw it, I added the line to the Feature and FeatureNode.

The used code:

        osgEarth::Symbology::Geometry* line1 = new LineString();
        line1->push_back((point.x() + 0.00025), (point.y() + 0.00006), 18);
        line1->push_back((point.x() + 0.00020), (point.y() + 0.00006), 18);

        line1->push_back((point.x() + 0.00025), (point.y() + 0.00006), 18);
        line1->push_back((point.x() + 0.00025), (point.y() + 0.000031), 18);
       
        line1->push_back((point.x() + 0.00025), (point.y() + 0.00006), 18);
        line1->push_back((point.x() + 0.00025), (point.y() + 0.00006), 17);
        //corner h-dx-dx
        osgEarth::Symbology::Geometry* line2 = new LineString();
        line2->push_back((point.x() + 0.00025), (point.y() - 0.00006), 18);
        line2->push_back((point.x() + 0.00020), (point.y() - 0.00006), 18);

        line2->push_back((point.x() + 0.00025), (point.y() - 0.00006), 18);
        line2->push_back((point.x() + 0.00025), (point.y() - 0.000031), 18);

        line2->push_back((point.x() + 0.00025), (point.y() - 0.00006), 18);
        line2->push_back((point.x() + 0.00025), (point.y() - 0.00006), 17);
        //corner h-sx-sx
        osgEarth::Symbology::Geometry* line3 = new LineString();
        line3->push_back((point.x() - 0.00020), (point.y() + 0.00006), 18);
        line3->push_back((point.x() - 0.00025), (point.y() + 0.00006), 18);
       
        line3->push_back((point.x() - 0.00025), (point.y() + 0.00006), 18);
        line3->push_back((point.x() - 0.00025), (point.y() + 0.000031), 18);
       
        line3->push_back((point.x() - 0.00025), (point.y() + 0.000031), 18);
        line3->push_back((point.x() - 0.00025), (point.y() + 0.00006), 18);
       
        line3->push_back((point.x() - 0.00025), (point.y() + 0.00006), 18);
        line3->push_back((point.x() - 0.00025), (point.y() + 0.00006), 17);
        //corner h-sx-dx
        osgEarth::Symbology::Geometry* line4 = new LineString();
        line4->push_back((point.x() - 0.00025), (point.y() - 0.00006), 18);
        line4->push_back((point.x() - 0.00020), (point.y() - 0.00006), 18);

        line4->push_back((point.x() - 0.00025), (point.y() - 0.00006), 18);
        line4->push_back((point.x() - 0.00025), (point.y() - 0.000031), 18);

        line4->push_back((point.x() - 0.00025), (point.y() - 0.00006), 18);
        line4->push_back((point.x() - 0.00025), (point.y() - 0.00006), 17);

        //corner d-dx-sx
        osgEarth::Symbology::Geometry* line5 = new LineString();
        line5->push_back((point.x() + 0.00025), (point.y() + 0.00006), -6);
        line5->push_back((point.x() + 0.00020), (point.y() + 0.00006), -6);

        line5->push_back((point.x() + 0.00025), (point.y() + 0.00006), -6);
        line5->push_back((point.x() + 0.00025), (point.y() + 0.000031), -6);

        line5->push_back((point.x() + 0.00025), (point.y() + 0.00006), -6);
        line5->push_back((point.x() + 0.00025), (point.y() + 0.00006), -5);
        //corner d-dx-dx
        osgEarth::Symbology::Geometry* line6 = new LineString();
        line6->push_back((point.x() + 0.00025), (point.y() - 0.00006), -6);
        line6->push_back((point.x() + 0.00020), (point.y() - 0.00006), -6);

        line6->push_back((point.x() + 0.00025), (point.y() - 0.00006), -6);
        line6->push_back((point.x() + 0.00025), (point.y() - 0.000031), -6);

        line6->push_back((point.x() + 0.00025), (point.y() - 0.00006), -6);
        line6->push_back((point.x() + 0.00025), (point.y() - 0.00006), -5);
        //corner d-sx-sx
        osgEarth::Symbology::Geometry* line7 = new LineString();
        line7->push_back((point.x() - 0.00020), (point.y() + 0.00006), -6);
        line7->push_back((point.x() - 0.00025), (point.y() + 0.00006), -6);
       
        line7->push_back((point.x() - 0.00025), (point.y() + 0.00006), -6);
        line7->push_back((point.x() - 0.00025), (point.y() + 0.000031), -6);

        line7->push_back((point.x() - 0.00025), (point.y() + 0.000031), -6);
        line7->push_back((point.x() - 0.00025), (point.y() + 0.00006), -6);

        line7->push_back((point.x() - 0.00025), (point.y() + 0.00006), -6);
        line7->push_back((point.x() - 0.00025), (point.y() + 0.00006), -5);
        //corner d-sx-dx
        osgEarth::Symbology::Geometry* line8 = new LineString();
        line8->push_back((point.x() - 0.00025), (point.y() - 0.00006), -6);
        line8->push_back((point.x() - 0.00020), (point.y() - 0.00006), -6);

        line8->push_back((point.x() - 0.00025), (point.y() - 0.00006), -6);
        line8->push_back((point.x() - 0.00025), (point.y() - 0.000031), -6);

        line8->push_back((point.x() - 0.00025), (point.y() - 0.00006), -6);
        line8->push_back((point.x() - 0.00025), (point.y() - 0.00006), -5);

        Feature* feature1 = new Feature(line1, geoSRS, shapeStyle);
        Feature* feature2 = new Feature(line2, geoSRS, shapeStyle);
        Feature* feature3 = new Feature(line3, geoSRS, shapeStyle);
        Feature* feature4 = new Feature(line4, geoSRS, shapeStyle);
        Feature* feature5 = new Feature(line5, geoSRS, shapeStyle);
        Feature* feature6 = new Feature(line6, geoSRS, shapeStyle);
        Feature* feature7 = new Feature(line7, geoSRS, shapeStyle);
        Feature* feature8 = new Feature(line8, geoSRS, shapeStyle);
        feature1->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature2->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature3->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature4->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature5->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature6->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature7->geoInterp() = GEOINTERP_RHUMB_LINE;
        feature8->geoInterp() = GEOINTERP_RHUMB_LINE;
        FeatureNode* featureNode1 = new FeatureNode(feature1);
        FeatureNode* featureNode2 = new FeatureNode(feature2);
        FeatureNode* featureNode3 = new FeatureNode(feature3);
        FeatureNode* featureNode4 = new FeatureNode(feature4);
        FeatureNode* featureNode5 = new FeatureNode(feature5);
        FeatureNode* featureNode6 = new FeatureNode(feature6);
        FeatureNode* featureNode7 = new FeatureNode(feature7);
        FeatureNode* featureNode8 = new FeatureNode(feature8);

        osg::Group* annoGroup = new osg::Group();
        annoGroup->addChild(featureNode1);
        annoGroup->addChild(featureNode2);
        annoGroup->addChild(featureNode3);
        annoGroup->addChild(featureNode4);
        annoGroup->addChild(featureNode5);
        annoGroup->addChild(featureNode6);
        annoGroup->addChild(featureNode7);
        annoGroup->addChild(featureNode8);
       
        mapNode->addChild(annoGroup);

Then, is it possible to create an object that contains all lines (or all Features) and rotate it in simple way?

Thanks!