Add Scene3D::Panel example 64/313464/7
authorSeungho Baek <sbsh.baek@samsung.com>
Wed, 26 Jun 2024 07:39:38 +0000 (16:39 +0900)
committerSeungho Baek <sbsh.baek@samsung.com>
Mon, 19 Aug 2024 06:04:36 +0000 (15:04 +0900)
Change-Id: I9e978e1952f132d1b367c688ecdedf43f95e3bc9
Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
14 files changed:
com.samsung.dali-demo.xml
examples-reel/dali-examples-reel.cpp
examples/scene3d-panel/scene3d-panel-example.cpp [new file with mode: 0644]
resources/po/as.po
resources/po/de.po
resources/po/en_GB.po
resources/po/en_US.po
resources/po/es.po
resources/po/fi.po
resources/po/ko.po
resources/po/ml.po
resources/po/ur.po
resources/po/zn_CH.po
shared/dali-demo-strings.h

index b24929421e7fdcb9a0dac8da89c040560b912bea..bdb7821f0c792ac1d8e5d06fe9f9dbe54c5a1079 100644 (file)
        <ui-application appid="scene3d-model.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene3d-model.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Scene3D Model</label>
        </ui-application>
+       <ui-application appid="scene3d-panel.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene3d-panel.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>Scene3D Panel</label>
+       </ui-application>
        <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>
index e7c9398a7e705129db3681793c48ea5a70e5d124..9f487190bacf82b4d5e00a11f38664bc9556e852 100644 (file)
@@ -95,6 +95,7 @@ int DALI_EXPORT_API main(int argc, char** argv)
   demo.AddExample(Example("ray-marching.example", DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING));
   demo.AddExample(Example("scene3d-light.example", DALI_DEMO_STR_TITLE_SCENE3D_LIGHT));
   demo.AddExample(Example("scene3d-model.example", DALI_DEMO_STR_TITLE_SCENE3D_MODEL));
+  demo.AddExample(Example("scene3d-panel.example", DALI_DEMO_STR_TITLE_SCENE3D_PANEL));
   demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
   demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE));
   demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING));
