Keep the region name with the material.
This commit is contained in:
parent
94630733ff
commit
c9e23231da
@ -97,11 +97,13 @@ SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
|
|||||||
const SGPropertyNode *props,
|
const SGPropertyNode *props,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
std::shared_ptr<AreaList> a,
|
std::shared_ptr<AreaList> a,
|
||||||
SGSharedPtr<const SGCondition> c)
|
SGSharedPtr<const SGCondition> c,
|
||||||
|
const std::string& n)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
areas = a;
|
areas = a;
|
||||||
condition = c;
|
condition = c;
|
||||||
|
region = n;
|
||||||
read_properties( options, props, prop_root );
|
read_properties( options, props, prop_root );
|
||||||
buildEffectProperties(options);
|
buildEffectProperties(options);
|
||||||
}
|
}
|
||||||
@ -110,12 +112,14 @@ SGMaterial::SGMaterial( const osgDB::Options* options,
|
|||||||
const SGPropertyNode *props,
|
const SGPropertyNode *props,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
std::shared_ptr<AreaList> a,
|
std::shared_ptr<AreaList> a,
|
||||||
SGSharedPtr<const SGCondition> c)
|
SGSharedPtr<const SGCondition> c,
|
||||||
|
const std::string& n)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SGReaderWriterOptions> opt;
|
osg::ref_ptr<SGReaderWriterOptions> opt;
|
||||||
opt = SGReaderWriterOptions::copyOrCreate(options);
|
opt = SGReaderWriterOptions::copyOrCreate(options);
|
||||||
areas = a;
|
areas = a;
|
||||||
condition = c;
|
condition = c;
|
||||||
|
region = n;
|
||||||
init();
|
init();
|
||||||
read_properties(opt.get(), props, prop_root);
|
read_properties(opt.get(), props, prop_root);
|
||||||
buildEffectProperties(opt.get());
|
buildEffectProperties(opt.get());
|
||||||
|
@ -98,14 +98,16 @@ public:
|
|||||||
const SGPropertyNode *props,
|
const SGPropertyNode *props,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
std::shared_ptr<AreaList> a,
|
std::shared_ptr<AreaList> a,
|
||||||
SGSharedPtr<const SGCondition> c);
|
SGSharedPtr<const SGCondition> c,
|
||||||
|
const std::string& n);
|
||||||
|
|
||||||
|
|
||||||
SGMaterial(const simgear::SGReaderWriterOptions*,
|
SGMaterial(const simgear::SGReaderWriterOptions*,
|
||||||
const SGPropertyNode *props,
|
const SGPropertyNode *props,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
std::shared_ptr<AreaList> a,
|
std::shared_ptr<AreaList> a,
|
||||||
SGSharedPtr<const SGCondition> c);
|
SGSharedPtr<const SGCondition> c,
|
||||||
|
const std::string& n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
@ -124,6 +126,11 @@ public:
|
|||||||
simgear::Effect* get_one_effect(int texIndex);
|
simgear::Effect* get_one_effect(int texIndex);
|
||||||
simgear::Effect* get_effect();
|
simgear::Effect* get_effect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the region Name.
|
||||||
|
*/
|
||||||
|
const std::string get_region_name() const { return region; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Effect Name.
|
* Get the Effect Name.
|
||||||
*/
|
*/
|
||||||
@ -488,6 +495,9 @@ private:
|
|||||||
SGVec4f ambient, diffuse, specular, emission;
|
SGVec4f ambient, diffuse, specular, emission;
|
||||||
double shininess;
|
double shininess;
|
||||||
|
|
||||||
|
// region of this material
|
||||||
|
std::string region;
|
||||||
|
|
||||||
// effect for this material
|
// effect for this material
|
||||||
std::string effect;
|
std::string effect;
|
||||||
|
|
||||||
|
@ -128,12 +128,13 @@ bool SGMaterialLib::load( const SGPath &fg_root, const SGPath& mpath,
|
|||||||
|
|
||||||
// Now build all the materials for this set of areas and conditions
|
// Now build all the materials for this set of areas and conditions
|
||||||
|
|
||||||
|
const std::string region = node->getStringValue("name");
|
||||||
const simgear::PropertyList materials = node->getChildren("material");
|
const simgear::PropertyList materials = node->getChildren("material");
|
||||||
simgear::PropertyList::const_iterator materials_iter = materials.begin();
|
simgear::PropertyList::const_iterator materials_iter = materials.begin();
|
||||||
for (; materials_iter != materials.end(); materials_iter++) {
|
for (; materials_iter != materials.end(); materials_iter++) {
|
||||||
const SGPropertyNode *node = materials_iter->get();
|
const SGPropertyNode *node = materials_iter->get();
|
||||||
SGSharedPtr<SGMaterial> m =
|
SGSharedPtr<SGMaterial> m =
|
||||||
new SGMaterial(options.get(), node, prop_root, arealist, condition);
|
new SGMaterial(options.get(), node, prop_root, arealist, condition, region);
|
||||||
|
|
||||||
std::vector<SGPropertyNode_ptr>names = node->getChildren("name");
|
std::vector<SGPropertyNode_ptr>names = node->getChildren("name");
|
||||||
for ( unsigned int j = 0; j < names.size(); j++ ) {
|
for ( unsigned int j = 0; j < names.size(); j++ ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user