Commit dd10a1d0f410b3005684e9f46b42d44008a6cbc8

Authored by György Straub
1 parent a694ac42

Fixed the rotation interaction in the Primitive Shapes example.

Change-Id: If50a69da01c02fdb6047d766d5d213648b02a360
Signed-off-by: György Straub <g.straub@partner.samsung.com>
examples/primitive-shapes/primitive-shapes-example.cpp
... ... @@ -67,8 +67,7 @@ class PrimitiveShapesController : public ConnectionTracker
67 67 public:
68 68 PrimitiveShapesController(Application& application)
69 69 : mApplication(application),
70   - mColor(Vector4(0.3f, 0.7f, 1.0f, 1.0f)),
71   - mRotation(Vector2::ZERO)
  70 + mColor(Vector4(0.3f, 0.7f, 1.0f, 1.0f))
72 71 {
73 72 // Connect to the Application's Init signal
74 73 mApplication.InitSignal().Connect(this, &PrimitiveShapesController::Create);
... ... @@ -639,13 +638,13 @@ public:
639 638 case GestureState::CONTINUING:
640 639 {
641 640 //Rotate based off the gesture.
642   - const Vector2& displacement = gesture.GetDisplacement();
643   - mRotation.x -= displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
644   - mRotation.y += displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
645   - Quaternion rotation = Quaternion(Radian(mRotation.x), Vector3::XAXIS) *
646   - Quaternion(Radian(mRotation.y), Vector3::YAXIS);
  641 + Vector2 displacement = gesture.GetDisplacement();
  642 + Quaternion q0 = mModel.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
  643 + Vector2 rotation { displacement.y / X_ROTATION_DISPLACEMENT_FACTOR, // Y displacement rotates around X axis
  644 + displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR }; // X displacement rotates around Y axis
  645 + Quaternion q = Quaternion(Radian(rotation.x), Radian(rotation.y), Radian(0.f));
647 646  
648   - mModel.SetProperty(Actor::Property::ORIENTATION, rotation);
  647 + mModel.SetProperty(Actor::Property::ORIENTATION, q * q0);
649 648  
650 649 break;
651 650 }
... ... @@ -697,12 +696,11 @@ private:
697 696 Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned.
698 697  
699 698 Vector4 mColor; ///< Color to set all shapes.
700   - Vector2 mRotation; ///< Keeps track of model rotation.
701 699 };
702 700  
703 701 int DALI_EXPORT_API main(int argc, char** argv)
704 702 {
705   - Application application = Application::New(&argc, &argv);
  703 + Application application = Application::New(&argc, &argv, DEMO_THEME_PATH);
706 704 PrimitiveShapesController test(application);
707 705 application.MainLoop();
708 706 return 0;
... ...