X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fmetascene.cc;h=2328f33ee9b0cb6c03d9a64f3824a4b5827863a9;hp=e0b2b205137ebff222926101ff7e358229feb041;hb=80c04e7a9aa6d42f769dd4fa70c2c3113440cbce;hpb=12e70d8b9c2d5c81500d7631b9db5d17a34fe918 diff --git a/src/metascene.cc b/src/metascene.cc index e0b2b20..2328f33 100644 --- a/src/metascene.cc +++ b/src/metascene.cc @@ -1,3 +1,4 @@ +#include #include #include #include "metascene.h" @@ -6,7 +7,7 @@ #include "logger.h" #include "app.h" -#ifdef WIN32 +#if defined(WIN32) || defined(__WIN32__) #include #else #include @@ -74,6 +75,57 @@ void MetaScene::draw() const } } +SceneNode *MetaScene::find_node(const char *name) const +{ + int num = scenes.size(); + for(int i=0; ifind_node(name); + if(n) return n; + } + return 0; +} + +SceneNode *MetaScene::match_node(const char *qstr) const +{ + int num = scenes.size(); + for(int i=0; imatch_node(qstr); + if(n) return n; + } + return 0; +} + +std::list MetaScene::match_nodes(const char *qstr) const +{ + std::list res; + int num = scenes.size(); + for(int i=0; i tmp = scenes[i]->match_nodes(qstr); + if(!tmp.empty()) { + res.splice(res.end(), tmp); + } + } + return std::move(res); +} + +Scene *MetaScene::extract_nodes(const char *qstr) +{ + Scene *scn = 0; + int nscn = scenes.size(); + for(int i=0; iextract_nodes(qstr); + if(tmp) { + if(!scn) { + scn = tmp; + } else { + scn->merge(tmp); + delete tmp; + } + } + } + return scn; +} + static bool proc_node(MetaScene *mscn, struct ts_node *node) { struct ts_node *c = node->child_list; @@ -117,10 +169,15 @@ static bool proc_scenefile(MetaScene *mscn, struct ts_node *node) // datapath struct ts_attr *adpath = attr_inscope(node, "datapath"); if(adpath && adpath->val.type == TS_STRING) { - info_log("adding data path: %s\n", adpath->val.str); mscn->datamap.set_path(adpath->val.str); } + // strip path + struct ts_attr *aspath = attr_inscope(node, "strip_path"); + if(aspath && aspath->val.type == TS_NUMBER) { + mscn->datamap.set_strip(aspath->val.inum); + } + // walkmesh struct ts_attr *awmesh = attr_inscope(node, "walkmesh"); if(awmesh && awmesh->val.type == TS_STRING) { @@ -303,7 +360,7 @@ static void apply_mtledit(Scene *scn, const MaterialEdit &med) int nobj = scn->objects.size(); for(int i=0; iobjects[i]; - if(std::regex_match(obj->get_name(), med.name_re)) { + if(std::regex_match(obj->mtl.name, med.name_re)) { apply_mtledit(&obj->mtl, med); } }