[osg-users] adding object models in osgEarth best practices

David Bobavid david.bobavid at gmail.com
Thu May 2 11:27:30 PDT 2019


Hi Eran,

Yes, sure... this is what I'm doing:

First to load my map:

Code:

_map = new osgEarth::Map();

osgEarth::Drivers::GDALOptions basemap;
basemap.url() = "I:/Dev/QtOsgTest1/data/world.tif";
_map->addLayer(new ImageLayer(ImageLayerOptions("basemap", basemap)));

_mapNode = new osgEarth::MapNode(_map);





Then later to load the model:

Code:


auto model = osgDB::readNodeFile("I:/Dev/QtOsgTest1/data/cow.osg");
if (!model) {
qDebug() << "Oh shit, model didn't load!";
}

auto transform = new osg::MatrixTransform;
transform->setMatrix(osg::Matrix::scale(100, 100, 100));
if (!transform->addChild(model)) {
qDebug() << "Failed adding model to matrix transform";
}

auto geoTransform = new osgEarth::GeoTransform;
geoTransform->setTerrain(_mapNode->getTerrain());
if (!geoTransform->setPosition(osgEarth::GeoPoint(_mapNode->getMapSRS()->getGeographicSRS(), -100, 52, 1000))) {
qDebug() << "Setting position failed";
}

if (!geoTransform->addChild(transform)) {
qDebug() << "Adding matrix transform to geotransform failed";
}

_mapNode->addChild(geoTransform);




I don't see the model show up, but I also don't see any of my error statements, either. 

Thanks again,
david

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75941#75941







More information about the osg-users mailing list