[Tizen] Sample for Scene3D Light 09/296909/3
authorseungho baek <sbsh.baek@samsung.com>
Fri, 26 May 2023 09:23:06 +0000 (18:23 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Wed, 23 Aug 2023 04:52:20 +0000 (13:52 +0900)
Change-Id: Id6bbcd469498923b39b37b1738376337d754dace
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
build/tizen/CMakeLists.txt
com.samsung.dali-demo.xml
examples-reel/dali-examples-reel.cpp
examples/scene3d-light/scene3d-light-example.cpp [new file with mode: 0644]
resources/po/en_GB.po
resources/po/en_US.po
shared/dali-demo-strings.h

index 5198d34..c836f43 100644 (file)
@@ -152,6 +152,7 @@ INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.bmp" ${IMAGES_D
 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.ico" ${IMAGES_DIR})
 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.wbmp" ${IMAGES_DIR})
 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.ktx" ${IMAGES_DIR})
+INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.ktx2" ${IMAGES_DIR})
 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.astc" ${IMAGES_DIR})
 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.svg" ${IMAGES_DIR})
 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.json" ${IMAGES_DIR})
index 40c24ea..5ee77ec 100644 (file)
        <ui-application appid="rendering-triangle.example" exec="/usr/apps/com.samsung.dali-demo/bin/rendering-triangle.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Rendering Triangle</label>
        </ui-application>
-       <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>Model View</label>
-       </ui-application>
        <ui-application appid="scene3d.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene3d.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Scene3D</label>
        </ui-application>
+       <ui-application appid="scene3d-light.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene3d-light.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>Scene3D Light</label>
+       </ui-application>
+       <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="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 17fc2d7..54f4e9f 100644 (file)
@@ -89,6 +89,9 @@ int DALI_EXPORT_API main(int argc, char** argv)
   demo.AddExample(Example("rendering-textured-cube.example", DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE));
   demo.AddExample(Example("rendering-radial-progress.example", DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS));
   demo.AddExample(Example("ray-marching.example", DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING));
+  demo.AddExample(Example("scene3d.example", DALI_DEMO_STR_TITLE_SCENE3D));
+  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("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-light/scene3d-light-example.cpp b/examples/scene3d-light/scene3d-light-example.cpp
new file mode 100644 (file)
index 0000000..e38d146
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2020 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/public-api/controls/scene-view/scene-view.h>
+#include <dali-scene3d/public-api/controls/model/model.h>
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali-scene3d/public-api/light/light.h>
+
+#include <dali/integration-api/debug.h>
+
+using namespace Dali;
+using Dali::Toolkit::TextLabel;
+
+const std::string imagedir = DEMO_IMAGE_DIR;
+const std::string uri_diffuse_texture(imagedir + "papermill_E_diffuse-64.ktx");
+const std::string uri_specular_texture(imagedir + "papermill_pmrem.ktx");
+
+// This example shows how to create and display Hello World! using a simple TextActor
+//
+class Scene3dLightController : public ConnectionTracker
+{
+public:
+  Scene3dLightController(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &Scene3dLightController::Create);
+  }
+
+  ~Scene3dLightController() = 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);
+
+    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::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
+    sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
+    sceneView.SetBackgroundColor(Color::BEIGE);
+    sceneView.SetProperty(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE, 0.5f);
+    sceneView.SetProperty(Dali::CameraActor::Property::FAR_PLANE_DISTANCE, 0.5f);
+
+    light1 = Scene3D::Light::New();
+    light1.SetProperty(Dali::Actor::Property::COLOR, Color::BROWN);
+    light1.SetProperty(Dali::Actor::Property::POSITION, Vector3(-2.0f, -2.0f, 0.0f));
+    Dali::DevelActor::LookAt(light1, Vector3(0.0f, 0.0f, 0.0f));
+    Dali::Animation animation = Dali::Animation::New(3);
+    Dali::KeyFrames keyFrames = Dali::KeyFrames::New();
+    keyFrames.Add(0.0f, Quaternion(Radian(Degree(0.0f)), Vector3::YAXIS));
+    keyFrames.Add(0.25f, Quaternion(Radian(Degree(90.0f)), Vector3::YAXIS));
+    keyFrames.Add(0.5f, Quaternion(Radian(Degree(180.0f)), Vector3::YAXIS));
+    keyFrames.Add(0.75f, Quaternion(Radian(Degree(270.0f)), Vector3::YAXIS));
+    keyFrames.Add(1.0f, Quaternion(Radian(Degree(0.0f)), Vector3::YAXIS));
+
+    Actor dummyActor = Actor::New();
+    dummyActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+    dummyActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    dummyActor.Add(light1);
+    sceneView.Add(dummyActor);
+
+    animation.AnimateBetween(Dali::Property(dummyActor, Dali::Actor::Property::ORIENTATION), keyFrames);
+    animation.Play();
+    animation.SetLooping(true);
+
+    light2 = Scene3D::Light::New();
+    light2.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
+    Dali::DevelActor::LookAt(light2, Vector3(1.0f, 1.0f, -1.0f));
+    sceneView.Add(light2);
+
+    light3 = Scene3D::Light::New();
+    light3.SetProperty(Dali::Actor::Property::COLOR, Color::WHITE * 0.4);
+    light3.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, 0.0f, 1.1f));
+    Dali::DevelActor::LookAt(light3, Vector3(0.0, 0.0, 0.0f));
+    sceneView.Add(light3);
+
+    light4 = Scene3D::Light::New();
+    light4.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
+    light4.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, -1.0f, 1.1f));
+    Dali::DevelActor::LookAt(light4, Vector3(0.0, 0.0, 0.0f));
+    sceneView.Add(light4);
+
+    light5 = Scene3D::Light::New();
+    light5.SetProperty(Dali::Actor::Property::COLOR, Color::GREEN);
+    light5.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, 1.0f, 1.1f));
+    Dali::DevelActor::LookAt(light5, Vector3(0.0, 0.0, 0.0f));
+    sceneView.Add(light5);
+
+    light6 = Scene3D::Light::New();
+    light6.SetProperty(Dali::Actor::Property::COLOR, Color::CYAN);
+    light6.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, -1.2f, 1.1f));
+    Dali::DevelActor::LookAt(light6, Vector3(0.0, 0.0, 0.0f));
+    sceneView.Add(light6);
+
+    CameraActor camera = sceneView.GetSelectedCamera();
+    camera.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, 0.0f, 1.1f));
+    Dali::DevelActor::LookAt(camera, Vector3(0.0, 0.0, 0.0f));
+
+    Scene3D::Model model = Scene3D::Model::New(std::string(DEMO_MODEL_DIR) + "DamagedHelmet.gltf");
+    model.SetProperty(Dali::Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
+    model.SetProperty(Dali::Actor::Property::SIZE, Vector3::ONE);
+    sceneView.Add(model);
+
+    window.Add(sceneView);
+
+    // Respond to a touch anywhere on the window
+    window.GetRootLayer().TouchedSignal().Connect(this, &Scene3dLightController::OnTouch);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &Scene3dLightController::OnKeyEvent);
+  }
+
+  bool OnTouch(Actor actor, const TouchEvent& touch)
+  {
+    const PointState::Type state = touch.GetState(0);
+
+    switch(state)
+    {
+      default:
+      {
+        break;
+      }
+    }
+    return true;
+  }
+
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(event.GetKeyName() == "0")
+      {
+        sceneView.SetImageBasedLightSource("", "", 1.0f);
+        light1.Enable(true);
+        light2.Enable(true);
+        light6.Enable(false);  // to reset state of lights
+        light6.Enable(true);
+        light3.Enable(true);
+      }
+      if(event.GetKeyName() == "1")
+      {
+        sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
+        light1.Enable(false);
+        light2.Enable(false);
+      }
+      else if(event.GetKeyName() == "2")
+      {
+        sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
+        light1.Enable(true);
+        light2.Enable(true);
+      }
+      else if(event.GetKeyName() == "3")
+      {
+        sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.3f);
+        light1.Enable(true);
+        light2.Enable(true);
+      }
+      else if(event.GetKeyName() == "4")
+      {
+        sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.1f);
+        light1.Enable(true);
+        light2.Enable(true);
+      }
+      else if(event.GetKeyName() == "5")
+      {
+        sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.0f);
+        light1.Enable(true);
+      }
+      else if(event.GetKeyName() == "6")
+      {
+        sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.0f);
+        light1.Enable(false);
+      }
+    }
+  }
+
+private:
+  Application& mApplication;
+  Scene3D::Light light1;
+  Scene3D::Light light2;
+  Scene3D::Light light3;
+  Scene3D::Light light4;
+  Scene3D::Light light5;
+  Scene3D::Light light6;
+  Scene3D::SceneView sceneView;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application          application = Application::New(&argc, &argv);
+  Scene3dLightController test(application);
+  application.MainLoop();
+  return 0;
+}
index 94aed08..a46f366 100755 (executable)
@@ -208,6 +208,12 @@ msgstr "Renderer Stencil"
 msgid "DALI_DEMO_STR_TITLE_SCENE3D"
 msgstr "Scene3D"
 
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_LIGHT"
+msgstr "Scene3D Light"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
+msgstr "Scene3D Model"
+
 msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
 msgstr "Script-based UI"
 
