allow to modify the XML animation config of a loaded submodel by
defining an <overlay> branch, which is copied over the submodel's properties before the animations are evaluated
This commit is contained in:
@@ -50,8 +50,9 @@ using namespace simgear;
|
|||||||
osg::Node *
|
osg::Node *
|
||||||
sgLoad3DModel_internal(const string &path,
|
sgLoad3DModel_internal(const string &path,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
SGModelData *data=0,
|
SGModelData *data = 0,
|
||||||
osg::Node *(*load_panel)(SGPropertyNode *) = 0);
|
osg::Node *(*load_panel)(SGPropertyNode *) = 0,
|
||||||
|
SGPropertyNode *overlay = 0);
|
||||||
|
|
||||||
const char* SGReaderWriterXML::className() const
|
const char* SGReaderWriterXML::className() const
|
||||||
{
|
{
|
||||||
@@ -131,7 +132,8 @@ osg::Node *
|
|||||||
sgLoad3DModel_internal(const string &path,
|
sgLoad3DModel_internal(const string &path,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
SGModelData *data,
|
SGModelData *data,
|
||||||
osg::Node *(*load_panel)(SGPropertyNode *))
|
osg::Node *(*load_panel)(SGPropertyNode *),
|
||||||
|
SGPropertyNode *overlay)
|
||||||
{
|
{
|
||||||
if ( !prop_root ) {
|
if ( !prop_root ) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "prop_root NULL: " << path);
|
SG_LOG(SG_GENERAL, SG_ALERT, "prop_root NULL: " << path);
|
||||||
@@ -158,6 +160,9 @@ sgLoad3DModel_internal(const string &path,
|
|||||||
SG_LOG(SG_INPUT, SG_ALERT, "Failed to load xml: " << t.getFormattedMessage());
|
SG_LOG(SG_INPUT, SG_ALERT, "Failed to load xml: " << t.getFormattedMessage());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
if (overlay)
|
||||||
|
copyProperties(overlay, props);
|
||||||
|
|
||||||
if (props->hasValue("/path")) {
|
if (props->hasValue("/path")) {
|
||||||
modelpath = modelpath.dir();
|
modelpath = modelpath.dir();
|
||||||
modelpath.append(props->getStringValue("/path"));
|
modelpath.append(props->getStringValue("/path"));
|
||||||
@@ -234,7 +239,8 @@ sgLoad3DModel_internal(const string &path,
|
|||||||
submodelpath = submodelFileName;
|
submodelpath = submodelFileName;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
submodel = sgLoad3DModel_internal(submodelpath.str(), prop_root, 0, load_panel);
|
submodel = sgLoad3DModel_internal(submodelpath.str(), prop_root, 0, load_panel,
|
||||||
|
sub_props->getNode("overlay"));
|
||||||
} catch (const sg_throwable &t) {
|
} catch (const sg_throwable &t) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage());
|
SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage());
|
||||||
throw;
|
throw;
|
||||||
|
|||||||
Reference in New Issue
Block a user