#include <osg/CullFace>
#include <osg/PagedLOD>
+#include <osg/MatrixTransform>
#include <osg/Texture2D>
#include <osgDB/FileNameUtils>
if (options->getPluginStringData("SimGear::FG_EARTH") != "ON")
return 0;
+ SGSpheref sphere = bucketBox.getBoundingSphere();
+ osg::Matrixd transform;
+ transform.makeTranslate(toOsg(-sphere.getCenter()));
+
osg::Vec3Array* vertices = new osg::Vec3Array;
osg::Vec3Array* normals = new osg::Vec3Array;
osg::Vec2Array* texCoords = new osg::Vec2Array;
SGVec2f t[6];
unsigned num = bucketBox.getTileTriangles(i, j, incx, incy, v, n, t);
for (unsigned k = 0; k < num; ++k) {
- vertices->push_back(toOsg(v[k]));
+ vertices->push_back(transform.preMult(toOsg(v[k])));
normals->push_back(toOsg(n[k]));
texCoords->push_back(toOsg(t[k]));
}
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setTexCoordArray(0, texCoords);
- geometry->addPrimitiveSet(new osg::DrawArrays(osg::DrawArrays::TRIANGLES, 0, vertices->size()));
+ osg::DrawArrays* drawArrays = new osg::DrawArrays(osg::DrawArrays::TRIANGLES, 0, vertices->size());
+ drawArrays->setDataVariance(osg::Object::STATIC);
+ geometry->addPrimitiveSet(drawArrays);
osg::Geode* geode = new osg::Geode;
+ geode->setDataVariance(osg::Object::STATIC);
geode->addDrawable(geometry);
osg::ref_ptr<osg::StateSet> stateSet = getLowLODStateSet(options);
geode->setStateSet(stateSet.get());
- return geode;
+ transform.makeTranslate(toOsg(sphere.getCenter()));
+ osg::MatrixTransform* matrixTransform = new osg::MatrixTransform(transform);
+ matrixTransform->setDataVariance(osg::Object::STATIC);
+ matrixTransform->addChild(geode);
+
+ return matrixTransform;
}
osg::ref_ptr<osg::StateSet>