![]() |
I am trying to insert 3D models into the scene along with ShapeDrawables. In the attached case I am trying to have a plane fly surrounded by a sphere. The plane and sphere both show up but not at the same location. The planes texture is replaced by the solid color of the sphere but the sphere always appears to be on the horizon. Any thoughts would be greatly appreciated.
Bruce osg::Node* model = osgDB::readNodeFile(filename); if (model != NULL) { const osgEarth::SpatialReference *geoSRS = earthMapNode->getMapSRS(); osgEarth::GeoTransform *geo = new osgEarth::GeoTransform(); geo->setTerrain(earthMapNode->getTerrain()); osgEarth::AltitudeMode altMode = osgEarth::ALTMODE_ABSOLUTE; osgEarth::GeoPoint pos(geoSRS, longitude, latitude, altitude, altMode); geo->setPosition(pos); osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform(); pat->addChild(model); pat->setScale(osg::Vec3d(scale, scale, scale)); osg::Quat orientation = osg::Quat(osg::DegreesToRadians(roll), osg::Vec3(0, 1, 0)) * osg::Quat(osg::DegreesToRadians(pitch), osg::Vec3(1, 0, 0)) * osg::Quat(osg::DegreesToRadians(heading), osg::Vec3(0, 0, -1)); pat->setAttitude(orientation); geo->addChild(pat); mEntityGroup->addChild(geo); ///////////////// // draw the bubble osgEarth::GeoTransform *geo2 = new osgEarth::GeoTransform(); geo2->setTerrain(earthMapNode->getTerrain()); // altitude = 10000.0f; osgEarth::GeoPoint pos2(geoSRS, longitude, latitude, altitude, altMode); geo2->setPosition(pos2); osg::ShapeDrawable *_shapeDrawable; osg::TessellationHints* hints = new osg::TessellationHints; hints->setDetailRatio(0.5f); float _size = 1000.0; osg::Vec4 color = { 255,0,0,50 }; osg::Sphere* shape = new osg::Sphere(osg::Vec3(0, 0, 0), _size); _shapeDrawable = new osg::ShapeDrawable(shape, hints); if (_shapeDrawable != NULL) { _shapeDrawable->setDataVariance(osg::Object::DYNAMIC); _shapeDrawable->setColor(color); osg::Geode* geode = new osg::Geode(); if (geode != NULL) { geode->addDrawable(_shapeDrawable); geode->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); } scale = 100.0; osgEarth::GLUtils::setLighting(geode->getOrCreateStateSet(), osg::StateAttribute::OFF); osg::PositionAttitudeTransform *pat2 = new osg::PositionAttitudeTransform(); if (pat2 != NULL) { pat2->setScale(osg::Vec3d(scale, scale, scale)); pat2->addChild(geode); geo2->addChild(pat2); } mEntityGroup->addChild(geo2); } PlaneAndBubble.jpg |
Free forum by Nabble | Edit this page |