Commit 748040d5df43dc23bb0ef7255998e0e2df4e053a
1 parent
dd10a1d0
Fixed the rotation interaction in the Reflection example.
Change-Id: I336525894567d22349f883ff6d673ba0e2f8a2ff Signed-off-by: György Straub <g.straub@partner.samsung.com>
Showing
1 changed file
with
11 additions
and
6 deletions
examples/reflection-demo/reflection-example.cpp
| @@ -595,13 +595,18 @@ private: | @@ -595,13 +595,18 @@ private: | ||
| 595 | 595 | ||
| 596 | void OnPan(Actor actor, const PanGesture& panGesture) | 596 | void OnPan(Actor actor, const PanGesture& panGesture) |
| 597 | { | 597 | { |
| 598 | - const auto& displacement = panGesture.GetScreenDisplacement(); | ||
| 599 | - mCenterActor.RotateBy(Degree(displacement.y * 0.1f), Vector3(0.0, 0.0, 1.0)); | ||
| 600 | - mCenterActor.RotateBy(Degree(displacement.x * 0.1f), Vector3(0.0, 1.0, 0.0)); | ||
| 601 | - Quaternion q; | ||
| 602 | - mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get(q); | 598 | + Vector2 displacement = panGesture.GetScreenDisplacement(); |
| 599 | + Vector2 rotation{ | ||
| 600 | + displacement.y * -0.1f, | ||
| 601 | + displacement.x * 0.1f | ||
| 602 | + }; | ||
| 603 | + | ||
| 604 | + Quaternion q(Degree(0.f), Degree(rotation.y), Degree(rotation.x)); | ||
| 605 | + Quaternion q0 = mCenterActor.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>(); | ||
| 606 | + mCenterActor.SetProperty(Actor::Property::ORIENTATION, q * q0); | ||
| 607 | + | ||
| 603 | Matrix m = Matrix::IDENTITY; | 608 | Matrix m = Matrix::IDENTITY; |
| 604 | - m.SetTransformComponents(Vector3::ONE, q, Vector3::ZERO); | 609 | + m.SetTransformComponents(Vector3::ONE, q0, Vector3::ZERO); |
| 605 | auto yAxis = m.GetYAxis() * -1.0f; | 610 | auto yAxis = m.GetYAxis() * -1.0f; |
| 606 | 611 | ||
| 607 | yAxis.Normalize(); | 612 | yAxis.Normalize(); |