diff --git a/examples/scene3d-panel/scene3d-panel-example.cpp b/examples/scene3d-panel/scene3d-panel-example.cpp
new file mode 100644 (file)
index 0000000..01653c7
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2024 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-toolkit/dali-toolkit.h>
+#include <dali-scene3d/dali-scene3d.h>
+#include <dali/integration-api/debug.h>
+
+using namespace Dali;
+using Dali::Toolkit::TextLabel;
+
+namespace
+{
+  Vector3 BackFaceColors[3] =
+  {
+    Vector3(1.0f, 0.0f, 0.0f),
+    Vector3(0.0f, 1.0f, 0.0f),
+    Vector3(0.0f, 0.0f, 1.0f),
+  };
+}
+
+// This example shows how to create and display Hello World! using a simple TextActor
+//
+class Scene3DPanelController : public ConnectionTracker
+{
+public:
+  Scene3DPanelController(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &Scene3DPanelController::Create);
+  }
+
+  ~Scene3DPanelController() = default; // Nothing to do in destructor
+
+  // The Init signal is received once (only) during the Application lifetime
+  void Create(Application& application)
+  {
+    // Get a handle to the window
+    Window window = application.GetWindow();
+    window.SetBackgroundColor(Color::WHITE);
+
+    Vector2 windowSize(window.GetSize().GetWidth(), window.GetSize().GetHeight());
+
+    Dali::Scene3D::SceneView sceneView = Scene3D::SceneView::New();
+    sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+    sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    sceneView.SetProperty(Dali::Actor::Property::SIZE, windowSize);
+    sceneView.SetBackgroundColor(Color::BEIGE);
+    sceneView.UseFramebuffer(true);
+    window.Add(sceneView);
+
+    Dali::Toolkit::Control parent = Dali::Toolkit::Control::New();
+    parent.SetBackgroundColor(Color::BLUE);
+    parent.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    parent.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+    parent.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
+
+    Dali::Toolkit::Control child = Dali::Toolkit::Control::New();
+    child.SetBackgroundColor(Color::RED);
+    child.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    child.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+    child.SetProperty(Dali::Actor::Property::SIZE, Vector2(100, 100));
+    child.SetProperty(Dali::Actor::Property::POSITION, Vector2(25, 100));
+    parent.Add(child);
+
+    mPanel = Dali::Scene3D::Panel::New();
+    mPanel.SetProperty(Dali::Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.5f));
+    mPanel.SetProperty(Dali::Actor::Property::SIZE, Vector2(2.0f, 1.0f));
+    mPanel.SetPanelResolution(Vector2(400, 500));
+    mPanel.SetContent(parent);
+    mPanel.SetProperty(Dali::Scene3D::Panel::Property::BACK_FACE_PLANE_COLOR, BackFaceColors[mColorIndex]);
+    sceneView.Add(mPanel);
+
+    SetGuide();
+
+    Animation animation = Animation::New(15.0f);
+    animation.AnimateTo(Dali::Property(mPanel, Dali::Actor::Property::ORIENTATION), Quaternion(Dali::Radian(M_PI), Vector3::YAXIS));
+    animation.AnimateTo(Dali::Property(mPanel, Dali::Actor::Property::SIZE), Vector3(1.0f, 2.0f, 0.0f));
+    animation.SetLooping(true);
+    animation.SetLoopingMode(Dali::Animation::LoopingMode::AUTO_REVERSE);
+    animation.Play();
+
+    // Respond to a touch anywhere on the window
+    window.GetRootLayer().TouchedSignal().Connect(this, &Scene3DPanelController::OnTouch);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &Scene3DPanelController::OnKeyEvent);
+  }
+
+  bool OnTouch(Actor actor, const TouchEvent& touch)
+  {
+    // quit the application
+    mApplication.Quit();
+    return true;
+  }
+
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(event.GetKeyName() == "1")
+      {
+        bool isTransparent = mPanel.GetProperty<bool>(Dali::Scene3D::Panel::Property::TRANSPARENT);
+        mPanel.SetProperty(Dali::Scene3D::Panel::Property::TRANSPARENT, !isTransparent);
+      }
+      else if(event.GetKeyName() == "2")
+      {
+        bool isDoubleSided = mPanel.GetProperty<bool>(Dali::Scene3D::Panel::Property::DOUBLE_SIDED);
+        mPanel.SetProperty(Dali::Scene3D::Panel::Property::DOUBLE_SIDED, !isDoubleSided);
+      }
+      else if(event.GetKeyName() == "3")
+      {
+        bool isUsingBackFacePlane = mPanel.GetProperty<bool>(Dali::Scene3D::Panel::Property::USE_BACK_FACE_PLANE);
+        mPanel.SetProperty(Dali::Scene3D::Panel::Property::USE_BACK_FACE_PLANE, !isUsingBackFacePlane);
+      }
+      else if(event.GetKeyName() == "4")
+      {
+        mColorIndex = ((mColorIndex + 1) % 3);
+        mPanel.SetProperty(Dali::Scene3D::Panel::Property::BACK_FACE_PLANE_COLOR, BackFaceColors[mColorIndex]);
+      }
+      SetGuide();
+    }
+  }
+
+  void SetGuide()
+  {
+    if(!mGuideText)
+    {
+      mGuideText = TextLabel::New();
+      mGuideText.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
+      mGuideText.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
+      mGuideText.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 30.0f);
+      mGuideText.SetProperty(Dali::Toolkit::TextLabel::Property::MULTI_LINE, true);
+    }
+    mApplication.GetWindow().Add(mGuideText);
+
+    std::string    isTransparent        = mPanel.GetProperty<bool>(Dali::Scene3D::Panel::Property::TRANSPARENT) ? "true" : "false";
+    std::string    isDoubleSided        = mPanel.GetProperty<bool>(Dali::Scene3D::Panel::Property::DOUBLE_SIDED) ? "true" : "false";
+    std::string    isUsingBackFacePlane = mPanel.GetProperty<bool>(Dali::Scene3D::Panel::Property::USE_BACK_FACE_PLANE) ? "true" : "false";
+    std::string    backFaceColor;
+    backFaceColor.append("(" + std::to_string(BackFaceColors[mColorIndex].r));
+    backFaceColor.append(", " + std::to_string(BackFaceColors[mColorIndex].g));
+    backFaceColor.append(", " + std::to_string(BackFaceColors[mColorIndex].b) + ")");
+
+    std::string guideText;
+    guideText += "Press 1 to convert transparency - Current value : " + isTransparent + "\n";
+    guideText += "Press 2 to convert double sided - Current value : " + isDoubleSided + "\n";
+    guideText += "Press 3 to convert back face - Current value : " + isUsingBackFacePlane + "\n";
+    guideText += "Press 4 to convert back face color - Current value : " + backFaceColor + "\n";
+    mGuideText.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT, guideText);
+  }
+
+private:
+  TextLabel            mGuideText;
+  uint32_t             mColorIndex{0};
+  Dali::Scene3D::Panel mPanel;
+  Application&         mApplication;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application          application = Application::New(&argc, &argv);
+  Scene3DPanelController test(application);
+  application.MainLoop();
+  return 0;
+}
index 695811e0028a40967b6ac73822e8f4bd4e6de47c..51364e8e74c165449a5a54e0d97bf6cd03499475 100755 (executable)
@@ -183,3 +183,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index 757554bf78b45e3133121179fd8e8ed3bf265612..293ac058a9ae21637de6d1a147f3d764730dc619 100755 (executable)
@@ -183,3 +183,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index 9b54219d41f1ed0fefd08e87164d9c53e75b96bf..e47ed79e6679c50c721df4af15460ebd4ce838f7 100755 (executable)
@@ -235,6 +235,9 @@ msgstr "Scene3D Light"
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
 
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
+
 msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
 msgstr "Script-based UI"
 
