]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/cloud.cxx
Improved tile cache priority scheme.
[simgear.git] / simgear / scene / sky / cloud.cxx
index 72462cc7c03b199b44882b598a0a2517783559b6..0c5b6e21acf7d8f3f03267660df7b2deca8a5297 100644 (file)
@@ -54,6 +54,7 @@
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
+#include <simgear/screen/extensions.hxx>
 
 #include "newcloud.hxx"
 #include "cloudfield.hxx"
@@ -82,6 +83,13 @@ static bool bump_mapping = false;
 
 bool SGCloudLayer::enable_bump_mapping = false;
 
+const std::string SGCloudLayer::SG_CLOUD_OVERCAST_STRING = "overcast";
+const std::string SGCloudLayer::SG_CLOUD_BROKEN_STRING = "broken";
+const std::string SGCloudLayer::SG_CLOUD_SCATTERED_STRING = "scattered";
+const std::string SGCloudLayer::SG_CLOUD_FEW_STRING = "few";
+const std::string SGCloudLayer::SG_CLOUD_CIRRUS_STRING = "cirrus";
+const std::string SGCloudLayer::SG_CLOUD_CLEAR_STRING = "clear";
+
 // make an StateSet for a cloud layer given the named texture
 static osg::StateSet*
 SGMakeState(const SGPath &path, const char* colorTexture,
@@ -292,6 +300,56 @@ SGCloudLayer::setCoverage (Coverage coverage)
     }
 }
 
+const std::string &
+SGCloudLayer::getCoverageString( Coverage coverage )
+{
+       switch( coverage ) {
+               case SG_CLOUD_OVERCAST:
+                       return SG_CLOUD_OVERCAST_STRING;
+               case SG_CLOUD_BROKEN:
+                       return SG_CLOUD_BROKEN_STRING;
+               case SG_CLOUD_SCATTERED:
+                       return SG_CLOUD_SCATTERED_STRING;
+               case SG_CLOUD_FEW:
+                       return SG_CLOUD_FEW_STRING;
+               case SG_CLOUD_CIRRUS:
+                       return SG_CLOUD_CIRRUS_STRING;
+               case SG_CLOUD_CLEAR:
+               default:
+                       return SG_CLOUD_CLEAR_STRING;
+       }
+}
+
+SGCloudLayer::Coverage 
+SGCloudLayer::getCoverageType( const std::string & coverage )
+{
+       if( SG_CLOUD_OVERCAST_STRING == coverage ) {
+               return SG_CLOUD_OVERCAST;
+       } else if( SG_CLOUD_BROKEN_STRING == coverage ) {
+               return SG_CLOUD_BROKEN;
+       } else if( SG_CLOUD_SCATTERED_STRING == coverage ) {
+               return SG_CLOUD_SCATTERED;
+       } else if( SG_CLOUD_FEW_STRING == coverage ) {
+               return SG_CLOUD_FEW;
+       } else if( SG_CLOUD_CIRRUS_STRING == coverage ) {
+               return SG_CLOUD_CIRRUS;
+       } else {
+               return SG_CLOUD_CLEAR;
+       }
+}
+
+const std::string &
+SGCloudLayer::getCoverageString() const
+{
+       return getCoverageString(layer_coverage);
+}
+
+void
+SGCloudLayer::setCoverageString( const std::string & coverage )
+{
+       setCoverage( getCoverageType(coverage) );
+}
+
 void
 SGCloudLayer::setTextureOffset(const osg::Vec2& offset)
 {
@@ -698,7 +756,7 @@ bool SGCloudLayer::reposition( const SGVec3f& p, const SGVec3f& up, double lon,
         double ax = 0.0, ay = 0.0, bx = 0.0, by = 0.0;
 
         if (dist > 0.0) {
-            ax = cos(course) * dist;
+            ax = -cos(course) * dist;
             ay = sin(course) * dist;
         }
 
@@ -711,6 +769,7 @@ bool SGCloudLayer::reposition( const SGVec3f& p, const SGVec3f& up, double lon,
         double xoff = (ax + bx) / (2 * scale);
         double yoff = (ay + by) / (2 * scale);
 
+
 //        const float layer_scale = layer_span / scale;
 
         // cout << "xoff = " << xoff << ", yoff = " << yoff << endl;