void MovableObject::callback_rotation(const glm::fquat &rotation) { orientation_ = rotation; rotation_matrix_dirty_ = true; orientation_changed(); matrix_becomes_dirty(); }
void MovableObject::set_rotation(const glm::vec3 &axis, const float angle) { rotation_matrix_dirty_ = true; orientation_ = glm::rotate(glm::fquat(1.f, 0.f, 0.f, 0.f), angle, axis); orientation_changed(); matrix_becomes_dirty(); }
void MovableObject::set_orientation(const glm::fquat &orientation) { rotation_matrix_dirty_ = true; orientation_ = orientation; orientation_changed(); matrix_becomes_dirty(); }
void MovableObject::relative_rotate(const glm::vec3 &axis, const float &angle) { rotation_matrix_dirty_ = true; glm::vec3 n_axis = glm::normalize(axis) * sinf(angle/2.f); glm::fquat offset = glm::fquat(cosf(angle/2.f), n_axis.x, n_axis.y, n_axis.z); orientation_ = orientation_ * offset; orientation_ = glm::normalize(orientation_); orientation_changed(); }
void MovableObject::set_matrix(const glm::mat4 &mat) { rotation_matrix_dirty_ = true; translation_matrix_dirty_ = true; orientation_ = glm::quat_cast(mat); orientation_changed(); position_ = glm::vec3(glm::column(mat, 3)); position_changed(); matrix_becomes_dirty(); }