index 011807237abab026dd4de67446d84e10f0cece86..ae175b628b40d4edda9c9efe6dfe71091c91cf07 100755 (executable)
@@ -244,6 +244,9 @@ msgstr "Scene3D Light"
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
 
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
+
 msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
 msgstr "Script-based UI"
 
index 5534fa70890b9fcb80327e9f369bbc4a85db2d93..af195df0bcc6ba2e5af77052d0fbfce9ca36b2df 100755 (executable)
@@ -183,3 +183,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index 4d9a97c0076d39e8a9d014a759f4ffbbeac44a96..51dff5d10ec3c4d0f6bf84c3675ce8db7c51e715 100755 (executable)
@@ -183,3 +183,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
\ No newline at end of file
index ce45799137a5f7b47bf479f19838d4433f7a01fa..bdc0e30e23ea3d90cd17ceae18d33af7f0d2361c 100755 (executable)
@@ -201,5 +201,9 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES"
 msgstr "애니메이션 벡터 이미지"
+
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index 938bd7cb82ade91863a6c58ea4fd3fd3df12173f..54e9c1f25ff108e3fdcdb0c0675eb49f221d6551 100755 (executable)
@@ -183,3 +183,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index 2e27873099ecf3ba6c305a9b07b3bec63ff45a59..59cf30b1c36ed9d93795a5020769949873c3ced4 100755 (executable)
@@ -183,3 +183,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index fa9b933bb5497aadbf11c3237262ba7e958fa836..0888d1aa401258996100976541a44644a1b4fb8f 100755 (executable)
@@ -186,3 +186,6 @@ msgstr "PBR"
 
 msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
 msgstr "Scene3D Model"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_PANEL"
+msgstr "Scene3D Panel"
index f7ca9dd8626d2b2a66ebffc64f8761a59ba91d81..160ad0b06ce50cb77952e5a0928d2e01044ac0b3 100644 (file)
@@ -128,6 +128,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_SCENE3D dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D")
 #define DALI_DEMO_STR_TITLE_SCENE3D_LIGHT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_LIGHT")
 #define DALI_DEMO_STR_TITLE_SCENE3D_MODEL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_MODEL")
+#define DALI_DEMO_STR_TITLE_SCENE3D_PANEL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_PANEL")
 #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI")
 #define DALI_DEMO_STR_TITLE_SCROLL_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCROLL_VIEW")
 #define DALI_DEMO_STR_TITLE_SIMPLE_SCROLL_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SIMPLE_SCROLL_VIEW")
@@ -252,6 +253,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_SCENE3D "Scene3D"
 #define DALI_DEMO_STR_TITLE_SCENE3D_LIGHT "Scene3D Light"
 #define DALI_DEMO_STR_TITLE_SCENE3D_MODEL "Scene3D Model"
+#define DALI_DEMO_STR_TITLE_SCENE3D_PANEL "Scene3D Panel"
 #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI "Script Based UI"
 #define DALI_DEMO_STR_TITLE_SCROLL_VIEW "Scroll View"
 #define DALI_DEMO_STR_TITLE_SIMPLE_SCROLL_VIEW "Simple Scroll View"