void ImGuiProperty(const Transform3D &transform3D) { auto position = transform3D.position(); auto center = transform3D.center(); auto scale = transform3D.scale(); auto orientation = transform3D.orientation(); ImGui::InputFloat3("Position", &position[0]); ImGui::InputFloat3("Center", ¢er[0]); ImGui::InputFloat("Scale", &scale); ImGui::InputFloat4("Orientation", &orientation[0]); }
Transform3D Transform3D::interpolated(const Transform3D & other, float v) const { Transform3D result; result.setOrientation(glm::slerp(m_orientation, other.orientation(), v)); result.setPosition(glm::mix(m_position, other.position(), v)); result.setScale(glm::mix(m_scale, other.scale(), v)); result.setCenter(glm::mix(m_center, other.center(), v)); return result; }
Box::Box(const glm::vec3 & halfExtent, const Transform3D & transform) { m_p = transform.position(); auto x = transform.directionLocalToWorld(glm::vec3(halfExtent.x, 0.0f, 0.0f)); auto y = transform.directionLocalToWorld(glm::vec3(0.0f, halfExtent.y, 0.0f)); auto z = transform.directionLocalToWorld(glm::vec3(0.0f, 0.0f, halfExtent.z)); x = x != glm::vec3(0.0f) ? glm::normalize(x) : x; y = y != glm::vec3(0.0f) ? glm::normalize(y) : y; z = z != glm::vec3(0.0f) ? glm::normalize(z) : z; m_halfExtent = halfExtent; m_axes = glm::mat3(x, y, z); }
void ImGuiProperty(Transform3D &transform3D) { auto position = transform3D.position(); auto center = transform3D.center(); auto scale = transform3D.scale(); auto orientation = transform3D.orientation(); if (ImGui::InputFloat3("Position", &position[0])) transform3D.setPosition(position); if (ImGui::InputFloat3("Center", ¢er[0])) transform3D.setCenter(position); if (ImGui::InputFloat("Scale", &scale)) transform3D.setScale(scale); if (ImGui::InputFloat4("Orientation", &orientation[0])) transform3D.setOrientation(orientation); }