From: Mathias Froehlich Date: Sun, 20 Jan 2013 14:33:25 +0000 (+0100) Subject: spt: Put the sea level textured tiles also under a transform node. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2d72bf4308f14c8f8125d10442cf30957e0fe201;p=simgear.git spt: Put the sea level textured tiles also under a transform node. --- diff --git a/simgear/scene/tgdb/ReaderWriterSPT.cxx b/simgear/scene/tgdb/ReaderWriterSPT.cxx index e5e41a4a..2c0faba7 100644 --- a/simgear/scene/tgdb/ReaderWriterSPT.cxx +++ b/simgear/scene/tgdb/ReaderWriterSPT.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -269,6 +270,10 @@ ReaderWriterSPT::createSeaLevelTile(const BucketBox& bucketBox, const osgDB::Opt 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; @@ -286,7 +291,7 @@ ReaderWriterSPT::createSeaLevelTile(const BucketBox& bucketBox, const osgDB::Opt 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])); } @@ -308,14 +313,22 @@ ReaderWriterSPT::createSeaLevelTile(const BucketBox& bucketBox, const osgDB::Opt 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 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