bool SGPagedLOD::addChild(osg::Node *child)
{
- //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::addChild(" << getFileName(getNumChildren()) << ")");
if (!PagedLOD::addChild(child))
return false;
setRadius(getBound().radius());
setCenter(getBound().center());
- SGReaderWriterXMLOptions* opts;
- opts = dynamic_cast<SGReaderWriterXMLOptions*>(_readerWriterOptions.get());
- if(opts)
- {
- osg::ref_ptr<SGModelData> d = opts->getModelData();
- if(d.valid())
- d->modelLoaded(getFileName(getNumChildren()-1),
- d->getConfigProperties(), this);
- }
return true;
}
SGSharedPtr<SGPropertyNode> prop_root;
osg::Node *(*load_panel)(SGPropertyNode *)=0;
- SGModelData *data=0;
+ osg::ref_ptr<SGModelData> data;
if (xmlOptions) {
prop_root = xmlOptions->getPropRoot();
} else {
submodelpath = submodelFileName;
}
+ osg::ref_ptr<SGReaderWriterXMLOptions> options;
+ options = new SGReaderWriterXMLOptions(*options_);
+ options->setPropRoot(prop_root);
try {
- submodel = sgLoad3DModel_internal(submodelpath.str(), options_,
+ submodel = sgLoad3DModel_internal(submodelpath.str(), options.get(),
sub_props->getNode("overlay"));
} catch (const sg_throwable &t) {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage());
options.get()));
}
- if (data) {
- data->setConfigProperties(props);
- options->setModelData(data);
- }
-
std::vector<SGPropertyNode_ptr> animation_nodes;
animation_nodes = props->getChildren("animation");
for (unsigned i = 0; i < animation_nodes.size(); ++i)
if (!needTransform && group->getNumChildren() < 2) {
model = group->getChild(0);
group->removeChild(model.get());
- model->setUserData(group->getUserData());
+ if (data.valid())
+ data->modelLoaded(modelpath.str(), props, model.get());
return model.release();
}
+ if (data.valid())
+ data->modelLoaded(modelpath.str(), props, group.get());
if (props->hasChild("debug-outfile")) {
std::string outputfile = props->getStringValue("debug-outfile",
"debug-model.osg");
opt->setPropRoot(prop_root);
opt->setModelData(data);
osg::Node *n = readNodeFile(path, opt.get());
- if(data)
- data->modelLoaded(path, data->getConfigProperties(), n);
if (n && n->getName().empty())
n->setName("Direct loaded model \"" + path + "\"");
return n;
virtual ~SGModelData() {}
virtual void modelLoaded(const string& path, SGPropertyNode *prop,
osg::Node* branch) = 0;
- void setConfigProperties(SGPropertyNode *configProperties)
- { _configProperties = configProperties; }
- SGPropertyNode *getConfigProperties()
- { return _configProperties; }
-
-private:
- SGSharedPtr<SGPropertyNode> _configProperties;
};
}