Changed the shadow/lights example defaults 46/88246/4
authorDavid Steele <david.steele@partner.samsung.com>
Thu, 15 Sep 2016 11:58:03 +0000 (12:58 +0100)
committerDavid Steele <david.steele@partner.samsung.com>
Fri, 16 Sep 2016 15:45:13 +0000 (16:45 +0100)
Updated the defaults on the shadow / light example to first
move the light, rather than panning the scene.

Updated the intial orientations to look better.

Change-Id: I8eceb5f536a75fef5e6881987452efb53af6e544
Signed-off-by: David Steele <david.steele@samsung.com>
com.samsung.dali-demo.xml
demo/dali-demo.cpp
examples/shadows-and-lights/shadows-and-lights-example.cpp [moved from examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp with 95% similarity]

index 4a58819..b7980de 100644 (file)
@@ -64,7 +64,7 @@
        <ui-application appid="scroll-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/scroll-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Scroll View</label>
        </ui-application>
-       <ui-application appid="shadow-bone-lighting.example" exec="/usr/apps/com.samsung.dali-demo/bin/shadow-bone-lighting.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+       <ui-application appid="shadows-and-lights.example" exec="/usr/apps/com.samsung.dali-demo/bin/shadows-and-lights.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Shadows and Lights</label>
        </ui-application>
        <ui-application appid="dali-builder" exec="/usr/apps/com.samsung.dali-demo/bin/dali-builder" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
index f413590..408eb58 100644 (file)
@@ -48,7 +48,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
   demo.AddExample(Example("page-turn-view.example", DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW));
   demo.AddExample(Example("refraction-effect.example", DALI_DEMO_STR_TITLE_REFRACTION));
   demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
-  demo.AddExample(Example("shadow-bone-lighting.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS));
+  demo.AddExample(Example("shadows-and-lights.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS));
   demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI));
   demo.AddExample(Example("image-scaling-and-filtering.example", DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING));
   demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING));
@@ -35,7 +35,7 @@ const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-default.png" );
 const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
 
 const char* APPLICATION_TITLE_PAN_LIGHT( "Lighting: Pan Light" );
-const char* APPLICATION_TITLE_PAN_OBJECT( "Lighting: Rotate Object" );
+const char* APPLICATION_TITLE_ROTATE_OBJECT( "Lighting: Rotate Object" );
 const char* APPLICATION_TITLE_PAN_SCENE( "Lighting: Pan Scene" );
 const char* APPLICATION_TITLE_ROTATE_SCENE( "Lighting: Rotate Scene" );
 const char* CHANGE_EFFECT_IMAGE( DEMO_IMAGE_DIR "icon-change.png" );
@@ -60,8 +60,8 @@ const Vector2 DEFAULT_STAGE_SIZE( 480.0f, 800.0f );
 
 const float X_ROTATION_DISPLACEMENT_FACTOR = 60.f;
 const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.f;
-const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 180.f;
-const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 180.f;
+const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 1/360.f;
+const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 1/360.f;
 
 }
 
@@ -81,16 +81,16 @@ public:
   TestApp(Application &app)
   : mApp(app),
     mPaused(false),
-    mTranslation(Vector3::ZERO),
-    mSceneYRotation( Dali::ANGLE_30 * 0.5f ),
-    mSceneXRotation( Dali::ANGLE_30 ),
-    mLightYRotation(0.0f),
-    mLightXRotation(0.0f),
-    mObjectYRotation(0.0f),
+    mTranslation(22.0f, -1.0f, 0.0f),
+    mSceneXRotation( Degree(-6.0f) ), // Initial values give a reasonable off-straight view.
+    mSceneYRotation( Degree(20.0f) ),
+    mLightXRotation( Degree(-1.5f) ),
+    mLightYRotation( Degree(-9.5f) ),
     mObjectXRotation(0.0f),
-    mPinchScale(0.5f),
-    mScaleAtPinchStart(0.5f),
-    mPanState(PAN_SCENE)
+    mObjectYRotation(0.0f),
+    mPinchScale(0.6f),
+    mScaleAtPinchStart(0.6f),
+    mPanState(PAN_LIGHT)
   {
     app.InitSignal().Connect(this, &TestApp::Create);
     app.TerminateSignal().Connect(this, &TestApp::Terminate);
@@ -157,7 +157,7 @@ public:
     toolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
 
     // Set Title text
-    mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) );
+    mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) );
 
     //Add a reset button
     Toolkit::PushButton resetButton = Toolkit::PushButton::New();
@@ -167,7 +167,7 @@ public:
     toolBar.AddControl( resetButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
 
     // Setup
-    mView.SetPosition(Vector3(0.0f, 0.0f, -50));
+    mView.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
 
     mContents.SetBehavior(Layer::LAYER_3D);
     mContents.SetPosition(mTranslation);
@@ -324,9 +324,9 @@ public:
         {
           case PAN_LIGHT:
           {
-            mLightXRotation = mLightXRotation - gesture.displacement.y / LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+            mLightXRotation = mLightXRotation - gesture.displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
             mLightXRotation = Clamp(mLightXRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
-            mLightYRotation = mLightYRotation + gesture.displacement.x / LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+            mLightYRotation = mLightYRotation + gesture.displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
             mLightYRotation = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
             mLightAnchor.SetOrientation( CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
             break;
@@ -407,22 +407,22 @@ public:
   {
     switch(mPanState)
     {
-      case PAN_SCENE:
-        mPanState = ROTATE_SCENE;
-        mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_SCENE) );
-        break;
-      case ROTATE_SCENE:
-        mPanState = PAN_LIGHT;
-        mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) );
-        break;
       case PAN_LIGHT:
         mPanState = ROTATE_OBJECT;
-        mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_OBJECT) );
+        mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_OBJECT) );
         break;
       case ROTATE_OBJECT:
+        mPanState = ROTATE_SCENE;
+        mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_SCENE) );
+        break;
+      case ROTATE_SCENE:
         mPanState = PAN_SCENE;
         mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) );
         break;
+      case PAN_SCENE:
+        mPanState = PAN_LIGHT;
+        mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) );
+        break;
       default:
         break;
     }
@@ -464,12 +464,12 @@ private:
   PinchGestureDetector      mPinchGestureDetector;
   TapGestureDetector        mTapGestureDetector;
   Vector3                   mTranslation;
-  Radian                    mSceneYRotation;
   Radian                    mSceneXRotation;
-  Radian                    mLightYRotation;
+  Radian                    mSceneYRotation;
   Radian                    mLightXRotation;
-  Radian                    mObjectYRotation;
+  Radian                    mLightYRotation;
   Radian                    mObjectXRotation;
+  Radian                    mObjectYRotation;
   float                     mPinchScale;
   float                     mScaleAtPinchStart;