+#include <assert.h>
#include <string>
#include <regex>
#include "metascene.h"
#include "logger.h"
#include "app.h"
-#ifdef WIN32
+#if defined(WIN32) || defined(__WIN32__)
#include <malloc.h>
#else
#include <alloca.h>
}
}
+SceneNode *MetaScene::find_node(const char *name) const
+{
+ int num = scenes.size();
+ for(int i=0; i<num; i++) {
+ SceneNode *n = scenes[i]->find_node(name);
+ if(n) return n;
+ }
+ return 0;
+}
+
+SceneNode *MetaScene::match_node(const char *qstr) const
+{
+ int num = scenes.size();
+ for(int i=0; i<num; i++) {
+ SceneNode *n = scenes[i]->match_node(qstr);
+ if(n) return n;
+ }
+ return 0;
+}
+
+std::list<SceneNode*> MetaScene::match_nodes(const char *qstr) const
+{
+ std::list<SceneNode*> res;
+ int num = scenes.size();
+ for(int i=0; i<num; i++) {
+ std::list<SceneNode*> 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; i<nscn; i++) {
+ Scene *tmp = scenes[i]->extract_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;
// 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) {
int nobj = scn->objects.size();
for(int i=0; i<nobj; i++) {
Object *obj = scn->objects[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);
}
}