+ } else if(nnodes) {
+ // just use the first one
+ SceneNode *first = wscn->nodes->get_child(0);
+ sdat->meta->start_pos = first->get_position();
+ sdat->meta->start_rot = first->get_rotation();
+ }
+ delete wscn;
+ }
+
+ int num_medits = sdat->mtledit.size();
+ for(int i=0; i<num_medits; i++) {
+ // perform material edits
+ apply_mtledit(newscn, sdat->mtledit[i]);
+ }
+
+ scenes.push_back(newscn);
+ return true;
+}
+
+static bool proc_mtledit(MetaScene *mscn, MaterialEdit *med, struct ts_node *node)
+{
+ if(strcmp(node->name, "mtledit") != 0) {
+ return false;
+ }
+
+ const char *restr = ".*";
+ struct ts_attr *amtl = ts_get_attr(node, "material");
+ if(amtl && amtl->val.type == TS_STRING) {
+ restr = amtl->val.str;
+ }
+
+ med->name_re = std::regex(restr);
+
+ node = node->child_list;
+ while(node) {
+ struct ts_node *cn = node;
+ node = node->next;
+
+ if(strcmp(cn->name, "texture") == 0) {
+ // add/change/remove a texture
+ struct ts_attr *atype = ts_get_attr(cn, "type");
+ struct ts_attr *afile = ts_get_attr(cn, "file");
+
+ int textype = MTL_TEX_DIFFUSE;
+ if(atype) {
+ if(atype->val.type == TS_STRING) {
+ textype = mtl_parse_type(atype->val.str);
+ } else if(atype->val.type == TS_NUMBER) {
+ textype = atype->val.inum;
+ if(textype < 0 || textype >= NUM_MTL_TEXTURES) {
+ error_log("invalid texture in mtledit: %d\n", textype);
+ continue;
+ }