@@ -309,5 +315,3 @@ msgstr "Web View"
 
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES"
 msgstr "Animated Vector Images"
-msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
-msgstr "Scene3D Model"
index ab66673..5df7870 100755 (executable)
@@ -214,6 +214,12 @@ msgstr "Renderer Stencil"
 msgid "DALI_DEMO_STR_TITLE_SCENE3D"
 msgstr "Scene3D"
 
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_LIGHT"
+msgstr "Scene3D Light"
+
+msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
+msgstr "Scene3D Model"
+
 msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
 msgstr "Script-based UI"
 
@@ -324,5 +330,3 @@ msgstr "Text Bitmap Font"
 
 msgid "DALI_DEMO_STR_TITLE_WAVES"
 msgstr "Waves"
-msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
-msgstr "Scene3D Model"
index 3552ed3..a5f6734 100644 (file)
@@ -115,8 +115,9 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS")
 #define DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING")
 #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERER_STENCIL")
-#define DALI_DEMO_STR_TITLE_SCENE3D_MODEL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_MODEL")
 #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_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")
@@ -227,8 +228,9 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING "Ray Marching"
 #define DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS "Radial Progress"
 #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL "Renderer Stencils"
-#define DALI_DEMO_STR_TITLE_SCENE3D_MODEL "Scene3D Model"
 #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_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"