From 748040d5df43dc23bb0ef7255998e0e2df4e053a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gy=C3=B6rgy=20Straub?= Date: Thu, 29 Oct 2020 14:46:24 +0000 Subject: [PATCH] Fixed the rotation interaction in the Reflection example. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I336525894567d22349f883ff6d673ba0e2f8a2ff Signed-off-by: György Straub --- examples/reflection-demo/reflection-example.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/reflection-demo/reflection-example.cpp b/examples/reflection-demo/reflection-example.cpp index 9de2407..6a44fda 100644 --- a/examples/reflection-demo/reflection-example.cpp +++ b/examples/reflection-demo/reflection-example.cpp @@ -595,13 +595,18 @@ private: void OnPan(Actor actor, const PanGesture& panGesture) { - const auto& displacement = panGesture.GetScreenDisplacement(); - mCenterActor.RotateBy(Degree(displacement.y * 0.1f), Vector3(0.0, 0.0, 1.0)); - mCenterActor.RotateBy(Degree(displacement.x * 0.1f), Vector3(0.0, 1.0, 0.0)); - Quaternion q; - mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get(q); + Vector2 displacement = panGesture.GetScreenDisplacement(); + Vector2 rotation{ + displacement.y * -0.1f, + displacement.x * 0.1f + }; + + Quaternion q(Degree(0.f), Degree(rotation.y), Degree(rotation.x)); + Quaternion q0 = mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get(); + mCenterActor.SetProperty(Actor::Property::ORIENTATION, q * q0); + Matrix m = Matrix::IDENTITY; - m.SetTransformComponents(Vector3::ONE, q, Vector3::ZERO); + m.SetTransformComponents(Vector3::ONE, q0, Vector3::ZERO); auto yAxis = m.GetYAxis() * -1.0f; yAxis.Normalize(); -- 2.7.4