From 71edbc6f51473e803418d6d2954455604067d746 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Wed, 30 May 2018 22:28:14 +0200 Subject: [PATCH] Start implementing animation file reader --- CGII/src/SkeletonViewer.cpp | 77 ++++++++++++++++++++++++++++++++++++- CGII/src/SkeletonViewer.h | 5 ++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/CGII/src/SkeletonViewer.cpp b/CGII/src/SkeletonViewer.cpp index 86c677e..57a71b3 100644 --- a/CGII/src/SkeletonViewer.cpp +++ b/CGII/src/SkeletonViewer.cpp @@ -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 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(); + } + } } } diff --git a/CGII/src/SkeletonViewer.h b/CGII/src/SkeletonViewer.h index 214cfbd..1de73e5 100644 --- a/CGII/src/SkeletonViewer.h +++ b/CGII/src/SkeletonViewer.h @@ -33,6 +33,9 @@ class SkeletonViewer : public node, public drawable, public provider gui_group_ptr tree_view; gui_group_ptr bone_group; + std::vector>> animations; + float colors[SKELETON_DEPTH][3]; + // Maps gui elements in the tree view to a specific bone std::map 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]; };