1 #include <msp/core/maputils.h>
9 Armature::Link &Armature::add_link()
11 links.push_back(Link(string(), links.size()));
15 const Armature::Link &Armature::get_link(unsigned index) const
17 for(const Link &l: links)
18 if(l.get_index()==index)
20 throw key_error(index);
23 const Armature::Link &Armature::get_link(const string &name) const
25 for(const Link &l: links)
26 if(l.get_name()==name)
28 throw key_error(name);
31 unsigned Armature::get_max_link_index() const
33 unsigned max_index = 0;
34 for(const Link &l: links)
35 max_index = max(max_index, l.get_index());
40 Armature::Link::Link(const string &n, unsigned i):
46 void Armature::Link::set_parent(const Link *p)
51 void Armature::Link::set_base(const Vector3 &b)
57 Armature::Loader::Loader(Armature &a):
58 DataFile::ObjectLoader<Armature>(a)
60 add("link", &Loader::link);
63 void Armature::Loader::link(const string &n)
65 Link lnk(n, obj.links.size());
67 obj.links.push_back(lnk);
71 Armature::Link::Loader::Loader(Link &l, const Armature &a):
72 DataFile::ObjectLoader<Link>(l),
75 add("base", &Loader::base);
76 add("index", &Link::index);
77 add("parent", &Loader::parent);
80 void Armature::Link::Loader::base(float x, float y, float z)
82 obj.base = Vector3(x, y, z);
85 void Armature::Link::Loader::parent(const string &n)
87 obj.parent = &armature.get_link(n);