54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include "scene3d/instance.h"
|
|
#include "log/log.h"
|
|
|
|
using namespace GS::NML;
|
|
using namespace GS::S3D;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool Instance::FromMetaTag(Tag &tag)
|
|
{
|
|
if (tag.name != "Instance")
|
|
__ERR__(__LOG_E__ << "Could not parse instance, incorrect root tag (" << tag.name << ").\n", false)
|
|
|
|
do_not_parent = false;
|
|
|
|
NMLTagForeach(pt, tag)
|
|
{
|
|
if (pt->name == "MItem")
|
|
MItem::FromMetaTag(*pt);
|
|
else if (pt->name == "Item")
|
|
Item::FromMetaTag(*pt);
|
|
|
|
else if (pt->name == "Template")
|
|
template_path = pt->GetString();
|
|
else if (pt->name == "DoNotParent")
|
|
do_not_parent = pt->GetBool();
|
|
|
|
else __LOG_W__ << "Unknown tag '" << pt->name << "' in <Instance>.\n";
|
|
}
|
|
return true;
|
|
}
|
|
Tag *Instance::AsMetaTag()
|
|
{
|
|
Tag *root = new Tag("Instance");
|
|
if (!root)
|
|
__ERR__(__LOG_E__ << "Could not create root tag to serialize.\n", NULL)
|
|
|
|
root->AddChild(MItem::AsMetaTag());
|
|
root->AddChild(Item::AsMetaTag());
|
|
|
|
root->AddChild("Template", template_path);
|
|
if (do_not_parent)
|
|
root->AddChild("DoNotParent", do_not_parent);
|
|
|
|
return root;
|
|
}
|
|
//------------------------------------------------------------------------------
|