Commit bff9106ed4c4033eac9251b3cd67f68d3c3a417a

Authored by seungho baek
1 parent 2c5b0f10

Sample for Scene3D Light

Change-Id: Id6bbcd469498923b39b37b1738376337d754dace
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
build/tizen/CMakeLists.txt
... ... @@ -156,6 +156,7 @@ INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} &quot;${LOCAL_IMAGES_TREE}&quot; &quot;*.webp&quot; ${IMAGES_
156 156 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.bmp" ${IMAGES_DIR})
157 157 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.wbmp" ${IMAGES_DIR})
158 158 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.ktx" ${IMAGES_DIR})
  159 +INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.ktx2" ${IMAGES_DIR})
159 160 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.astc" ${IMAGES_DIR})
160 161 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.svg" ${IMAGES_DIR})
161 162 INSTALL_TREE_FILES(${LOCAL_IMAGES_DIR} "${LOCAL_IMAGES_TREE}" "*.json" ${IMAGES_DIR})
... ...
com.samsung.dali-demo.xml
... ... @@ -286,12 +286,15 @@
286 286 <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">
287 287 <label>Rendering Triangle</label>
288 288 </ui-application>
289   - <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">
290   - <label>Model View</label>
291   - </ui-application>
292 289 <ui-application appid="scene3d.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene3d.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
293 290 <label>Scene3D</label>
294 291 </ui-application>
  292 + <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">
  293 + <label>Scene3D Light</label>
  294 + </ui-application>
  295 + <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">
  296 + <label>Scene3D Model</label>
  297 + </ui-application>
295 298 <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">
296 299 <label>Scroll View</label>
297 300 </ui-application>
... ...
examples-reel/dali-examples-reel.cpp
... ... @@ -91,6 +91,9 @@ int DALI_EXPORT_API main(int argc, char** argv)
91 91 demo.AddExample(Example("rendering-textured-cube.example", DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE));
92 92 demo.AddExample(Example("rendering-radial-progress.example", DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS));
93 93 demo.AddExample(Example("ray-marching.example", DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING));
  94 + demo.AddExample(Example("scene3d.example", DALI_DEMO_STR_TITLE_SCENE3D));
  95 + demo.AddExample(Example("scene3d-light.example", DALI_DEMO_STR_TITLE_SCENE3D_LIGHT));
  96 + demo.AddExample(Example("scene3d-model.example", DALI_DEMO_STR_TITLE_SCENE3D_MODEL));
94 97 demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
95 98 demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE));
96 99 demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING));
... ...
examples/scene3d-light/scene3d-light-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#include <dali-toolkit/dali-toolkit.h>
  19 +#include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
  20 +#include <dali-scene3d/public-api/controls/model/model.h>
  21 +#include <dali/devel-api/actors/actor-devel.h>
  22 +#include <dali-scene3d/public-api/light/light.h>
  23 +
  24 +#include <dali/integration-api/debug.h>
  25 +
  26 +using namespace Dali;
  27 +using Dali::Toolkit::TextLabel;
  28 +
  29 +const std::string imagedir = DEMO_IMAGE_DIR;
  30 +const std::string uri_diffuse_texture(imagedir + "papermill_E_diffuse-64.ktx");
  31 +const std::string uri_specular_texture(imagedir + "papermill_pmrem.ktx");
  32 +
  33 +// This example shows how to create and display Hello World! using a simple TextActor
  34 +//
  35 +class Scene3dLightController : public ConnectionTracker
  36 +{
  37 +public:
  38 + Scene3dLightController(Application& application)
  39 + : mApplication(application)
  40 + {
  41 + // Connect to the Application's Init signal
  42 + mApplication.InitSignal().Connect(this, &Scene3dLightController::Create);
  43 + }
  44 +
  45 + ~Scene3dLightController() = default; // Nothing to do in destructor
  46 +
  47 + // The Init signal is received once (only) during the Application lifetime
  48 + void Create(Application& application)
  49 + {
  50 + // Get a handle to the window
  51 + Window window = application.GetWindow();
  52 + window.SetBackgroundColor(Color::WHITE);
  53 +
  54 + sceneView = Scene3D::SceneView::New();
  55 + sceneView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
  56 + sceneView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
  57 + sceneView.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
  58 + sceneView.SetProperty(Dali::Actor::Property::HEIGHT_RESIZE_POLICY, ResizePolicy::FILL_TO_PARENT);
  59 + sceneView.SetBackgroundColor(Color::BEIGE);
  60 + sceneView.SetProperty(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE, 0.5f);
  61 + sceneView.SetProperty(Dali::CameraActor::Property::FAR_PLANE_DISTANCE, 0.5f);
  62 +
  63 + light1 = Scene3D::Light::New();
  64 + light1.SetProperty(Dali::Actor::Property::COLOR, Color::BROWN);
  65 + light1.SetProperty(Dali::Actor::Property::POSITION, Vector3(-2.0f, -2.0f, 0.0f));
  66 + Dali::DevelActor::LookAt(light1, Vector3(0.0f, 0.0f, 0.0f));
  67 + Dali::Animation animation = Dali::Animation::New(3);
  68 + Dali::KeyFrames keyFrames = Dali::KeyFrames::New();
  69 + keyFrames.Add(0.0f, Quaternion(Radian(Degree(0.0f)), Vector3::YAXIS));
  70 + keyFrames.Add(0.25f, Quaternion(Radian(Degree(90.0f)), Vector3::YAXIS));
  71 + keyFrames.Add(0.5f, Quaternion(Radian(Degree(180.0f)), Vector3::YAXIS));
  72 + keyFrames.Add(0.75f, Quaternion(Radian(Degree(270.0f)), Vector3::YAXIS));
  73 + keyFrames.Add(1.0f, Quaternion(Radian(Degree(0.0f)), Vector3::YAXIS));
  74 +
  75 + Actor dummyActor = Actor::New();
  76 + dummyActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
  77 + dummyActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
  78 + dummyActor.Add(light1);
  79 + sceneView.Add(dummyActor);
  80 +
  81 + animation.AnimateBetween(Dali::Property(dummyActor, Dali::Actor::Property::ORIENTATION), keyFrames);
  82 + animation.Play();
  83 + animation.SetLooping(true);
  84 +
  85 + light2 = Scene3D::Light::New();
  86 + light2.SetProperty(Dali::Actor::Property::COLOR, Color::BLUE);
  87 + Dali::DevelActor::LookAt(light2, Vector3(1.0f, 1.0f, -1.0f));
  88 + sceneView.Add(light2);
  89 +
  90 + light3 = Scene3D::Light::New();
  91 + light3.SetProperty(Dali::Actor::Property::COLOR, Color::WHITE * 0.4);
  92 + light3.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, 0.0f, 1.1f));
  93 + Dali::DevelActor::LookAt(light3, Vector3(0.0, 0.0, 0.0f));
  94 + sceneView.Add(light3);
  95 +
  96 + light4 = Scene3D::Light::New();
  97 + light4.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
  98 + light4.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, -1.0f, 1.1f));
  99 + Dali::DevelActor::LookAt(light4, Vector3(0.0, 0.0, 0.0f));
  100 + sceneView.Add(light4);
  101 +
  102 + light5 = Scene3D::Light::New();
  103 + light5.SetProperty(Dali::Actor::Property::COLOR, Color::GREEN);
  104 + light5.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, 1.0f, 1.1f));
  105 + Dali::DevelActor::LookAt(light5, Vector3(0.0, 0.0, 0.0f));
  106 + sceneView.Add(light5);
  107 +
  108 + light6 = Scene3D::Light::New();
  109 + light6.SetProperty(Dali::Actor::Property::COLOR, Color::CYAN);
  110 + light6.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, -1.2f, 1.1f));
  111 + Dali::DevelActor::LookAt(light6, Vector3(0.0, 0.0, 0.0f));
  112 + sceneView.Add(light6);
  113 +
  114 + CameraActor camera = sceneView.GetSelectedCamera();
  115 + camera.SetProperty(Dali::Actor::Property::POSITION, Vector3(-1.0f, 0.0f, 1.1f));
  116 + Dali::DevelActor::LookAt(camera, Vector3(0.0, 0.0, 0.0f));
  117 +
  118 + Scene3D::Model model = Scene3D::Model::New(std::string(DEMO_MODEL_DIR) + "DamagedHelmet.gltf");
  119 + model.SetProperty(Dali::Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
  120 + model.SetProperty(Dali::Actor::Property::SIZE, Vector3::ONE);
  121 + sceneView.Add(model);
  122 +
  123 + window.Add(sceneView);
  124 +
  125 + // Respond to a touch anywhere on the window
  126 + window.GetRootLayer().TouchedSignal().Connect(this, &Scene3dLightController::OnTouch);
  127 +
  128 + // Respond to key events
  129 + window.KeyEventSignal().Connect(this, &Scene3dLightController::OnKeyEvent);
  130 + }
  131 +
  132 + bool OnTouch(Actor actor, const TouchEvent& touch)
  133 + {
  134 + const PointState::Type state = touch.GetState(0);
  135 +
  136 + switch(state)
  137 + {
  138 + default:
  139 + {
  140 + break;
  141 + }
  142 + }
  143 + return true;
  144 + }
  145 +
  146 + void OnKeyEvent(const KeyEvent& event)
  147 + {
  148 + if(event.GetState() == KeyEvent::DOWN)
  149 + {
  150 + if(event.GetKeyName() == "0")
  151 + {
  152 + sceneView.SetImageBasedLightSource("", "", 1.0f);
  153 + light1.Enable(true);
  154 + light2.Enable(true);
  155 + light6.Enable(false); // to reset state of lights
  156 + light6.Enable(true);
  157 + light3.Enable(true);
  158 + }
  159 + if(event.GetKeyName() == "1")
  160 + {
  161 + sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
  162 + light1.Enable(false);
  163 + light2.Enable(false);
  164 + }
  165 + else if(event.GetKeyName() == "2")
  166 + {
  167 + sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
  168 + light1.Enable(true);
  169 + light2.Enable(true);
  170 + }
  171 + else if(event.GetKeyName() == "3")
  172 + {
  173 + sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.3f);
  174 + light1.Enable(true);
  175 + light2.Enable(true);
  176 + }
  177 + else if(event.GetKeyName() == "4")
  178 + {
  179 + sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.1f);
  180 + light1.Enable(true);
  181 + light2.Enable(true);
  182 + }
  183 + else if(event.GetKeyName() == "5")
  184 + {
  185 + sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.0f);
  186 + light1.Enable(true);
  187 + }
  188 + else if(event.GetKeyName() == "6")
  189 + {
  190 + sceneView.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.0f);
  191 + light1.Enable(false);
  192 + }
  193 + }
  194 + }
  195 +
  196 +private:
  197 + Application& mApplication;
  198 + Scene3D::Light light1;
  199 + Scene3D::Light light2;
  200 + Scene3D::Light light3;
  201 + Scene3D::Light light4;
  202 + Scene3D::Light light5;
  203 + Scene3D::Light light6;
  204 + Scene3D::SceneView sceneView;
  205 +};
  206 +
  207 +int DALI_EXPORT_API main(int argc, char** argv)
  208 +{
  209 + Application application = Application::New(&argc, &argv);
  210 + Scene3dLightController test(application);
  211 + application.MainLoop();
  212 + return 0;
  213 +}
