Esempio n. 1
0
void load(
	Animation_Set *anim_set,
	std::string info_filename,
	std::string path_to_files,
	std::map< std::pair<std::string, int>, std::vector<Bone> > &bones)
{
	XMLData *xml = new XMLData(info_filename);
	std::list<XMLData *>::iterator it;
	std::list<XMLData *> nodes = xml->get_nodes();

	std::string sub_bak = anim_set->get_sub_animation_name();

	for (it = nodes.begin(); it != nodes.end(); it++) {
		XMLData *sub = *it;
		XMLData *tmp;
		std::string name = sub->get_name();
		tmp = sub->find("frames");
		std::string framesS;
		if (tmp)
			framesS = tmp->get_value();
		else
			framesS = "1";
		int nframes = atoi(framesS.c_str());
		for (int i = 0; i < nframes; i++) {
			anim_set->set_sub_animation(name, true);
			anim_set->get_current_animation()->set_frame(i);
			int w = anim_set->get_current_animation()->get_current_frame()->get_width();
			int h = anim_set->get_current_animation()->get_current_frame()->get_height();
			std::string filename = path_to_files + "/" + name + "/" + General::itos(i+1) + ".xml";
			std::vector<Bone> bones2;
			load(bones2, w, h, filename);
			std::pair<std::string, int> p;
			p.first = name;
			p.second = i;
			bones[p] = bones2;
		}
	}

	anim_set->set_sub_animation(sub_bak);

	delete xml;
}