]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/tgdb/SGOceanTile.cxx
simgear/scene/sky/sky.cxx: Include sg_inlines.h with simgear/ prefix as all other...
[simgear.git] / simgear / scene / tgdb / SGOceanTile.cxx
index 9ff60f3e0c8729b84371968b5bef7ef0af3655fe..2907bbacd691bf3a1e4b86fe92742e2bdbde69cd 100644 (file)
@@ -81,7 +81,7 @@ public:
     SGVec3f normals[latPoints][lonPoints];
     SGVec3d rel[latPoints][lonPoints];
 
-    point_list geod_nodes;
+    std::vector<SGGeod> geod_nodes;
 
     osg::Vec3Array* vl;
     osg::Vec3Array* nl;
@@ -122,27 +122,31 @@ void OceanMesh::calcMesh(const SGVec3d& cartCenter, const SGQuatd& orient,
     }
     
     // Calculate texture coordinates
-    point_list geod_nodes(latPoints * lonPoints);
-    VectorArrayAdapter<point_list> geodNodesArray(geod_nodes, lonPoints);
+    typedef std::vector<SGGeod> GeodVector;
+    
+    GeodVector geod_nodes(latPoints * lonPoints);
+    VectorArrayAdapter<GeodVector> geodNodesArray(geod_nodes, lonPoints);
     int_list rectangle(latPoints * lonPoints);
     VectorArrayAdapter<int_list> rectArray(rectangle, lonPoints);
     for (int j = 0; j < latPoints; j++) {
         for (int i = 0; i < lonPoints; i++) {
-            geodNodesArray(j, i) = Point3D(geod[j][i].getLongitudeDeg(),
-                                           geod[j][i].getLatitudeDeg(),
-                                           geod[j][i].getElevationM());
+            geodNodesArray(j, i) = geod[j][i];
             rectArray(j, i) = j * 5 + i;
         }
     }
-    point_list texs = sgCalcTexCoords( clat, geod_nodes, rectangle, 
+    
+    typedef std::vector<SGVec2f> Vec2Array;
+    Vec2Array texs = sgCalcTexCoords( clat, geod_nodes, rectangle, 
                                        1000.0 / tex_width );
-    VectorArrayAdapter<point_list> texsArray(texs, lonPoints);
+                                
+                                       
+    VectorArrayAdapter<Vec2Array> texsArray(texs, lonPoints);
   
     for (int j = 0; j < latPoints; j++) {
         for (int i = 0; i < lonPoints; ++i) {
-            vlArray(j, i) = rel[j][i].osg();
-            nlArray(j, i) = normals[j][i].osg();
-            tlArray(j, i) = texsArray(j, i).toSGVec2f().osg();
+            vlArray(j, i) = toOsg(rel[j][i]);
+            nlArray(j, i) = toOsg(normals[j][i]);
+            tlArray(j, i) = toOsg(texsArray(j, i));
         }
     }
 
@@ -277,7 +281,7 @@ osg::Node* SGOceanTile(const SGBucket& b, SGMaterialLib *matlib)
     // Calculate center point
     SGVec3d cartCenter = SGVec3d::fromGeod(b.get_center());
     SGGeod geodPos = SGGeod::fromCart(cartCenter);
-    SGQuatd hlOr = SGQuatd::fromLonLat(geodPos);
+    SGQuatd hlOr = SGQuatd::fromLonLat(geodPos)*SGQuatd::fromEulerDeg(0, 0, 180);
 
     double clon = b.get_center_lon();
     double clat = b.get_center_lat();
@@ -310,11 +314,12 @@ osg::Node* SGOceanTile(const SGBucket& b, SGMaterialLib *matlib)
     geode->setName("Ocean tile");
     geode->setEffect(effect);
     geode->addDrawable(geometry);
+    geode->runGenerators(geometry);
 
     osg::MatrixTransform* transform = new osg::MatrixTransform;
     transform->setName("Ocean");
-    transform->setMatrix(osg::Matrix::rotate(hlOr.osg())*
-                         osg::Matrix::translate(cartCenter.osg()));
+    transform->setMatrix(osg::Matrix::rotate(toOsg(hlOr))*
+                         osg::Matrix::translate(toOsg(cartCenter)));
     transform->addChild(geode);
   
     return transform;