|
@ -19,11 +19,20 @@ Eigen::Matrix3d subface::trans_world_to_local_linear() const { return model_matr |
|
|
|
|
|
|
|
|
std::pair<internal::paired_model_matrix *, bool> subface::apply_transform(internal::transform_type type, Eigen::Vector4d param) |
|
|
std::pair<internal::paired_model_matrix *, bool> subface::apply_transform(internal::transform_type type, Eigen::Vector4d param) |
|
|
{ |
|
|
{ |
|
|
|
|
|
std::cout << "Applying transform: " << param.head<3>() << std::endl; |
|
|
auto temp = *model_matrices; |
|
|
auto temp = *model_matrices; |
|
|
switch (type) { |
|
|
switch (type) { |
|
|
case internal::transform_type::scale: { |
|
|
case internal::transform_type::scale: { |
|
|
|
|
|
std::cout << "Before scale:" << std::endl; |
|
|
|
|
|
std::cout << "local_to_world.linear():\n" << temp.local_to_world.linear() << std::endl; |
|
|
|
|
|
std::cout << "world_to_local.linear():\n" << temp.world_to_local.linear() << std::endl; |
|
|
|
|
|
|
|
|
temp.local_to_world.linear() = param.head<3>().asDiagonal() * temp.local_to_world.linear(); |
|
|
temp.local_to_world.linear() = param.head<3>().asDiagonal() * temp.local_to_world.linear(); |
|
|
temp.world_to_local.linear() = temp.world_to_local.linear() * param.head<3>().cwiseInverse().asDiagonal(); |
|
|
temp.world_to_local.linear() = temp.world_to_local.linear() * param.head<3>().cwiseInverse().asDiagonal(); |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "After scale:" << std::endl; |
|
|
|
|
|
std::cout << "local_to_world.linear():\n" << temp.local_to_world.linear() << std::endl; |
|
|
|
|
|
std::cout << "world_to_local.linear():\n" << temp.world_to_local.linear() << std::endl; |
|
|
} break; |
|
|
} break; |
|
|
case internal::transform_type::rotation: { |
|
|
case internal::transform_type::rotation: { |
|
|
auto rotation_matrix = Eigen::Quaterniond(param).toRotationMatrix(); |
|
|
auto rotation_matrix = Eigen::Quaterniond(param).toRotationMatrix(); |
|
@ -31,8 +40,14 @@ std::pair<internal::paired_model_matrix *, bool> subface::apply_transform(intern |
|
|
temp.world_to_local.linear() = temp.world_to_local.linear() * rotation_matrix.transpose(); |
|
|
temp.world_to_local.linear() = temp.world_to_local.linear() * rotation_matrix.transpose(); |
|
|
} break; |
|
|
} break; |
|
|
case internal::transform_type::translation: { |
|
|
case internal::transform_type::translation: { |
|
|
|
|
|
std::cout << "Before translation: " << std::endl; |
|
|
|
|
|
std::cout << "Local to world: " << temp.local_to_world.translation() << std::endl; |
|
|
|
|
|
std::cout << "World to local: " << temp.world_to_local.translation() << std::endl; |
|
|
temp.local_to_world.translation() += param.head<3>(); |
|
|
temp.local_to_world.translation() += param.head<3>(); |
|
|
temp.world_to_local.translation() -= param.head<3>(); |
|
|
temp.world_to_local.translation() -= param.head<3>(); |
|
|
|
|
|
std::cout << "After translation: " << std::endl; |
|
|
|
|
|
std::cout << "Local to world: " << temp.local_to_world.translation() << std::endl; |
|
|
|
|
|
std::cout << "World to local: " << temp.world_to_local.translation() << std::endl; |
|
|
} break; |
|
|
} break; |
|
|
default: throw std::invalid_argument("Invalid transform type"); |
|
|
default: throw std::invalid_argument("Invalid transform type"); |
|
|
} |
|
|
} |
|
|