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,8 +67,7 @@ class PrimitiveShapesController : public ConnectionTracker
67 public: 67 public:
68 PrimitiveShapesController(Application& application) 68 PrimitiveShapesController(Application& application)
69 : mApplication(application), 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 // Connect to the Application's Init signal 72 // Connect to the Application's Init signal
74 mApplication.InitSignal().Connect(this, &PrimitiveShapesController::Create); 73 mApplication.InitSignal().Connect(this, &PrimitiveShapesController::Create);
@@ -639,13 +638,13 @@ public: @@ -639,13 +638,13 @@ public:
639 case GestureState::CONTINUING: 638 case GestureState::CONTINUING:
640 { 639 {
641 //Rotate based off the gesture. 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 break; 649 break;
651 } 650 }
@@ -697,12 +696,11 @@ private: @@ -697,12 +696,11 @@ private:
697 Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned. 696 Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned.
698 697
699 Vector4 mColor; ///< Color to set all shapes. 698 Vector4 mColor; ///< Color to set all shapes.
700 - Vector2 mRotation; ///< Keeps track of model rotation.  
701 }; 699 };
702 700
703 int DALI_EXPORT_API main(int argc, char** argv) 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 PrimitiveShapesController test(application); 704 PrimitiveShapesController test(application);
707 application.MainLoop(); 705 application.MainLoop();
708 return 0; 706 return 0;