From: Stuart Buchanan Date: Tue, 17 Feb 2015 21:47:51 +0000 (+0000) Subject: materials.xml defined vegetation Effect. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6f15bb415f042aced3120174a6c8b3228aa160a8;p=simgear.git materials.xml defined vegetation Effect. --- diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index a39c71c1..d90a40ed 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -323,6 +323,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options, // Random vegetation properties wood_coverage = props->getDoubleValue("wood-coverage", 0.0); + tree_effect = props->getStringValue("tree-effect", "Effects/tree"); tree_height = props->getDoubleValue("tree-height-m", 0.0); tree_width = props->getDoubleValue("tree-width-m", 0.0); tree_range = props->getDoubleValue("tree-range-m", 0.0); diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index ef420d94..ee094fa6 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -273,6 +273,14 @@ public: * @return the texture to use for trees. */ inline std::string get_tree_texture () const { return tree_texture; } + + + /** + * Get the effect file name to use for trees + * + * @return the effect to use for this set of trees. + */ + inline std::string get_tree_effect () const { return tree_effect; } /** * Get the cosine of the maximum tree density slope angle. We @@ -476,6 +484,9 @@ private: // Tree texture, typically a strip of applicable tree textures std::string tree_texture; + + // Tree effect to be used for a particular material + std::string tree_effect; // Object mask, a simple RGB texture used as a mask when placing // random vegetation, objects and buildings diff --git a/simgear/scene/tgdb/SGTileDetailsCallback.hxx b/simgear/scene/tgdb/SGTileDetailsCallback.hxx index 44c7f86f..ced1403c 100644 --- a/simgear/scene/tgdb/SGTileDetailsCallback.hxx +++ b/simgear/scene/tgdb/SGTileDetailsCallback.hxx @@ -723,6 +723,7 @@ public: BOOST_FOREACH(bin, randomForest) { if ((bin->texture == mat->get_tree_texture() ) && + (bin->teffect == mat->get_tree_effect() ) && (bin->texture_varieties == mat->get_tree_varieties()) && (bin->range == mat->get_tree_range() ) && (bin->width == mat->get_tree_width() ) && @@ -736,6 +737,8 @@ public: bin = new TreeBin(); bin->texture = mat->get_tree_texture(); SG_LOG(SG_INPUT, SG_DEBUG, "Tree texture " << bin->texture); + bin->teffect = mat->get_tree_effect(); + SG_LOG(SG_INPUT, SG_DEBUG, "Tree effect " << bin->teffect); bin->range = mat->get_tree_range(); bin->width = mat->get_tree_width(); bin->height = mat->get_tree_height(); diff --git a/simgear/scene/tgdb/TreeBin.cxx b/simgear/scene/tgdb/TreeBin.cxx index 9b8aa3bc..64928084 100644 --- a/simgear/scene/tgdb/TreeBin.cxx +++ b/simgear/scene/tgdb/TreeBin.cxx @@ -343,7 +343,7 @@ osg::Group* createForest(SGTreeBinList& forestList, const osg::Matrix& transform (!iter->second.lock(effect))) { SGPropertyNode_ptr effectProp = new SGPropertyNode; - makeChild(effectProp, "inherits-from")->setStringValue("Effects/tree"); + makeChild(effectProp, "inherits-from")->setStringValue(forest->teffect); SGPropertyNode* params = makeChild(effectProp, "parameters"); // emphasize n = 0 params->getChild("texture", 0, true)->getChild("image", 0, true) diff --git a/simgear/scene/tgdb/TreeBin.hxx b/simgear/scene/tgdb/TreeBin.hxx index 9b9c3bc9..80441ec4 100644 --- a/simgear/scene/tgdb/TreeBin.hxx +++ b/simgear/scene/tgdb/TreeBin.hxx @@ -49,6 +49,7 @@ public: float height; float width; std::string texture; + std::string teffect; void insert(const Tree& t) { _trees.push_back(t); }