... ...
resources/po/en_GB.po
... ... @@ -214,6 +214,12 @@ msgstr &quot;Renderer Stencil&quot;
214 214 msgid "DALI_DEMO_STR_TITLE_SCENE3D"
215 215 msgstr "Scene3D"
216 216  
  217 +msgid "DALI_DEMO_STR_TITLE_SCENE3D_LIGHT"
  218 +msgstr "Scene3D Light"
  219 +
  220 +msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
  221 +msgstr "Scene3D Model"
  222 +
217 223 msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
218 224 msgstr "Script-based UI"
219 225  
... ... @@ -318,5 +324,3 @@ msgstr &quot;Web View&quot;
318 324  
319 325 msgid "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES"
320 326 msgstr "Animated Vector Images"
321   -msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
322   -msgstr "Scene3D Model"
... ...
resources/po/en_US.po
... ... @@ -223,6 +223,12 @@ msgstr &quot;Renderer Stencil&quot;
223 223 msgid "DALI_DEMO_STR_TITLE_SCENE3D"
224 224 msgstr "Scene3D"
225 225  
  226 +msgid "DALI_DEMO_STR_TITLE_SCENE3D_LIGHT"
  227 +msgstr "Scene3D Light"
  228 +
  229 +msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
  230 +msgstr "Scene3D Model"
  231 +
