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

Eran Cohen ceranco at gmail.com
Thu May 2 08:03:25 PDT 2019


Hi David,

If you're adding a model from code, you can simple load it normally using osgDB::readNodeFile and place it under an osgEarth::GeoTransform to transform to the correct location:


Code:

auto model = osgDB::readNodeFile("path-to-model");

auto geoTransform = new osgEarth::GeoTransform;
geoTransform->addChild(model);

...





GeoTransform can place the model using a GeoPoint and orients correctly so that the Z-axis down is toward the earth.

To scale and rotate the model, simply put it under an additional transform:

Code:

auto model = osgDB::readNodeFile("path-to-model");

auto transform = new osg::MatrixTransform;
transform->setMatrix(osg::Matrix::scale(10, 10, 10));
transform->addChild(model);

auto geoTransform = new osgEarth::GeoTransform;
geoTransform->addChild(transform);

...




Cheers,
Eran

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







More information about the osg-users mailing list