Let SGCloudLayer handle coverage strings
This is currently handled in various places in FlightGear.
This commit is contained in:
@@ -83,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,
|
||||
@@ -293,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)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,13 @@ public:
|
||||
SG_MAX_CLOUD_COVERAGES
|
||||
};
|
||||
|
||||
static const std::string SG_CLOUD_OVERCAST_STRING; // "overcast"
|
||||
static const std::string SG_CLOUD_BROKEN_STRING; // "broken"
|
||||
static const std::string SG_CLOUD_SCATTERED_STRING; // "scattered"
|
||||
static const std::string SG_CLOUD_FEW_STRING; // "few"
|
||||
static const std::string SG_CLOUD_CIRRUS_STRING; // "cirrus"
|
||||
static const std::string SG_CLOUD_CLEAR_STRING; // "clear"
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param tex_path the path to the set of cloud textures
|
||||
@@ -123,6 +130,18 @@ public:
|
||||
*/
|
||||
void setCoverage (Coverage coverage);
|
||||
|
||||
/** get coverage as string */
|
||||
const string & getCoverageString() const;
|
||||
|
||||
/** get coverage as string */
|
||||
static const string & getCoverageString( Coverage coverage );
|
||||
|
||||
/** get coverage type from string */
|
||||
static Coverage getCoverageType( const std::string & coverage );
|
||||
|
||||
/** set coverage as string */
|
||||
void setCoverageString( const string & coverage );
|
||||
|
||||
/**
|
||||
* set the cloud movement direction
|
||||
* @param dir the cloud movement direction
|
||||
|
||||
Reference in New Issue
Block a user