226 232 msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
227 233 msgstr "Script-based UI"
228 234  
... ... @@ -336,5 +342,3 @@ msgstr &quot;Text Bitmap Font&quot;
336 342  
337 343 msgid "DALI_DEMO_STR_TITLE_WAVES"
338 344 msgstr "Waves"
339   -msgid "DALI_DEMO_STR_TITLE_SCENE3D_MODEL"
340   -msgstr "Scene3D Model"
... ...
shared/dali-demo-strings.h
... ... @@ -119,8 +119,9 @@ extern &quot;C&quot;
119 119 #define DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS")
120 120 #define DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING")
121 121 #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERER_STENCIL")
122   -#define DALI_DEMO_STR_TITLE_SCENE3D_MODEL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_MODEL")
123 122 #define DALI_DEMO_STR_TITLE_SCENE3D dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D")
  123 +#define DALI_DEMO_STR_TITLE_SCENE3D_LIGHT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_LIGHT")
  124 +#define DALI_DEMO_STR_TITLE_SCENE3D_MODEL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_MODEL")
124 125 #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI")
125 126 #define DALI_DEMO_STR_TITLE_SCROLL_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCROLL_VIEW")
126 127 #define DALI_DEMO_STR_TITLE_SIMPLE_SCROLL_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SIMPLE_SCROLL_VIEW")
... ... @@ -235,8 +236,9 @@ extern &quot;C&quot;
235 236 #define DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING "Ray Marching"
236 237 #define DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS "Radial Progress"
237 238 #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL "Renderer Stencils"
238   -#define DALI_DEMO_STR_TITLE_SCENE3D_MODEL "Scene3D Model"
239 239 #define DALI_DEMO_STR_TITLE_SCENE3D "Scene3D"
  240 +#define DALI_DEMO_STR_TITLE_SCENE3D_LIGHT "Scene3D Light"
  241 +#define DALI_DEMO_STR_TITLE_SCENE3D_MODEL "Scene3D Model"
240 242 #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI "Script Based UI"
241 243 #define DALI_DEMO_STR_TITLE_SCROLL_VIEW "Scroll View"
242 244 #define DALI_DEMO_STR_TITLE_SIMPLE_SCROLL_VIEW "Simple Scroll View"
... ...