X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Ftgdb%2FSGOceanTile.cxx;h=9ff60f3e0c8729b84371968b5bef7ef0af3655fe;hb=c3b1802e956db11c2b06d354d90bca3ca9622a7b;hp=af1dddf4914e46719b92bac6656395e4d2f7ba4e;hpb=6c30f6269388c8eb4b850e4817567c06f79c8d80;p=simgear.git diff --git a/simgear/scene/tgdb/SGOceanTile.cxx b/simgear/scene/tgdb/SGOceanTile.cxx index af1dddf4..9ff60f3e 100644 --- a/simgear/scene/tgdb/SGOceanTile.cxx +++ b/simgear/scene/tgdb/SGOceanTile.cxx @@ -37,8 +37,11 @@ #include #include #include +#include +#include #include #include + #include using namespace simgear; @@ -87,7 +90,8 @@ public: VectorArrayAdapter nlArray; VectorArrayAdapter tlArray; - void calcMesh(const SGVec3d& cartCenter, double clon, double clat, + void calcMesh(const SGVec3d& cartCenter, const SGQuatd& orient, + double clon, double clat, double height, double width, double tex_width); void calcApronPt(int latIdx, int lonIdx, int latInner, int lonInner, int destIdx, double tex_width); @@ -96,7 +100,8 @@ public: }; } -void OceanMesh::calcMesh(const SGVec3d& cartCenter, double clon, double clat, +void OceanMesh::calcMesh(const SGVec3d& cartCenter, const SGQuatd& orient, + double clon, double clat, double height, double width, double tex_width) { // Calculate vertices. By splitting the tile up into 4 quads on a @@ -111,8 +116,8 @@ void OceanMesh::calcMesh(const SGVec3d& cartCenter, double clon, double clat, for (int i = 0; i < lonPoints; i++) { geod[j][i] = SGGeod::fromDeg(startLon + i * longInc, lat); SGVec3d cart = SGVec3d::fromGeod(geod[j][i]); - rel[j][i] = cart - cartCenter; - normals[j][i] = toVec3f(normalize(cart)); + rel[j][i] = orient.transform(cart - cartCenter); + normals[j][i] = toVec3f(orient.transform(normalize(cart))); } } @@ -252,7 +257,7 @@ void fillDrawElementsWithApron(short height, short width, osg::Node* SGOceanTile(const SGBucket& b, SGMaterialLib *matlib) { - osg::StateSet *stateSet = 0; + Effect *effect = 0; double tex_width = 1000.0; @@ -264,20 +269,22 @@ osg::Node* SGOceanTile(const SGBucket& b, SGMaterialLib *matlib) tex_width = mat->get_xsize(); // set OSG State - stateSet = mat->get_state(); + effect = mat->get_effect(); } else { SG_LOG( SG_TERRAIN, SG_ALERT, "Ack! unknown use material name = Ocean"); } OceanMesh grid; // Calculate center point SGVec3d cartCenter = SGVec3d::fromGeod(b.get_center()); - + SGGeod geodPos = SGGeod::fromCart(cartCenter); + SGQuatd hlOr = SGQuatd::fromLonLat(geodPos); + double clon = b.get_center_lon(); double clat = b.get_center_lat(); double height = b.get_height(); double width = b.get_width(); - grid.calcMesh(cartCenter, clon, clat, height, width, tex_width); + grid.calcMesh(cartCenter, hlOr, clon, clat, height, width, tex_width); grid.calcApronPts(tex_width); osg::Vec4Array* cl = new osg::Vec4Array; @@ -299,14 +306,15 @@ osg::Node* SGOceanTile(const SGBucket& b, SGMaterialLib *matlib) fillDrawElementsWithApron(latPoints, lonPoints, drawElements->begin()); geometry->addPrimitiveSet(drawElements); - osg::Geode* geode = new osg::Geode; + EffectGeode* geode = new EffectGeode; geode->setName("Ocean tile"); + geode->setEffect(effect); geode->addDrawable(geometry); - geode->setStateSet(stateSet); osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setName("Ocean"); - transform->setMatrix(osg::Matrix::translate(cartCenter.osg())); + transform->setMatrix(osg::Matrix::rotate(hlOr.osg())* + osg::Matrix::translate(cartCenter.osg())); transform->addChild(geode); return transform;