Start implementing animation file reader

This commit is contained in:
hodasemi 2018-05-30 22:28:14 +02:00
parent d62d06ae40
commit 71edbc6f51
2 changed files with 79 additions and 3 deletions

View file

@ -245,7 +245,82 @@ void SkeletonViewer::load_animation()
std::string filename = cgv::gui::file_open_dialog("Open", "Animation File (*.amc):*.amc");
if (!filename.empty())
{
/*Task: Load animation */
std::ifstream file(filename);
std::string line;
int current_index = -1;
while(std::getline(file, line))
{
if (line[0] == '#' || line[0] == ':')
{
continue;
}
int number = 0;
std::istringstream sline(line);
sline >> number;
if (number != 0)
{
current_index = number - 1;
std::cout << "current_index: " << current_index << std::endl;
}
else
{
if (current_index < 0)
abort();
std::string bone_name;
float bla;
// sexy c-code for gettin string
while(!line.empty()) {
int first_blank = line.find_first_of(" ");
string fnumbers = line.substr(first_blank + 1);
string bonename = line.substr(0, first_blank);
}
if (!(sline >> bone_name))
{
std::cout << "index(" << current_index << ") could not get bone name from: " << line << std::endl;
if (!(sline >> bla))
{
std::cout << "index(" << current_index << ") could not get value from: " << line << std::endl;
}
}
std::vector<AtomicTransform> transforms;
float value;
if (name == "root" )
{
for(int i = 0; i < 6; i++)
{
if (!(sline >> value))
{
std::cout << "could not get value from: " << line << std::endl;
}
else
{
}
}
}
else if (!name.empty())
{
while (sline >> value)
{
// TODO
}
}
abort();
}
}
}
}

View file

@ -33,6 +33,9 @@ class SkeletonViewer : public node, public drawable, public provider
gui_group_ptr tree_view;
gui_group_ptr bone_group;
std::vector<std::map<std::string, std::vector<AtomicTransform* >>> animations;
float colors[SKELETON_DEPTH][3];
// Maps gui elements in the tree view to a specific bone
std::map<base_ptr, Bone *> gui_to_bone;
@ -70,6 +73,4 @@ class SkeletonViewer : public node, public drawable, public provider
void draw(context &c);
std::string get_parent_type() const;
float colors[SKELETON_DEPTH][3];
};