Merge branch 'devel/master' into tizen accepted/tizen/unified/20231130.180909
authorhuiyu.eun <huiyu.eun@samsung.com>
Wed, 29 Nov 2023 04:52:57 +0000 (13:52 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Wed, 29 Nov 2023 04:52:57 +0000 (13:52 +0900)
Change-Id: Ic1e8e2f16d42a84caeb4d6b6a7238400bdcb78eb

14 files changed:
build/tizen/CMakeLists.txt
com.samsung.dali-demo.xml
examples/benchmark-2dphysics/README.md [new file with mode: 0644]
examples/benchmark-2dphysics/benchmark-2d-physics-controller.cpp [new file with mode: 0644]
examples/benchmark-2dphysics/dependencies.cmake [new file with mode: 0644]
examples/scene3d-model/scene3d-model-example.cpp
packaging/com.samsung.dali-demo.spec
resources/models/Duck.bin [new file with mode: 0644]
resources/models/Duck.gltf [new file with mode: 0644]
resources/models/DuckCM.png [new file with mode: 0644]
resources/po/en_GB.po
resources/po/en_US.po
shared/dali-demo-strings.h
tests-reel/dali-tests-reel.cpp

index 5270d57..68e3ca2 100644 (file)
@@ -21,8 +21,8 @@ OPTION(ENABLE_TRACE              "Enable Trace" OFF)
 OPTION(ENABLE_PKG_CONFIGURE      "Use pkgconfig" ON)
 OPTION(INTERNATIONALIZATION      "Internationalization demo string names" ON)
 
-SET(ROOT_SRC_DIR ${CMAKE_SOURCE_DIR}/../..)
-SET(DEMO_SHARED ${CMAKE_SOURCE_DIR}/../../shared)
+SET(ROOT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
+SET(DEMO_SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../../shared)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
index 59fceae..4c95b90 100644 (file)
@@ -43,6 +43,9 @@
        <ui-application appid="benchmark.example" exec="/usr/apps/com.samsung.dali-demo/bin/benchmark.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Benchmark</label>
        </ui-application>
+       <ui-application appid="benchmark-2dphysics.example" exec="/usr/apps/com.samsung.dali-demo/bin/benchmark-2dphysics.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>Benchmark 2D Physics</label>
+       </ui-application>
        <ui-application appid="bezier-curve.example" exec="/usr/apps/com.samsung.dali-demo/bin/bezier-curve.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Alpha Function Curve</label>
        </ui-application>
diff --git a/examples/benchmark-2dphysics/README.md b/examples/benchmark-2dphysics/README.md
new file mode 100644 (file)
index 0000000..9fc5712
--- /dev/null
@@ -0,0 +1,13 @@
+# 2d Physics benchmark Example
+
+This is an example to test the performance of DALI with and without physics enabled.
+It first measures performance with physics and collisions off, by animating motion using
+property notifications for 30 seconds. Uses N ImageViews, where N defaults to 500
+
+Then, it creates a PhysicsAdaptor and uses zero gravity and a bounding box to achieve a
+similar visual result with N ImageViews attached to physics bodies.
+
+N can be changed on the command line.
+
+
+
diff --git a/examples/benchmark-2dphysics/benchmark-2d-physics-controller.cpp b/examples/benchmark-2dphysics/benchmark-2d-physics-controller.cpp
new file mode 100644 (file)
index 0000000..2926d5c
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-physics/dali-physics.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali/devel-api/adaptor-framework/key-devel.h>
+#include <dali/devel-api/events/hit-test-algorithm.h>
+#include <dali/integration-api/debug.h>
+
+#include <chipmunk/chipmunk.h>
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+using namespace Dali;
+using namespace Dali::Toolkit::Physics;
+using namespace Dali::ParentOrigin;
+using namespace Dali::AnchorPoint;
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gPhysicsDemo = Debug::Filter::New(Debug::Concise, false, "LOG_PHYSICS_EXAMPLE");
+#endif
+
+const float    MAX_ANIMATION_DURATION{60.0f};
+const uint32_t ANIMATION_TIME{30000};
+const uint32_t DEFAULT_BALL_COUNT{500};
+
+#if defined(_ARCH_ARM_)
+#define DEMO_ICON_DIR "/usr/share/icons"
+#else
+#define DEMO_ICON_DIR DEMO_IMAGE_DIR
+#endif
+
+const std::string BALL_IMAGES[] = {DEMO_IMAGE_DIR "/blocks-ball.png",
+                                   DEMO_ICON_DIR "/dali-tests.png",
+                                   DEMO_ICON_DIR "/dali-examples.png",
+                                   DEMO_ICON_DIR "/com.samsung.dali-demo.png"};
+
+const Vector2 BALL_SIZE{26.0f, 26.0f};
+
+// Groups that can collide with each other:
+const cpGroup BALL_GROUP{1 << 0};
+const cpGroup BOUNDS_GROUP{1 << 1};
+
+const cpBitmask COLLISION_MASK{0xfF};
+
+const cpBitmask BALL_COLLIDES_WITH{BALL_GROUP | BOUNDS_GROUP};
+
+/**
+ * @brief The physics demo using Chipmunk2D APIs.
+ */
+class Physics2dBenchmarkController : public ConnectionTracker
+{
+public:
+  Physics2dBenchmarkController(Application& app, int numberOfBalls)
+  : mApplication(app),
+    mBallNumber(numberOfBalls)
+  {
+    app.InitSignal().Connect(this, &Physics2dBenchmarkController::OnInit);
+    app.TerminateSignal().Connect(this, &Physics2dBenchmarkController::OnTerminate);
+  }
+
+  ~Physics2dBenchmarkController() = default;
+
+  void OnInit(Application& application)
+  {
+    mWindow = application.GetWindow();
+    mWindow.ResizeSignal().Connect(this, &Physics2dBenchmarkController::OnWindowResize);
+    mWindow.KeyEventSignal().Connect(this, &Physics2dBenchmarkController::OnKeyEv);
+    mWindow.GetRootLayer().TouchedSignal().Connect(this, &Physics2dBenchmarkController::OnTouched);
+    mWindow.SetBackgroundColor(Color::DARK_SLATE_GRAY);
+
+    CreateAnimationSimulation();
+
+    mTimer = Timer::New(ANIMATION_TIME);
+    mTimer.TickSignal().Connect(this, &Physics2dBenchmarkController::AnimationSimFinished);
+    mTimer.Start();
+  }
+
+  void CreateAnimationSimulation()
+  {
+    Window::WindowSize windowSize = mWindow.GetSize();
+    mBallActors.resize(mBallNumber);
+    mBallVelocity.resize(mBallNumber);
+
+    mAnimationSimRootActor = Layer::New();
+    mAnimationSimRootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+    mAnimationSimRootActor[Actor::Property::PARENT_ORIGIN] = Dali::ParentOrigin::CENTER;
+    mAnimationSimRootActor[Actor::Property::ANCHOR_POINT]  = Dali::AnchorPoint::CENTER;
+
+    mWindow.Add(mAnimationSimRootActor);
+    std::ostringstream oss;
+    oss << "Animation simulation of " << mBallNumber << " balls";
+    auto title = Toolkit::TextLabel::New(oss.str());
+    mAnimationSimRootActor.Add(title);
+    title[Toolkit::TextLabel::Property::TEXT_COLOR]           = Color::WHITE;
+    title[Actor::Property::PARENT_ORIGIN]                     = Dali::ParentOrigin::TOP_CENTER;
+    title[Actor::Property::ANCHOR_POINT]                      = Dali::AnchorPoint::TOP_CENTER;
+    title[Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT] = HorizontalAlignment::CENTER;
+    title.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
+
+    const float margin(BALL_SIZE.width * 0.5f);
+
+    for(int i = 0; i < mBallNumber; ++i)
+    {
+      Actor ball = mBallActors[i]          = Toolkit::ImageView::New(BALL_IMAGES[rand() % 4]);
+      ball[Actor::Property::PARENT_ORIGIN] = Dali::ParentOrigin::CENTER;
+      ball[Actor::Property::ANCHOR_POINT]  = Dali::AnchorPoint::CENTER;
+
+      ball[Actor::Property::NAME]     = "Ball";
+      ball[Actor::Property::SIZE]     = BALL_SIZE; // Halve the image size
+      int width                       = windowSize.GetWidth() / 2;
+      int height                      = windowSize.GetHeight() / 2;
+      ball[Actor::Property::POSITION] = Vector3(Random::Range(margin - width, width - margin), Random::Range(margin - height, height - margin), 0.0f);
+      ball.RegisterProperty("index", i);
+      mAnimationSimRootActor.Add(ball);
+
+      mBallVelocity[i] = Vector3(Random::Range(-25.0f, 25.0f), Random::Range(-25.0f, 25.0f), 0.0f);
+      mBallVelocity[i].Normalize();
+      mBallVelocity[i] = mBallVelocity[i] * Random::Range(15.0f, 50.0f);
+
+      PropertyNotification leftNotify = mBallActors[i].AddPropertyNotification(Actor::Property::POSITION_X, LessThanCondition(margin - width));
+      leftNotify.NotifySignal().Connect(this, &Physics2dBenchmarkController::OnHitLeftWall);
+
+      PropertyNotification rightNotify = mBallActors[i].AddPropertyNotification(Actor::Property::POSITION_X, GreaterThanCondition(width - margin));
+      rightNotify.NotifySignal().Connect(this, &Physics2dBenchmarkController::OnHitRightWall);
+
+      PropertyNotification topNotify = mBallActors[i].AddPropertyNotification(Actor::Property::POSITION_Y, LessThanCondition(margin - height));
+      topNotify.NotifySignal().Connect(this, &Physics2dBenchmarkController::OnHitTopWall);
+
+      PropertyNotification bottomNotify = mBallActors[i].AddPropertyNotification(Actor::Property::POSITION_Y, GreaterThanCondition(height - margin));
+      bottomNotify.NotifySignal().Connect(this, &Physics2dBenchmarkController::OnHitBottomWall);
+    }
+
+    title.RaiseToTop();
+    ContinueAnimation();
+  }
+
+  bool AnimationSimFinished()
+  {
+    static bool first = true;
+    if(first)
+    {
+      UnparentAndReset(mAnimationSimRootActor);
+      mBallAnimation.Stop();
+      mBallAnimation.Clear();
+      first = false;
+
+      CreatePhysicsSimulation();
+      return true;
+    }
+
+    mApplication.Quit();
+    return false;
+  }
+
+  void ContinueAnimation()
+  {
+    if(mBallAnimation)
+    {
+      mBallAnimation.Clear();
+    }
+    mBallAnimation = Animation::New(MAX_ANIMATION_DURATION);
+    for(int i = 0; i < mBallNumber; ++i)
+    {
+      mBallAnimation.AnimateBy(Property(mBallActors[i], Actor::Property::POSITION), mBallVelocity[i] * MAX_ANIMATION_DURATION);
+    }
+    mBallAnimation.Play();
+  }
+
+  void OnHitLeftWall(PropertyNotification& source)
+  {
+    auto actor = Actor::DownCast(source.GetTarget());
+    if(actor)
+    {
+      int index        = actor["index"];
+      mBallVelocity[index].x = fabsf(mBallVelocity[index].x);
+      ContinueAnimation();
+    }
+  }
+
+  void OnHitRightWall(PropertyNotification& source)
+  {
+    auto actor = Actor::DownCast(source.GetTarget());
+    if(actor)
+    {
+      int index        = actor["index"];
+      mBallVelocity[index].x = -fabsf(mBallVelocity[index].x);
+      ContinueAnimation();
+    }
+  }
+
+  void OnHitBottomWall(PropertyNotification& source)
+  {
+    auto actor = Actor::DownCast(source.GetTarget());
+    if(actor)
+    {
+      int index        = actor["index"];
+      mBallVelocity[index].y = -fabsf(mBallVelocity[index].y);
+      ContinueAnimation();
+    }
+  }
+
+  void OnHitTopWall(PropertyNotification& source)
+  {
+    auto actor = Actor::DownCast(source.GetTarget());
+    if(actor)
+    {
+      int index        = actor["index"];
+      mBallVelocity[index].y = fabsf(mBallVelocity[index].y);
+      ContinueAnimation();
+    }
+  }
+
+  void CreatePhysicsSimulation()
+  {
+    Window::WindowSize windowSize = mWindow.GetSize();
+
+    // Map Physics space (origin bottom left, +ve Y up)
+    // to DALi space (origin center, +ve Y down)
+    mPhysicsTransform.SetIdentityAndScale(Vector3(1.0f, -1.0f, 1.0f));
+    mPhysicsTransform.SetTranslation(Vector3(windowSize.GetWidth() * 0.5f,
+                                             windowSize.GetHeight() * 0.5f,
+                                             0.0f));
+
+    mPhysicsAdaptor = PhysicsAdaptor::New(mPhysicsTransform, windowSize);
+    mPhysicsRoot    = mPhysicsAdaptor.GetRootActor();
+    mWindow.Add(mPhysicsRoot);
+
+    auto     scopedAccessor = mPhysicsAdaptor.GetPhysicsAccessor();
+    cpSpace* space          = scopedAccessor->GetNative().Get<cpSpace*>();
+    cpSpaceSetGravity(space, cpv(0, 0));
+
+    CreateBounds(space, windowSize);
+
+    for(int i = 0; i < mBallNumber; ++i)
+    {
+      mBalls.push_back(CreateBall(space));
+    }
+
+    // Process any async queued methods next frame
+    mPhysicsAdaptor.CreateSyncPoint();
+
+    std::ostringstream oss;
+    oss << "Physics simulation of " << mBallNumber << " balls";
+    auto title = Toolkit::TextLabel::New(oss.str());
+    mPhysicsRoot.Add(title);
+    title[Toolkit::TextLabel::Property::TEXT_COLOR]           = Color::WHITE;
+    title[Actor::Property::PARENT_ORIGIN]                     = Dali::ParentOrigin::TOP_CENTER;
+    title[Actor::Property::ANCHOR_POINT]                      = Dali::AnchorPoint::TOP_CENTER;
+    title[Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT] = HorizontalAlignment::CENTER;
+    title.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
+    title.RaiseToTop();
+  }
+
+  PhysicsActor CreateBall(cpSpace* space)
+  {
+    const float BALL_MASS       = 10.0f;
+    const float BALL_RADIUS     = BALL_SIZE.x * 0.25f;
+    const float BALL_ELASTICITY = 1.0f;
+    const float BALL_FRICTION   = 0.0f;
+
+    auto ball                   = Toolkit::ImageView::New(BALL_IMAGES[rand() % 4]);
+    ball[Actor::Property::NAME] = "Ball";
+    ball[Actor::Property::SIZE] = BALL_SIZE * 0.5f;
+    cpBody* body                = cpSpaceAddBody(space, cpBodyNew(BALL_MASS, cpMomentForCircle(BALL_MASS, 0.0f, BALL_RADIUS, cpvzero)));
+
+    cpShape* shape = cpSpaceAddShape(space, cpCircleShapeNew(body, BALL_RADIUS, cpvzero));
+    cpShapeSetElasticity(shape, BALL_ELASTICITY);
+    cpShapeSetFriction(shape, BALL_FRICTION);
+
+    PhysicsActor physicsBall = mPhysicsAdaptor.AddActorBody(ball, body);
+
+    Window::WindowSize windowSize = mWindow.GetSize();
+
+    const float fw = 0.5f * (windowSize.GetWidth() - BALL_RADIUS);
+    const float fh = 0.5f * (windowSize.GetHeight() - BALL_RADIUS);
+
+    // Example of setting physics property on update thread
+    physicsBall.AsyncSetPhysicsPosition(Vector3(Random::Range(-fw, fw), Random::Range(-fh, -fh * 0.5), 0.0f));
+
+    // Example of queuing a chipmunk method to run on the update thread
+    mPhysicsAdaptor.Queue([body]() {
+      cpBodySetVelocity(body, cpv(Random::Range(-100.0, 100.0), Random::Range(-100.0, 100.0)));
+    });
+    return physicsBall;
+  }
+
+  void CreateBounds(cpSpace* space, Window::WindowSize size)
+  {
+    // We're working in physics space here - coords are: origin: bottom left, +ve Y: up
+    int32_t xBound = static_cast<int32_t>(static_cast<uint32_t>(size.GetWidth()));
+    int32_t yBound = static_cast<int32_t>(static_cast<uint32_t>(size.GetHeight()));
+
+    cpBody* staticBody = cpSpaceGetStaticBody(space);
+
+    if(mLeftBound)
+    {
+      cpSpaceRemoveShape(space, mLeftBound);
+      cpSpaceRemoveShape(space, mRightBound);
+      cpSpaceRemoveShape(space, mTopBound);
+      cpSpaceRemoveShape(space, mBottomBound);
+      cpShapeFree(mLeftBound);
+      cpShapeFree(mRightBound);
+      cpShapeFree(mTopBound);
+      cpShapeFree(mBottomBound);
+    }
+    mLeftBound   = AddBound(space, staticBody, cpv(0, 0), cpv(0, yBound));
+    mRightBound  = AddBound(space, staticBody, cpv(xBound, 0), cpv(xBound, yBound));
+    mTopBound    = AddBound(space, staticBody, cpv(0, 0), cpv(xBound, 0));
+    mBottomBound = AddBound(space, staticBody, cpv(0, yBound), cpv(xBound, yBound));
+  }
+
+  cpShape* AddBound(cpSpace* space, cpBody* staticBody, cpVect start, cpVect end)
+  {
+    cpShape* shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, start, end, 0.0f));
+    cpShapeSetElasticity(shape, 1.0f);
+    cpShapeSetFriction(shape, 1.0f);
+
+    cpShapeSetFilter(shape, cpShapeFilterNew(BOUNDS_GROUP, COLLISION_MASK, COLLISION_MASK));
+    return shape;
+  }
+
+  void OnTerminate(Application& application)
+  {
+    UnparentAndReset(mPhysicsRoot);
+  }
+
+  void OnWindowResize(Window window, Window::WindowSize newSize)
+  {
+    auto     scopedAccessor = mPhysicsAdaptor.GetPhysicsAccessor();
+    cpSpace* space          = scopedAccessor->GetNative().Get<cpSpace*>();
+
+    CreateBounds(space, newSize);
+  }
+
+  bool OnTouched(Dali::Actor actor, const Dali::TouchEvent& touch)
+  {
+    mApplication.Quit();
+    return false;
+  }
+
+  void OnKeyEv(const Dali::KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+  Window       mWindow;
+
+  PhysicsAdaptor            mPhysicsAdaptor;
+  std::vector<PhysicsActor> mBalls;
+  Matrix                    mPhysicsTransform;
+  Actor                     mPhysicsRoot;
+  Layer                     mPhysicsDebugLayer;
+  Layer                     mAnimationSimRootActor;
+  cpShape*                  mLeftBound{nullptr};
+  cpShape*                  mRightBound{nullptr};
+  cpShape*                  mTopBound{nullptr};
+  cpShape*                  mBottomBound{nullptr};
+
+  std::vector<Actor>   mBallActors;
+  std::vector<Vector3> mBallVelocity;
+  int                  mBallNumber;
+  Animation            mBallAnimation;
+  Timer                mTimer;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  setenv("DALI_FPS_TRACKING", "5", 1);
+  Application application = Application::New(&argc, &argv);
+
+  int numberOfBalls = DEFAULT_BALL_COUNT;
+  if(argc > 1)
+  {
+    numberOfBalls = atoi(argv[1]);
+  }
+
+  Physics2dBenchmarkController controller(application, numberOfBalls);
+  application.MainLoop();
+  return 0;
+}
diff --git a/examples/benchmark-2dphysics/dependencies.cmake b/examples/benchmark-2dphysics/dependencies.cmake
new file mode 100644 (file)
index 0000000..b30b385
--- /dev/null
@@ -0,0 +1,5 @@
+TARGET_COMPILE_OPTIONS(${EXAMPLE}.example PUBLIC ${DALI_PHYSICS_2D_CFLAGS})
+TARGET_LINK_LIBRARIES(${EXAMPLE}.example ${DALI_PHYSICS_2D_LDFLAGS})
+MESSAGE(STATUS "Included dependencies for ${EXAMPLE}")
+MESSAGE(STATUS " Compile options: ${DALI_PHYSICS_2D_CFLAGS}")
+MESSAGE(STATUS " Link options: ${DALI_PHYSICS_2D_LDFLAGS}")
index b306792..414ae5e 100644 (file)
@@ -41,54 +41,69 @@ using namespace Dali::Toolkit;
 
 namespace
 {
-static constexpr int32_t NUM_OF_GLTF_MODELS = 7;
+struct ModelInfo
+{
+  const char*   name;      ///< The name of the model.
+  const Vector2 size;      ///< The size of the model
+  const float   yPosition; ///< The position of the model in the Y axis.
+};
 
-const char* gltf_list[7] =
+const ModelInfo gltf_list[] =
   {
     /**
      * For the BoxAnimated.glb
      * Donated by Cesium for glTF testing.
      * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxAnimated
      */
-    "BoxAnimated.glb",
+    {"BoxAnimated.glb", Vector2(300.0f, 300.0f), 100.0f},
+    /**
+     * For the quantized Duck.gltf and its Assets
+     * Created by Sony Computer Entertainment Inc.
+     * Licensed under the SCEA Shared Source License, Version 1.0
+     * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Duck/glTF-Quantized
+     */
+    {"Duck.gltf", Vector2(600.0f, 600.0f), 300.0f},
     /**
      * For the Lantern.gltf and its Assets
      * Donated by Microsoft for glTF testing
      * Created by Ryan Martin
      * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Lantern
      */
-    "Lantern.gltf",
+    {"Lantern.gltf", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the BoomBox.gltf and its Assets
      * Donated by Microsoft for glTF testing
      * Created by Ryan Martin
      * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoomBox
      */
-    "BoomBox.gltf",
+    {"BoomBox.gltf", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the DamagedHelmet.glb
      * Battle Damaged Sci-fi Helmet - PBR by theblueturtle_, published under a
      * Creative Commons Attribution-NonCommercial license
      * https://sketchfab.com/models/b81008d513954189a063ff901f7abfe4
      */
-    "DamagedHelmet.glb",
+    {"DamagedHelmet.glb", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the microphone.gltf and its Assets
      * Microphone GXL 066 Bafhcteks by Gistold, published under a
      * Creative Commons Attribution-NonCommercial license
      * https://sketchfab.com/models/5172dbe9281a45f48cee8c15bdfa1831
      */
-    "microphone.gltf",
+    {"microphone.gltf", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the beer_model.dli and its Assets
      * This model includes a bottle of beer and cube box.
      */
-    "beer_model.dli",
+    {"beer_model.dli", Vector2(600.0f, 600.0f), 0.0f},
     /**
      * For the exercise_model.dli and its Assets
      * This model includes a sportsman
      */
-    "exercise_model.dli"};
+    {"exercise_model.dli", Vector2(600.0f, 600.0f), 0.0f},
+};
+
+const int32_t NUM_OF_GLTF_MODELS = sizeof(gltf_list) / sizeof(gltf_list[0]);
 
 /**
  * For the diffuse and specular cube map texture.
@@ -266,18 +281,11 @@ public:
     }
 
     std::string gltfUrl = modeldir;
-    gltfUrl += gltf_list[index];
+    gltfUrl += gltf_list[index].name;
 
     mModel = Dali::Scene3D::Model::New(gltfUrl);
-    if(index == 0u)
-    {
-      mModel.SetProperty(Dali::Actor::Property::SIZE, Vector2(300, 300));
-      mModel.SetProperty(Dali::Actor::Property::POSITION_Y, 100);
-    }
-    else
-    {
-      mModel.SetProperty(Dali::Actor::Property::SIZE, Vector2(600, 600));
-    }
+    mModel.SetProperty(Dali::Actor::Property::SIZE, gltf_list[index].size);
+    mModel.SetProperty(Dali::Actor::Property::POSITION_Y, gltf_list[index].yPosition);
     mModel.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
     mModel.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
     mModel.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
@@ -292,7 +300,7 @@ public:
     mReadyToLoad = true;
     if(mModel.GetAnimationCount() > 0)
     {
-      Animation animation = (std::string("exercise_model.dli") == gltf_list[mCurrentGlTF]) ? mModel.GetAnimation("idleToSquatClip_0") : mModel.GetAnimation(0u);
+      Animation animation = (std::string("exercise_model.dli") == gltf_list[mCurrentGlTF].name) ? mModel.GetAnimation("idleToSquatClip_0") : mModel.GetAnimation(0u);
       animation.Play();
       animation.SetLoopCount(0);
     }
index 20533b7..84a8cf8 100755 (executable)
@@ -2,7 +2,7 @@
 
 Name:       com.samsung.dali-demo
 Summary:    The OpenGLES Canvas Core Demo
-Version:    2.2.53
+Version:    2.3.0
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
diff --git a/resources/models/Duck.bin b/resources/models/Duck.bin
new file mode 100644 (file)
index 0000000..e723475
Binary files /dev/null and b/resources/models/Duck.bin differ
diff --git a/resources/models/Duck.gltf b/resources/models/Duck.gltf
new file mode 100644 (file)
index 0000000..7c5e4c7
--- /dev/null
@@ -0,0 +1,218 @@
+{\r
+  "buffers":[\r
+    {\r
+      "uri":"Duck.bin",\r
+      "byteLength":63656\r
+    }\r
+  ],\r
+  "asset":{\r
+    "version":"2.0",\r
+    "generator":"gltfpack 0.13"\r
+  },\r
+  "extensionsUsed":[\r
+    "KHR_mesh_quantization",\r
+    "KHR_texture_transform"\r
+  ],\r
+  "extensionsRequired":[\r
+    "KHR_mesh_quantization"\r
+  ],\r
+  "bufferViews":[\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":0,\r
+      "byteLength":9596,\r
+      "byteStride":4,\r
+      "target":34962\r
+    },\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":9596,\r
+      "byteLength":19192,\r
+      "byteStride":8,\r
+      "target":34962\r
+    },\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":28788,\r
+      "byteLength":9596,\r
+      "byteStride":4,\r
+      "target":34962\r
+    },\r
+    {\r
+      "buffer":0,\r
+      "byteOffset":38384,\r
+      "byteLength":25272,\r
+      "target":34963\r
+    }\r
+  ],\r
+  "accessors":[\r
+    {\r
+      "bufferView":0,\r
+      "byteOffset":0,\r
+      "componentType":5120,\r
+      "count":2399,\r
+      "type":"VEC3",\r
+      "normalized":true\r
+    },\r
+    {\r
+      "bufferView":1,\r
+      "byteOffset":0,\r
+      "componentType":5123,\r
+      "count":2399,\r
+      "type":"VEC3",\r
+      "min":[\r
+        0,\r
+        0,\r
+        0\r
+      ],\r
+      "max":[\r
+        16383,\r
+        15251,\r
+        11411\r
+      ]\r
+    },\r
+    {\r
+      "bufferView":2,\r
+      "byteOffset":0,\r
+      "componentType":5123,\r
+      "count":2399,\r
+      "type":"VEC2"\r
+    },\r
+    {\r
+      "bufferView":3,\r
+      "byteOffset":0,\r
+      "componentType":5123,\r
+      "count":12636,\r
+      "type":"SCALAR"\r
+    }\r
+  ],\r
+  "images":[\r
+    {\r
+      "uri":"DuckCM.png"\r
+    }\r
+  ],\r
+  "textures":[\r
+    {\r
+      "source":0\r
+    }\r
+  ],\r
+  "materials":[\r
+    {\r
+      "name":"blinn3-fx",\r
+      "pbrMetallicRoughness":{\r
+        "baseColorTexture":{\r
+          "index":0,\r
+          "texCoord":0,\r
+          "extensions":{\r
+            "KHR_texture_transform":{\r
+              "offset":[\r
+                0.0264090002,\r
+                0.019963026\r
+              ],\r
+              "scale":[\r
+                0.000233684244,\r
+                0.000234450286\r
+              ]\r
+            }\r
+          }\r
+        },\r
+        "metallicFactor":0\r
+      }\r
+    }\r
+  ],\r
+  "meshes":[\r
+    {\r
+      "primitives":[\r
+        {\r
+          "attributes":{\r
+            "NORMAL":0,\r
+            "POSITION":1,\r
+            "TEXCOORD_0":2\r
+          },\r
+          "mode":4,\r
+          "indices":3,\r
+          "material":0\r
+        }\r
+      ]\r
+    }\r
+  ],\r
+  "nodes":[\r
+    {\r
+      "mesh":0,\r
+      "translation":[\r
+        -0.692984998,\r
+        0.0992936939,\r
+        -0.613281965\r
+      ],\r
+      "scale":[\r
+        0.900101006161,\r
+        0.900101006161,\r
+        0.900101006161\r
+      ]\r
+    },\r
+    {\r
+      "matrix":[\r
+        0.00999999978,\r
+        0,\r
+        0,\r
+        0,\r
+        0,\r
+        0.00999999978,\r
+        0,\r
+        0,\r
+        0,\r
+        0,\r
+        0.00999999978,\r
+        0,\r
+        0,\r
+        0,\r
+        0,\r
+        1\r
+      ],\r
+      "children":[\r
+        2\r
+      ]\r
+    },\r
+    {\r
+      "matrix":[\r
+        -0.72896868,\r
+        0,\r
+        -0.684547067,\r
+        0,\r
+        -0.425204903,\r
+        0.783693433,\r
+        0.452797294,\r
+        0,\r
+        0.536475062,\r
+        0.621147811,\r
+        -0.57128799,\r
+        0,\r
+        400.113007,\r
+        463.264008,\r
+        -431.078033,\r
+        1\r
+      ],\r
+      "camera":0\r
+    }\r
+  ],\r
+  "scenes":[\r
+    {\r
+      "nodes":[\r
+        0,\r
+        1\r
+      ]\r
+    }\r
+  ],\r
+  "cameras":[\r
+    {\r
+      "type":"perspective",\r
+      "perspective":{\r
+        "yfov":0.660592556,\r
+        "znear":1,\r
+        "aspectRatio":1.5,\r
+        "zfar":10000\r
+      }\r
+    }\r
+  ],\r
+  "scene":0\r
+}
\ No newline at end of file
diff --git a/resources/models/DuckCM.png b/resources/models/DuckCM.png
new file mode 100644 (file)
index 0000000..9fa2dd4
Binary files /dev/null and b/resources/models/DuckCM.png differ
index ad38e07..30178dc 100755 (executable)
@@ -16,6 +16,9 @@ msgstr "Basic Light"
 msgid "DALI_DEMO_STR_TITLE_BENCHMARK"
 msgstr "ImageView Benchmark"
 
+msgid "DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS"
+msgstr "2D Physics Benchmark"
+
 msgid "DALI_DEMO_STR_TITLE_BEZIER_CURVE"
 msgstr "Bezier Curve"
 
index 7c96551..52592cd 100755 (executable)
@@ -16,6 +16,9 @@ msgstr "Basic Light"
 msgid "DALI_DEMO_STR_TITLE_BENCHMARK"
 msgstr "ImageView Benchmark"
 
+msgid "DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS"
+msgstr "2D Physics Benchmark"
+
 msgid "DALI_DEMO_STR_TITLE_BEZIER_CURVE"
 msgstr "Bezier Curve"
 
index 90e16f1..3346db7 100644 (file)
@@ -41,6 +41,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_ARC_VISUAL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ARC_VISUAL")
 #define DALI_DEMO_STR_TITLE_BASIC_LIGHT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BASIC_LIGHT")
 #define DALI_DEMO_STR_TITLE_BENCHMARK dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BENCHMARK")
+#define DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS")
 #define DALI_DEMO_STR_TITLE_BEZIER_CURVE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BEZIER_CURVE")
 #define DALI_DEMO_STR_TITLE_BLOCKS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOCKS")
 #define DALI_DEMO_STR_TITLE_BLOOM_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOOM_VIEW")
@@ -163,6 +164,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_ARC_VISUAL "Arc Visual"
 #define DALI_DEMO_STR_TITLE_BASIC_LIGHT "Basic Light"
 #define DALI_DEMO_STR_TITLE_BENCHMARK "ImageView Benchmark"
+#define DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS "2D Physics Benchmark"
 #define DALI_DEMO_STR_TITLE_BEZIER_CURVE "Alpha Function Bezier Curve"
 #define DALI_DEMO_STR_TITLE_BLOCKS "Blocks"
 #define DALI_DEMO_STR_TITLE_BLOOM_VIEW "Bloom"
index 8dfd6ff..5d2d3c4 100644 (file)
@@ -38,6 +38,7 @@ int DALI_EXPORT_API main(int argc, char** argv)
   DaliTableView demo(app);
 
   demo.AddExample(Example("benchmark.example", DALI_DEMO_STR_TITLE_BENCHMARK));
+  demo.AddExample(Example("benchmark-2dphysics.example", DALI_DEMO_STR_TITLE_BENCHMARK_2D_PHYSICS));
   demo.AddExample(Example("camera-test.example", DALI_DEMO_STR_TITLE_CAMERA_TEST));
   demo.AddExample(Example("compressed-texture-formats.example", DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS));
   demo.AddExample(Example("homescreen-benchmark.example", DALI_DEMO_STR_TITLE_HOMESCREEN));