Move cross of base bone to its tip
This commit is contained in:
parent
d3e440aeea
commit
a792259004
1 changed files with 7 additions and 5 deletions
|
@ -97,6 +97,8 @@ void IKViewer::calculate_kinematic_chain(Bone *base, Bone *endeffector)
|
|||
current_base_matrix = current_base_matrix * transform->calculate_matrix();
|
||||
}
|
||||
|
||||
current_base_matrix = current_base_matrix * base->get_translation_transform_current_joint_to_next();
|
||||
|
||||
if (!endeffector)
|
||||
return;
|
||||
|
||||
|
@ -178,11 +180,14 @@ void IKViewer::calculate_kinematic_chain(Bone *base, Bone *endeffector)
|
|||
}
|
||||
else
|
||||
{
|
||||
// can't ever happen, but when it does, we will know
|
||||
// can never happen, but when it does, we will know
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Transform> inverse_static = std::shared_ptr<Transform>(new StaticTransform(inv(base->get_translation_transform_current_joint_to_next())));
|
||||
kinematic_chain.emplace_front(inverse_static);
|
||||
|
||||
current_endeffector_matrix.identity();
|
||||
|
||||
for (auto &transform : kinematic_chain)
|
||||
|
@ -191,9 +196,6 @@ void IKViewer::calculate_kinematic_chain(Bone *base, Bone *endeffector)
|
|||
}
|
||||
|
||||
target_position = current_base_matrix * current_endeffector_matrix * endeffector->get_bone_local_tip_position();
|
||||
|
||||
print_vec3(target_position);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void IKViewer::optimize()
|
||||
|
@ -210,7 +212,7 @@ void IKViewer::optimize()
|
|||
/*Task 3.3: Implement CCD */
|
||||
for (int i = 0; i < max_iterations; i++)
|
||||
{
|
||||
for (auto it = kinematic_chain.rbegin(); it != kinematic_chain.rend(); i++)
|
||||
for (auto it = kinematic_chain.rbegin(); it != kinematic_chain.rend(); it++)
|
||||
{
|
||||
//it->optimize_value(/*local_vector*/, target_position);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue