diff --git a/.vscode/settings.json b/.vscode/settings.json index d3f6ce2..c4b72bd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -52,7 +52,8 @@ "typeinfo": "cpp", "utility": "cpp", "variant": "cpp", - "algorithm": "cpp" + "algorithm": "cpp", + "new": "cpp" }, "editor.formatOnSave": true } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 12baac7..bea65fd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,7 +12,8 @@ "plugin:cg_fltk.cgv", "plugin:CGII.cgv", "plugin:crg_stereo_view.cgv" - ] + ], + "dependsOn": "Build CGII" }, { "label": "Build All", diff --git a/CGII/src/Bone.cpp b/CGII/src/Bone.cpp index a0706af..7aea345 100644 --- a/CGII/src/Bone.cpp +++ b/CGII/src/Bone.cpp @@ -41,12 +41,17 @@ void Bone::calculate_matrices() { orientationTransformGlobalToLocal.identity(); std::for_each(orientation.begin(), orientation.end(), [&](AtomicTransform *t) { - std::cout << "atomic transform " << t->get_name() << ": " << t->get_value() << std::endl; + std::cout << name << " orientation " << t->get_name() << ": " << t->get_value() << std::endl; orientationTransformGlobalToLocal = orientationTransformGlobalToLocal * t->calculate_matrix(); }); + orientationTransformLocalToGlobal = cgv::math::inv(orientationTransformGlobalToLocal); + std::for_each(dofs.begin(), dofs.end(), [&](std::shared_ptr &t) { + //std::cout << "dofs " << t->get_name() << ": " << t->get_value() << std::endl; + }); + /*Task 2.1: Implement matrix calculation */ Mat4 matrix; matrix.identity(); @@ -109,17 +114,17 @@ Mat4 Bone::calculate_transform_prev_to_current_with_dofs() dofs.identity(); std::for_each(orientation.begin(), orientation.end(), [&](AtomicTransform *t) { - dofs = dofs * t->calculate_matrix(); + //dofs = dofs * t->calculate_matrix(); }); - Mat4 t = translationTransformCurrentJointToNext * orientationTransformPrevJointToCurrent * dofs; + Mat4 t = translationTransformCurrentJointToNext * orientationTransformPrevJointToCurrent * dofs; // * orientationTransformGlobalToLocal; return t; } Mat4 Bone::calculate_transform_prev_to_current_without_dofs() { //Task 2.1: Implement matrix calculation - Mat4 t = translationTransformCurrentJointToNext * orientationTransformPrevJointToCurrent; + Mat4 t = translationTransformCurrentJointToNext * orientationTransformPrevJointToCurrent * orientationTransformLocalToGlobal * orientationTransformGlobalToLocal; return t; }