SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
ENDFOREACH(flag)
- pkg_check_modules(DALI_SCENE_LOADER dali2-scene-loader)
- IF( DALI_SCENE_LOADER_FOUND )
- FOREACH(flag ${DALI_SCENE_LOADER_CFLAGS})
+ pkg_check_modules(DALI_SCENE3D dali2-scene3d)
+ IF( DALI_SCENE3D_FOUND )
+ FOREACH(flag ${DALI_SCENE3D_CFLAGS})
SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
ENDFOREACH(flag)
- SET( REQUIRED_CFLAGS "${REQUIRED_CFLAGS} -DDALI_SCENE_LOADER_AVAILABLE" )
+ SET( REQUIRED_CFLAGS "${REQUIRED_CFLAGS} -DDALI_SCENE3D_AVAILABLE" )
- FOREACH(flag ${DALI_SCENE_LOADER_LDFLAGS})
+ FOREACH(flag ${DALI_SCENE3D_LDFLAGS})
SET(REQUIRED_PKGS_LDFLAGS "${REQUIRED_PKGS_LDFLAGS} ${flag}")
ENDFOREACH(flag)
- SET( ENABLE_SCENE_LOADER "ON" )
+ SET( ENABLE_SCENE3D "ON" )
ENDIF()
# if build as tizen platform, use capi-appfw-app-control
FIND_PACKAGE( dali2-adaptor REQUIRED )
FIND_PACKAGE( dali2-toolkit REQUIRED )
- FIND_PACKAGE( dali2-scene-loader )
+ FIND_PACKAGE( dali2-scene3d )
# Set up the include dir
SET( INCLUDE_DIR $ENV{includedir} )
)
ENDIF()
- IF (dali2-scene-loader_FOUND)
+ IF (dali2-scene3d_FOUND)
SET(REQUIRED_LIBS
${REQUIRED_LIBS}
- dali2-scene-loader::dali2-scene-loader
+ dali2-scene3d::dali2-scene3d
)
- SET( ENABLE_SCENE_LOADER "ON" )
+ SET( ENABLE_SCENE3D "ON" )
ENDIF()
ELSEIF( UNIX )
SET( REQUIRED_LIBS
SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DTRACE_ENABLED")
ENDIF()
-IF( ENABLE_SCENE_LOADER )
- SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DDALI_SCENE_LOADER_AVAILABLE")
+IF( ENABLE_SCENE3D )
+ SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DDALI_SCENE3D_AVAILABLE")
ENDIF()
IF( UNIX )
MESSAGE( " Folder DEMO_EXAMPLE_BIN : [" ${DEMO_EXAMPLE_BIN} "]" )
MESSAGE( " Folder DEMO_LANG : [" ${DEMO_LANG} "]" )
MESSAGE( " Current Build Platform : [" ${CURRENT_BUILD_PLATFORM} "]" )
-MESSAGE( " Scene Loader Enabled : [" ${ENABLE_SCENE_LOADER} "]" )
+MESSAGE( " Scene3D Enabled : [" ${ENABLE_SCENE3D} "]" )
ENDMACRO()
SUBDIRLIST(SUBDIRS ${EXAMPLES_SRC_DIR})
-SET(SCENE_LOADER_DIR "scene-loader")
-IF (NOT "${ENABLE_SCENE_LOADER}" )
- IF ( ${SCENE_LOADER_DIR} IN_LIST SUBDIRS )
- LIST( REMOVE_ITEM SUBDIRS ${SCENE_LOADER_DIR} )
+SET(SCENE3D_DIR "scene3d")
+IF (NOT "${ENABLE_SCENE3D}" )
+ IF ( ${SCENE3D_DIR} IN_LIST SUBDIRS )
+ LIST( REMOVE_ITEM SUBDIRS ${SCENE3D_DIR} )
ENDIF()
ENDIF()
<ui-application appid="scene3d-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene3d-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
<label>Scene3d View</label>
</ui-application>
- <ui-application appid="scene-loader.example" exec="/usr/apps/com.samsung.dali-demo/bin/scene-loader.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
- <label>Scene Loader</label>
+ <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="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>
demo.AddExample(Example("rendering-skybox.example", DALI_DEMO_STR_TITLE_SKYBOX));
demo.AddExample(Example("rendering-basic-pbr.example", DALI_DEMO_STR_TITLE_PBR));
demo.AddExample(Example("scene3d-view.example", DALI_DEMO_STR_TITLE_SCENE3D_VIEW));
-#ifdef DALI_SCENE_LOADER_AVAILABLE
- demo.AddExample(Example("scene-loader.example", DALI_DEMO_STR_TITLE_SCENE_LOADER));
-#endif //DALI_SCENE_LOADER_AVAILABLE
+#ifdef DALI_SCENE3D_AVAILABLE
+ demo.AddExample(Example("scene3d.example", DALI_DEMO_STR_TITLE_SCENE3D));
+#endif //DALI_SCENE3D_AVAILABLE
demo.AddExample(Example("shadows-and-lights.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS));
demo.AddExample(Example("sparkle.example", DALI_DEMO_STR_TITLE_SPARKLE));
demo.AddExample(Example("waves.example", DALI_DEMO_STR_TITLE_WAVES));
+++ /dev/null
-/*\r
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-#include "scene-loader-example.h"\r
-\r
-#include "dali/dali.h"\r
-\r
-using namespace Dali;\r
-\r
-int DALI_EXPORT_API main(int argc, char** argv)\r
-{\r
- auto app = Application::New(&argc, &argv, DEMO_THEME_PATH);\r
- SceneLoaderExample sceneLoader(app);\r
- app.MainLoop();\r
- return 0;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-#include "scene-loader-example.h"\r
-#include <dali-toolkit/dali-toolkit.h>\r
-#include <dirent.h>\r
-#include <cstring>\r
-#include <string_view>\r
-#include "dali-scene-loader/public-api/dli-loader.h"\r
-#include "dali-scene-loader/public-api/gltf2-loader.h"\r
-#include "dali-scene-loader/public-api/light-parameters.h"\r
-#include "dali-scene-loader/public-api/load-result.h"\r
-#include "dali-scene-loader/public-api/shader-definition-factory.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
-#include "dali-toolkit/public-api/controls/text-controls/text-label.h"\r
-#include "dali-toolkit/public-api/visuals/gradient-visual-properties.h"\r
-#include "dali/public-api/actors/layer.h"\r
-#include "dali/public-api/adaptor-framework/key.h"\r
-#include "dali/public-api/events/key-event.h"\r
-#include "dali/public-api/object/property-array.h"\r
-#include "dali/public-api/render-tasks/render-task-list.h"\r
-#include "scene-loader-extension.h"\r
-\r
-using namespace Dali;\r
-using namespace Dali::Toolkit;\r
-using namespace Dali::SceneLoader;\r
-\r
-namespace\r
-{\r
-const float ROTATION_SCALE = 180.f; // the amount of rotation that a swipe whose length is the width of the screen, causes, in degrees.\r
-\r
-const float ITEM_HEIGHT = 50.f;\r
-\r
-const Vector3 CAMERA_DEFAULT_POSITION(0.0f, 0.0f, 3.5f);\r
-\r
-const std::string_view DLI_EXTENSION = ".dli";\r
-const std::string_view GLTF_EXTENSION = ".gltf";\r
-\r
-const std::string RESOURCE_TYPE_DIRS[]{\r
- "images/",\r
- "shaders/",\r
- "models/",\r
- "images/",\r
-};\r
-\r
-using StringVector = std::vector<std::string>;\r
-\r
-StringVector ListFiles(\r
- const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; })\r
-{\r
- StringVector results;\r
-\r
- if(auto dirp = opendir(path.c_str()))\r
- {\r
- std::unique_ptr<DIR, int (*)(DIR*)> dir(dirp, closedir);\r
-\r
- struct dirent* ent;\r
- while((ent = readdir(dir.get())) != nullptr)\r
- {\r
- if(ent->d_type == DT_REG && predicate(ent->d_name))\r
- {\r
- results.push_back(ent->d_name);\r
- }\r
- }\r
- }\r
- return results;\r
-}\r
-\r
-TextLabel MakeLabel(std::string msg)\r
-{\r
- TextLabel label = TextLabel::New(" " + msg);\r
- label.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);\r
- label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::WHITE);\r
- label.SetProperty(TextLabel::Property::PIXEL_SIZE, ITEM_HEIGHT * 4 / 7);\r
- label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");\r
- SetActorCentered(label);\r
- return label;\r
-}\r
-\r
-struct ItemFactoryImpl : Dali::Toolkit::ItemFactory\r
-{\r
- const std::vector<std::string>& mSceneNames;\r
- TapGestureDetector mTapDetector;\r
-\r
- ItemFactoryImpl(const std::vector<std::string>& sceneNames, TapGestureDetector tapDetector)\r
- : mSceneNames(sceneNames),\r
- mTapDetector(tapDetector)\r
- {\r
- }\r
-\r
- unsigned int GetNumberOfItems() override\r
- {\r
- return mSceneNames.size();\r
- }\r
-\r
- Actor NewItem(unsigned int itemId) override\r
- {\r
- auto label = MakeLabel(mSceneNames[itemId]);\r
- mTapDetector.Attach(label);\r
- label.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
- return label;\r
- }\r
-};\r
-\r
-Actor CreateErrorMessage(std::string msg)\r
-{\r
- auto label = MakeLabel(msg);\r
- label.SetProperty(TextLabel::Property::MULTI_LINE, true);\r
- label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::LEFT);\r
- label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, VerticalAlignment::TOP);\r
- return label;\r
-}\r
-\r
-void ConfigureCamera(const CameraParameters& params, CameraActor camera)\r
-{\r
- if(params.isPerspective)\r
- {\r
- camera.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION);\r
- camera.SetNearClippingPlane(params.zNear);\r
- camera.SetFarClippingPlane(params.zFar);\r
- camera.SetFieldOfView(Radian(Degree(params.yFov)));\r
- }\r
- else\r
- {\r
- camera.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION);\r
- camera.SetOrthographicProjection(params.orthographicSize.x,\r
- params.orthographicSize.y,\r
- params.orthographicSize.z,\r
- params.orthographicSize.w,\r
- params.zNear,\r
- params.zFar);\r
- }\r
-\r
- // model\r
- Vector3 camTranslation;\r
- Vector3 camScale;\r
- Quaternion camOrientation;\r
- params.CalculateTransformComponents(camTranslation, camOrientation, camScale);\r
-\r
- SetActorCentered(camera);\r
- camera.SetInvertYAxis(true);\r
- camera.SetProperty(Actor::Property::POSITION, camTranslation);\r
- camera.SetProperty(Actor::Property::ORIENTATION, camOrientation);\r
- camera.SetProperty(Actor::Property::SCALE, camScale);\r
-\r
- camOrientation.Conjugate();\r
-}\r
-\r
-void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests)\r
-{\r
- std::vector<std::string> errors;\r
- auto onError = [&errors](const std::string& msg) {\r
- errors.push_back(msg);\r
- };\r
- if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError))\r
- {\r
- ExceptionFlinger flinger(ASSERT_LOCATION);\r
- for(auto& msg : errors)\r
- {\r
- flinger << msg << '\n';\r
- }\r
- }\r
-}\r
-\r
-Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<AnimationDefinition>* animations, Animation& animation)\r
-{\r
- ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) {\r
- return Application::GetResourcePath() + RESOURCE_TYPE_DIRS[type];\r
- };\r
-\r
- auto path = pathProvider(ResourceType::Mesh) + sceneName;\r
-\r
- ResourceBundle resources;\r
- SceneDefinition scene;\r
- std::vector<AnimationGroupDefinition> animGroups;\r
- std::vector<CameraParameters> cameraParameters;\r
- std::vector<LightParameters> lights;\r
-\r
- animations->clear();\r
-\r
- LoadResult output{\r
- resources,\r
- scene,\r
- *animations,\r
- animGroups,\r
- cameraParameters,\r
- lights};\r
-\r
- if(sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size())\r
- {\r
- DliLoader loader;\r
- DliLoader::InputParams input{\r
- pathProvider(ResourceType::Mesh),\r
- nullptr,\r
- {},\r
- {},\r
- nullptr,\r
- {}};\r
- DliLoader::LoadParams loadParams{input, output};\r
- if(!loader.LoadScene(path, loadParams))\r
- {\r
- ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << path << "': " << loader.GetParseError();\r
- }\r
- }\r
- else\r
- {\r
- ShaderDefinitionFactory sdf;\r
- sdf.SetResources(resources);\r
- LoadGltfScene(path, sdf, output);\r
-\r
- resources.mEnvironmentMaps.push_back({});\r
- }\r
-\r
- if(cameraParameters.empty())\r
- {\r
- cameraParameters.push_back(CameraParameters());\r
- cameraParameters[0].matrix.SetTranslation(CAMERA_DEFAULT_POSITION);\r
- }\r
- ConfigureCamera(cameraParameters[0], camera);\r
-\r
- ViewProjection viewProjection = cameraParameters[0].GetViewProjection();\r
- Transforms xforms{\r
- MatrixStack{},\r
- viewProjection};\r
- NodeDefinition::CreateParams nodeParams{\r
- resources,\r
- xforms,\r
- {},\r
- {},\r
- {}};\r
- Customization::Choices choices;\r
-\r
- Actor root = Actor::New();\r
- SetActorCentered(root);\r
-\r
- for(auto iRoot : scene.GetRoots())\r
- {\r
- auto resourceRefs = resources.CreateRefCounter();\r
- scene.CountResourceRefs(iRoot, choices, resourceRefs);\r
- resources.CountEnvironmentReferences(resourceRefs);\r
-\r
- resources.LoadResources(resourceRefs, pathProvider);\r
-\r
- if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))\r
- {\r
- scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);\r
- scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));\r
- ConfigureBlendShapeShaders(resources, scene, actor, std::move(nodeParams.mBlendshapeRequests));\r
-\r
- scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));\r
-\r
- root.Add(actor);\r
- }\r
- }\r
-\r
- if(!animations->empty())\r
- {\r
- auto getActor = [&root](const std::string& name) {\r
- return root.FindChildByName(name);\r
- };\r
-\r
- animation = (*animations)[0].ReAnimate(getActor);\r
- animation.Play();\r
- }\r
-\r
- return root;\r
-}\r
-\r
-} // namespace\r
-\r
-SceneLoaderExample::SceneLoaderExample(Dali::Application& app)\r
-: mApp(app),\r
- mSceneLoaderExtension(new SceneLoaderExtension())\r
-{\r
- if(!std::getenv("DALI_APPLICATION_PACKAGE"))\r
- {\r
- if(auto desktopPrefix = std::getenv("DESKTOP_PREFIX"))\r
- {\r
- std::stringstream sstr;\r
- sstr << desktopPrefix << "/share/com.samsung.dali-demo/res/";\r
-\r
- auto daliApplicationPackage = sstr.str();\r
- setenv("DALI_APPLICATION_PACKAGE", daliApplicationPackage.c_str(), 0);\r
- }\r
- }\r
-\r
- app.InitSignal().Connect(this, &SceneLoaderExample::OnInit);\r
- app.TerminateSignal().Connect(this, &SceneLoaderExample::OnTerminate);\r
-}\r
-\r
-SceneLoaderExample::~SceneLoaderExample() = default;\r
-\r
-void SceneLoaderExample::OnInit(Application& app)\r
-{\r
- // get scenes\r
- auto resPath = Application::GetResourcePath();\r
- auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh];\r
- auto sceneNames = ListFiles(scenePath, [](const char* name) {\r
- auto len = strlen(name);\r
- return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) ||\r
- (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0);\r
- });\r
- mSceneNames = sceneNames;\r
-\r
- // create Dali objects\r
- auto window = app.GetWindow();\r
-\r
- // navigation view\r
- auto navigationView = NavigationView::New();\r
- navigationView.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);\r
- SetActorCentered(navigationView);\r
-\r
- // Set up the background gradient.\r
- Property::Array stopOffsets;\r
- stopOffsets.PushBack(0.0f);\r
- stopOffsets.PushBack(1.0f);\r
- Property::Array stopColors;\r
- stopColors.PushBack(Color::BLACK);\r
- stopColors.PushBack(Vector4(0.45f, 0.7f, 0.8f, 1.f)); // Medium bright, pastel blue\r
- const float percentageWindowHeight = window.GetSize().GetHeight() * 0.6f;\r
-\r
- navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND,\r
- Dali::Property::Map()\r
- .Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT)\r
- .Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets)\r
- .Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors)\r
- .Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight))\r
- .Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight))\r
- .Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE));\r
- window.Add(navigationView);\r
- mNavigationView = navigationView;\r
-\r
- // item view\r
- auto tapDetector = TapGestureDetector::New();\r
- mItemFactory.reset(new ::ItemFactoryImpl(mSceneNames, tapDetector));\r
-\r
- auto items = ItemView::New(*mItemFactory);\r
- SetActorCentered(items);\r
- items.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);\r
- items.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
-\r
- Vector3 windowSize(window.GetSize());\r
- auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST);\r
- itemLayout->SetItemSize(Vector3(windowSize.x * 0.9f, ITEM_HEIGHT, 1.f));\r
- items.AddLayout(*itemLayout);\r
- navigationView.Push(items);\r
-\r
- mItemLayout = itemLayout;\r
- mItemView = items;\r
-\r
- mItemView.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
- KeyboardFocusManager::Get().PreFocusChangeSignal().Connect(this, &SceneLoaderExample::OnKeyboardPreFocusChange);\r
- KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect(this, &SceneLoaderExample::OnKeyboardFocusedActorActivated);\r
- KeyboardFocusManager::Get().FocusChangedSignal().Connect(this, &SceneLoaderExample::OnKeyboardFocusChanged);\r
-\r
- SetActorCentered(KeyboardFocusManager::Get().GetFocusIndicatorActor());\r
-\r
- // camera\r
- auto camera = CameraActor::New();\r
- camera.SetInvertYAxis(true);\r
- window.Add(camera);\r
- mSceneCamera = camera;\r
-\r
- // event handling\r
- window.KeyEventSignal().Connect(this, &SceneLoaderExample::OnKey);\r
-\r
- tapDetector.DetectedSignal().Connect(this, &SceneLoaderExample::OnTap);\r
- mTapDetector = tapDetector;\r
-\r
- // activate layout\r
- mItemView.ActivateLayout(0, windowSize, 0.f);\r
-\r
- mSceneLoaderExtension->SetSceneLoader(this);\r
-}\r
-\r
-Actor SceneLoaderExample::OnKeyboardPreFocusChange(Actor current, Actor proposed, Control::KeyboardFocus::Direction direction)\r
-{\r
- if(!current && !proposed)\r
- {\r
- return mItemView;\r
- }\r
-\r
- return proposed;\r
-}\r
-\r
-void SceneLoaderExample::OnKeyboardFocusedActorActivated(Actor activatedActor)\r
-{\r
- if(activatedActor)\r
- {\r
- OnTap(activatedActor, Dali::TapGesture());\r
- }\r
-}\r
-\r
-void SceneLoaderExample::OnKeyboardFocusChanged(Actor originalFocusedActor, Actor currentFocusedActor)\r
-{\r
- if(currentFocusedActor)\r
- {\r
- auto itemId = mItemView.GetItemId(currentFocusedActor);\r
- mItemView.ScrollToItem(itemId, 0.1f);\r
- }\r
-}\r
-\r
-void SceneLoaderExample::OnTerminate(Application& app)\r
-{\r
- mTapDetector.Reset();\r
- mPanDetector.Reset();\r
-\r
- auto window = app.GetWindow();\r
- auto renderTasks = window.GetRenderTaskList();\r
- renderTasks.RemoveTask(mSceneRender);\r
- mSceneRender.Reset();\r
-\r
- UnparentAndReset(mNavigationView);\r
- UnparentAndReset(mSceneCamera);\r
-\r
- mItemFactory.reset();\r
-}\r
-\r
-void SceneLoaderExample::OnKey(const KeyEvent& e)\r
-{\r
- if(e.GetState() == KeyEvent::UP)\r
- {\r
- if(IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK))\r
- {\r
- if(mScene)\r
- {\r
- mPanDetector.Reset();\r
-\r
- mNavigationView.Pop();\r
- mScene.Reset();\r
-\r
- if(mActivatedActor)\r
- {\r
- KeyboardFocusManager::Get().SetCurrentFocusActor(mActivatedActor);\r
- }\r
- }\r
- else\r
- {\r
- mApp.Quit();\r
- }\r
- }\r
- else\r
- {\r
- mSceneLoaderExtension->OnKey(e);\r
- }\r
- }\r
-}\r
-\r
-void SceneLoaderExample::OnPan(Actor actor, const PanGesture& pan)\r
-{\r
- auto windowSize = mApp.GetWindow().GetSize();\r
- Vector2 size{float(windowSize.GetWidth()), float(windowSize.GetHeight())};\r
- float aspect = size.y / size.x;\r
-\r
- size /= ROTATION_SCALE;\r
-\r
- Vector2 rotation{pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect};\r
-\r
- Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f));\r
- Quaternion q0 = mScene.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();\r
-\r
- mScene.SetProperty(Actor::Property::ORIENTATION, q * q0);\r
-}\r
-\r
-void SceneLoaderExample::OnTap(Dali::Actor actor, const Dali::TapGesture& tap)\r
-{\r
- mActivatedActor = actor;\r
-\r
- auto id = mItemView.GetItemId(actor);\r
-\r
- try\r
- {\r
- auto window = mApp.GetWindow();\r
- auto renderTasks = window.GetRenderTaskList();\r
- renderTasks.RemoveTask(mSceneRender);\r
-\r
- auto scene = LoadScene(mSceneNames[id], mSceneCamera, &mSceneAnimations, mCurrentAnimation);\r
-\r
- auto sceneRender = renderTasks.CreateTask();\r
- sceneRender.SetCameraActor(mSceneCamera);\r
- sceneRender.SetSourceActor(scene);\r
- sceneRender.SetExclusive(true);\r
-\r
- mScene = scene;\r
- mSceneRender = sceneRender;\r
-\r
- mPanDetector = PanGestureDetector::New();\r
- mPanDetector.DetectedSignal().Connect(this, &SceneLoaderExample::OnPan);\r
- mPanDetector.Attach(mNavigationView);\r
- }\r
- catch(const DaliException& e)\r
- {\r
- mScene = CreateErrorMessage(e.condition);\r
- }\r
-\r
- mNavigationView.Push(mScene);\r
-\r
- mSceneLoaderExtension->ConnectTouchSignals();\r
-}\r
+++ /dev/null
-#ifndef SCENE_LAUNCHER_H_\r
-#define SCENE_LAUNCHER_H_\r
-/*\r
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <memory>\r
-#include "dali-scene-loader/public-api/animation-definition.h"\r
-#include "dali-scene-loader/public-api/camera-parameters.h"\r
-#include "dali-scene-loader/public-api/node-definition.h"\r
-#include "dali-scene-loader/public-api/scene-definition.h"\r
-#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h"\r
-#include "dali/public-api/actors/camera-actor.h"\r
-#include "dali/public-api/adaptor-framework/application.h"\r
-#include "dali/public-api/common/vector-wrapper.h"\r
-#include "dali/public-api/events/pan-gesture-detector.h"\r
-#include "dali/public-api/render-tasks/render-task.h"\r
-#include "dali/public-api/signals/connection-tracker.h"\r
-\r
-class SceneLoaderExtension;\r
-\r
-class SceneLoaderExample : public Dali::ConnectionTracker\r
-{\r
-public:\r
- SceneLoaderExample(Dali::Application& app);\r
- ~SceneLoaderExample();\r
-\r
-private: // data\r
- Dali::Application& mApp;\r
-\r
- std::vector<std::string> mSceneNames;\r
-\r
- Dali::Toolkit::NavigationView mNavigationView;\r
-\r
- std::unique_ptr<Dali::Toolkit::ItemFactory> mItemFactory;\r
- Dali::Toolkit::ItemLayoutPtr mItemLayout;\r
- Dali::Toolkit::ItemView mItemView;\r
-\r
- Dali::CameraActor mSceneCamera;\r
- Dali::RenderTask mSceneRender;\r
-\r
- Dali::Quaternion mCameraOrientationInv;\r
-\r
- Dali::TapGestureDetector mTapDetector;\r
- Dali::PanGestureDetector mPanDetector;\r
-\r
- Dali::Actor mActivatedActor;\r
-\r
-public:\r
- Dali::Actor mScene;\r
-\r
- std::vector<Dali::SceneLoader::AnimationDefinition> mSceneAnimations;\r
- Dali::Animation mCurrentAnimation;\r
-\r
- std::unique_ptr<SceneLoaderExtension> mSceneLoaderExtension;\r
-\r
-private: // methods\r
- void OnInit(Dali::Application& app);\r
- void OnTerminate(Dali::Application& app);\r
-\r
- void OnKey(const Dali::KeyEvent& e);\r
- void OnPan(Dali::Actor actor, const Dali::PanGesture& pan);\r
- void OnTap(Dali::Actor actor, const Dali::TapGesture& tap);\r
-\r
- Dali::Actor OnKeyboardPreFocusChange(Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction);\r
- void OnKeyboardFocusedActorActivated(Dali::Actor activatedActor);\r
- void OnKeyboardFocusChanged(Dali::Actor originalFocusedActor, Dali::Actor currentFocusedActor);\r
-};\r
-\r
-#endif //SCENE_LAUNCHER_H_\r
+++ /dev/null
-/*\r
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <dali-toolkit/dali-toolkit.h>\r
-#include <dali/dali.h>\r
-#include <cstring>\r
-\r
-class SceneLoaderExtension : public Dali::ConnectionTracker\r
-{\r
-public:\r
- SceneLoaderExtension()\r
- : mSceneLoader(nullptr),\r
- mCurrentAnimationIndex(ANIMATION_IDLE)\r
- {\r
- }\r
-\r
- ~SceneLoaderExtension() = default; // Nothing to do in destructor\r
-\r
- void SetSceneLoader(SceneLoaderExample* sceneLoader)\r
- {\r
- mSceneLoader = sceneLoader;\r
- }\r
-\r
- void ConnectTouchSignals()\r
- {\r
- // This is a temporary hack for now to manually connect these signals.\r
- // We should connect these signals automatically when loading the scene.\r
-\r
- if(mSceneLoader)\r
- {\r
- ConnectTouchSignal(ICON_IDLE);\r
- ConnectTouchSignal(ICON_SQUAT);\r
- ConnectTouchSignal(ICON_JUMPING_JACK);\r
- ConnectTouchSignal(ICON_LUNGE);\r
- }\r
- }\r
-\r
- void OnKey(const Dali::KeyEvent& e)\r
- {\r
- // This is a temporary hack for now to manually handle these key events.\r
- // We should links them to the animations automatically when loading the scene.\r
-\r
- switch(e.GetKeyCode())\r
- {\r
- case KEY_ONE:\r
- {\r
- PlaySceneAnimation(ANIMATION_IDLE);\r
- break;\r
- }\r
- case KEY_TWO:\r
- {\r
- PlaySceneAnimation(ANIMATION_IDLE_TO_SQUAT);\r
- break;\r
- }\r
- case KEY_THREE:\r
- {\r
- PlaySceneAnimation(ANIMATION_IDLE_TO_JUMPING_JACK);\r
- break;\r
- }\r
- case KEY_FOUR:\r
- {\r
- PlaySceneAnimation(ANIMATION_IDLE_TO_LUNGE);\r
- break;\r
- }\r
- default:\r
- break;\r
- }\r
- }\r
-\r
-private:\r
- bool PlaySceneAnimation(unsigned int animationIndex)\r
- {\r
- if(mSceneLoader && mSceneLoader->mScene)\r
- {\r
- if(mSceneLoader->mCurrentAnimation &&\r
- mCurrentAnimationIndex != ANIMATION_IDLE &&\r
- mSceneLoader->mCurrentAnimation.GetState() != Dali::Animation::STOPPED)\r
- {\r
- return false;\r
- }\r
-\r
- auto root = mSceneLoader->mScene;\r
- auto getActor = [&root](const std::string& name) {\r
- return root.FindChildByName(name);\r
- };\r
-\r
- if(mSceneLoader->mSceneAnimations.size() > animationIndex)\r
- {\r
- mCurrentAnimationIndex = animationIndex;\r
- mSceneLoader->mCurrentAnimation = mSceneLoader->mSceneAnimations[animationIndex].ReAnimate(getActor);\r
- mSceneLoader->mCurrentAnimation.FinishedSignal().Connect(this, &SceneLoaderExtension::OnAnimationFinished);\r
- mSceneLoader->mCurrentAnimation.Play();\r
- }\r
- }\r
-\r
- return true;\r
- }\r
-\r
- void ConnectTouchSignal(const std::string actorName)\r
- {\r
- if(mSceneLoader && mSceneLoader->mScene)\r
- {\r
- auto actor = mSceneLoader->mScene.FindChildByName(actorName);\r
- if(actor)\r
- {\r
- actor.TouchedSignal().Connect(this, &SceneLoaderExtension::OnTouch);\r
- }\r
- }\r
- }\r
-\r
- void OnAnimationFinished(Dali::Animation& source)\r
- {\r
- switch(mCurrentAnimationIndex)\r
- {\r
- case ANIMATION_IDLE_TO_SQUAT:\r
- {\r
- PlaySceneAnimation(ANIMATION_SQUAT_TO_IDLE);\r
- break;\r
- }\r
- case ANIMATION_IDLE_TO_JUMPING_JACK:\r
- {\r
- PlaySceneAnimation(ANIMATION_JUMPING_JACK);\r
- break;\r
- }\r
- case ANIMATION_JUMPING_JACK:\r
- {\r
- PlaySceneAnimation(ANIMATION_JUMPING_JACK_TO_IDLE);\r
- break;\r
- }\r
- case ANIMATION_IDLE_TO_LUNGE:\r
- {\r
- PlaySceneAnimation(ANIMATION_LUNGE);\r
- break;\r
- }\r
- case ANIMATION_LUNGE:\r
- {\r
- PlaySceneAnimation(ANIMATION_LUNGE_TO_IDLE);\r
- break;\r
- }\r
- default:\r
- {\r
- mCurrentAnimationIndex = ANIMATION_IDLE;\r
- break;\r
- }\r
- break;\r
- }\r
- }\r
-\r
- bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& touch)\r
- {\r
- bool processed = false;\r
-\r
- if(touch.GetPointCount() > 0)\r
- {\r
- if(touch.GetState(0) == Dali::PointState::DOWN)\r
- {\r
- auto actorName = actor.GetProperty<std::string>(Dali::Actor::Property::NAME);\r
-\r
- if(ICON_IDLE == actorName)\r
- {\r
- processed = PlaySceneAnimation(ANIMATION_IDLE);\r
- }\r
- else if(ICON_SQUAT == actorName)\r
- {\r
- processed = PlaySceneAnimation(ANIMATION_IDLE_TO_SQUAT);\r
- }\r
- else if(ICON_JUMPING_JACK == actorName)\r
- {\r
- processed = PlaySceneAnimation(ANIMATION_IDLE_TO_JUMPING_JACK);\r
- }\r
- else if(ICON_LUNGE == actorName)\r
- {\r
- processed = PlaySceneAnimation(ANIMATION_IDLE_TO_LUNGE);\r
- }\r
- }\r
- }\r
- return processed;\r
- }\r
-\r
-private:\r
- static constexpr unsigned int KEY_ONE = 10;\r
- static constexpr unsigned int KEY_TWO = 11;\r
- static constexpr unsigned int KEY_THREE = 12;\r
- static constexpr unsigned int KEY_FOUR = 13;\r
-\r
- // Idle animation\r
- static constexpr unsigned int ANIMATION_IDLE = 0;\r
- // Squat animation\r
- static constexpr unsigned int ANIMATION_IDLE_TO_SQUAT = 3;\r
- static constexpr unsigned int ANIMATION_SQUAT_TO_IDLE = 15;\r
- // JumpingJack animation\r
- static constexpr unsigned int ANIMATION_IDLE_TO_JUMPING_JACK = 1;\r
- static constexpr unsigned int ANIMATION_JUMPING_JACK = 5;\r
- static constexpr unsigned int ANIMATION_JUMPING_JACK_TO_IDLE = 6;\r
- // Lunge animation\r
- static constexpr unsigned int ANIMATION_IDLE_TO_LUNGE = 2;\r
- static constexpr unsigned int ANIMATION_LUNGE = 9;\r
- static constexpr unsigned int ANIMATION_LUNGE_TO_IDLE = 10;\r
-\r
- inline static const std::string ICON_IDLE = "Idle";\r
- inline static const std::string ICON_SQUAT = "Squat";\r
- inline static const std::string ICON_JUMPING_JACK = "JumpingJack";\r
- inline static const std::string ICON_LUNGE = "Lunge";\r
-\r
- SceneLoaderExample* mSceneLoader;\r
- unsigned int mCurrentAnimationIndex;\r
-};\r
--- /dev/null
+/*\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+#include "scene3d-example.h"\r
+\r
+#include "dali/dali.h"\r
+\r
+using namespace Dali;\r
+\r
+int DALI_EXPORT_API main(int argc, char** argv)\r
+{\r
+ auto app = Application::New(&argc, &argv, DEMO_THEME_PATH);\r
+ Scene3DExample scene3D(app);\r
+ app.MainLoop();\r
+ return 0;\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+#include "scene3d-example.h"\r
+#include <dali-toolkit/dali-toolkit.h>\r
+#include <dirent.h>\r
+#include <cstring>\r
+#include <string_view>\r
+#include "dali-scene3d/public-api/loader/dli-loader.h"\r
+#include "dali-scene3d/public-api/loader/gltf2-loader.h"\r
+#include "dali-scene3d/public-api/loader/light-parameters.h"\r
+#include "dali-scene3d/public-api/loader/load-result.h"\r
+#include "dali-scene3d/public-api/loader/shader-definition-factory.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
+#include "dali-toolkit/public-api/controls/text-controls/text-label.h"\r
+#include "dali-toolkit/public-api/visuals/gradient-visual-properties.h"\r
+#include "dali/public-api/actors/layer.h"\r
+#include "dali/public-api/adaptor-framework/key.h"\r
+#include "dali/public-api/events/key-event.h"\r
+#include "dali/public-api/object/property-array.h"\r
+#include "dali/public-api/render-tasks/render-task-list.h"\r
+#include "scene3d-extension.h"\r
+\r
+using namespace Dali;\r
+using namespace Dali::Toolkit;\r
+using namespace Dali::Scene3D::Loader;\r
+\r
+namespace\r
+{\r
+const float ROTATION_SCALE = 180.f; // the amount of rotation that a swipe whose length is the width of the screen, causes, in degrees.\r
+\r
+const float ITEM_HEIGHT = 50.f;\r
+\r
+const Vector3 CAMERA_DEFAULT_POSITION(0.0f, 0.0f, 3.5f);\r
+\r
+const std::string_view DLI_EXTENSION = ".dli";\r
+const std::string_view GLTF_EXTENSION = ".gltf";\r
+\r
+const std::string RESOURCE_TYPE_DIRS[]{\r
+ "images/",\r
+ "shaders/",\r
+ "models/",\r
+ "images/",\r
+};\r
+\r
+using StringVector = std::vector<std::string>;\r
+\r
+StringVector ListFiles(\r
+ const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; })\r
+{\r
+ StringVector results;\r
+\r
+ if(auto dirp = opendir(path.c_str()))\r
+ {\r
+ std::unique_ptr<DIR, int (*)(DIR*)> dir(dirp, closedir);\r
+\r
+ struct dirent* ent;\r
+ while((ent = readdir(dir.get())) != nullptr)\r
+ {\r
+ if(ent->d_type == DT_REG && predicate(ent->d_name))\r
+ {\r
+ results.push_back(ent->d_name);\r
+ }\r
+ }\r
+ }\r
+ return results;\r
+}\r
+\r
+TextLabel MakeLabel(std::string msg)\r
+{\r
+ TextLabel label = TextLabel::New(" " + msg);\r
+ label.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);\r
+ label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::WHITE);\r
+ label.SetProperty(TextLabel::Property::PIXEL_SIZE, ITEM_HEIGHT * 4 / 7);\r
+ label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");\r
+ SetActorCentered(label);\r
+ return label;\r
+}\r
+\r
+struct ItemFactoryImpl : Dali::Toolkit::ItemFactory\r
+{\r
+ const std::vector<std::string>& mSceneNames;\r
+ TapGestureDetector mTapDetector;\r
+\r
+ ItemFactoryImpl(const std::vector<std::string>& sceneNames, TapGestureDetector tapDetector)\r
+ : mSceneNames(sceneNames),\r
+ mTapDetector(tapDetector)\r
+ {\r
+ }\r
+\r
+ unsigned int GetNumberOfItems() override\r
+ {\r
+ return mSceneNames.size();\r
+ }\r
+\r
+ Actor NewItem(unsigned int itemId) override\r
+ {\r
+ auto label = MakeLabel(mSceneNames[itemId]);\r
+ mTapDetector.Attach(label);\r
+ label.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
+ return label;\r
+ }\r
+};\r
+\r
+Actor CreateErrorMessage(std::string msg)\r
+{\r
+ auto label = MakeLabel(msg);\r
+ label.SetProperty(TextLabel::Property::MULTI_LINE, true);\r
+ label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::LEFT);\r
+ label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, VerticalAlignment::TOP);\r
+ return label;\r
+}\r
+\r
+void ConfigureCamera(const CameraParameters& params, CameraActor camera)\r
+{\r
+ if(params.isPerspective)\r
+ {\r
+ camera.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION);\r
+ camera.SetNearClippingPlane(params.zNear);\r
+ camera.SetFarClippingPlane(params.zFar);\r
+ camera.SetFieldOfView(Radian(Degree(params.yFov)));\r
+ }\r
+ else\r
+ {\r
+ camera.SetProjectionMode(Camera::ORTHOGRAPHIC_PROJECTION);\r
+ camera.SetOrthographicProjection(params.orthographicSize.x,\r
+ params.orthographicSize.y,\r
+ params.orthographicSize.z,\r
+ params.orthographicSize.w,\r
+ params.zNear,\r
+ params.zFar);\r
+ }\r
+\r
+ // model\r
+ Vector3 camTranslation;\r
+ Vector3 camScale;\r
+ Quaternion camOrientation;\r
+ params.CalculateTransformComponents(camTranslation, camOrientation, camScale);\r
+\r
+ SetActorCentered(camera);\r
+ camera.SetInvertYAxis(true);\r
+ camera.SetProperty(Actor::Property::POSITION, camTranslation);\r
+ camera.SetProperty(Actor::Property::ORIENTATION, camOrientation);\r
+ camera.SetProperty(Actor::Property::SCALE, camScale);\r
+\r
+ camOrientation.Conjugate();\r
+}\r
+\r
+void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests)\r
+{\r
+ std::vector<std::string> errors;\r
+ auto onError = [&errors](const std::string& msg) {\r
+ errors.push_back(msg);\r
+ };\r
+ if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError))\r
+ {\r
+ ExceptionFlinger flinger(ASSERT_LOCATION);\r
+ for(auto& msg : errors)\r
+ {\r
+ flinger << msg << '\n';\r
+ }\r
+ }\r
+}\r
+\r
+Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<AnimationDefinition>* animations, Animation& animation)\r
+{\r
+ ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) {\r
+ return Application::GetResourcePath() + RESOURCE_TYPE_DIRS[type];\r
+ };\r
+\r
+ auto path = pathProvider(ResourceType::Mesh) + sceneName;\r
+\r
+ ResourceBundle resources;\r
+ SceneDefinition scene;\r
+ std::vector<AnimationGroupDefinition> animGroups;\r
+ std::vector<CameraParameters> cameraParameters;\r
+ std::vector<LightParameters> lights;\r
+\r
+ animations->clear();\r
+\r
+ LoadResult output{\r
+ resources,\r
+ scene,\r
+ *animations,\r
+ animGroups,\r
+ cameraParameters,\r
+ lights};\r
+\r
+ if(sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size())\r
+ {\r
+ DliLoader loader;\r
+ DliLoader::InputParams input{\r
+ pathProvider(ResourceType::Mesh),\r
+ nullptr,\r
+ {},\r
+ {},\r
+ nullptr,\r
+ {}};\r
+ DliLoader::LoadParams loadParams{input, output};\r
+ if(!loader.LoadScene(path, loadParams))\r
+ {\r
+ ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << path << "': " << loader.GetParseError();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ ShaderDefinitionFactory sdf;\r
+ sdf.SetResources(resources);\r
+ LoadGltfScene(path, sdf, output);\r
+\r
+ resources.mEnvironmentMaps.push_back({});\r
+ }\r
+\r
+ if(cameraParameters.empty())\r
+ {\r
+ cameraParameters.push_back(CameraParameters());\r
+ cameraParameters[0].matrix.SetTranslation(CAMERA_DEFAULT_POSITION);\r
+ }\r
+ ConfigureCamera(cameraParameters[0], camera);\r
+\r
+ ViewProjection viewProjection = cameraParameters[0].GetViewProjection();\r
+ Transforms xforms{\r
+ MatrixStack{},\r
+ viewProjection};\r
+ NodeDefinition::CreateParams nodeParams{\r
+ resources,\r
+ xforms,\r
+ {},\r
+ {},\r
+ {}};\r
+ Customization::Choices choices;\r
+\r
+ Actor root = Actor::New();\r
+ SetActorCentered(root);\r
+\r
+ for(auto iRoot : scene.GetRoots())\r
+ {\r
+ auto resourceRefs = resources.CreateRefCounter();\r
+ scene.CountResourceRefs(iRoot, choices, resourceRefs);\r
+ resources.CountEnvironmentReferences(resourceRefs);\r
+\r
+ resources.LoadResources(resourceRefs, pathProvider);\r
+\r
+ if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))\r
+ {\r
+ scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);\r
+ scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));\r
+ ConfigureBlendShapeShaders(resources, scene, actor, std::move(nodeParams.mBlendshapeRequests));\r
+\r
+ scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));\r
+\r
+ root.Add(actor);\r
+ }\r
+ }\r
+\r
+ if(!animations->empty())\r
+ {\r
+ auto getActor = [&root](const std::string& name) {\r
+ return root.FindChildByName(name);\r
+ };\r
+\r
+ animation = (*animations)[0].ReAnimate(getActor);\r
+ animation.Play();\r
+ }\r
+\r
+ return root;\r
+}\r
+\r
+} // namespace\r
+\r
+Scene3DExample::Scene3DExample(Dali::Application& app)\r
+: mApp(app),\r
+ mScene3DExtension(new Scene3DExtension())\r
+{\r
+ if(!std::getenv("DALI_APPLICATION_PACKAGE"))\r
+ {\r
+ if(auto desktopPrefix = std::getenv("DESKTOP_PREFIX"))\r
+ {\r
+ std::stringstream sstr;\r
+ sstr << desktopPrefix << "/share/com.samsung.dali-demo/res/";\r
+\r
+ auto daliApplicationPackage = sstr.str();\r
+ setenv("DALI_APPLICATION_PACKAGE", daliApplicationPackage.c_str(), 0);\r
+ }\r
+ }\r
+\r
+ app.InitSignal().Connect(this, &Scene3DExample::OnInit);\r
+ app.TerminateSignal().Connect(this, &Scene3DExample::OnTerminate);\r
+}\r
+\r
+Scene3DExample::~Scene3DExample() = default;\r
+\r
+void Scene3DExample::OnInit(Application& app)\r
+{\r
+ // get scenes\r
+ auto resPath = Application::GetResourcePath();\r
+ auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh];\r
+ auto sceneNames = ListFiles(scenePath, [](const char* name) {\r
+ auto len = strlen(name);\r
+ return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) ||\r
+ (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0);\r
+ });\r
+ mSceneNames = sceneNames;\r
+\r
+ // create Dali objects\r
+ auto window = app.GetWindow();\r
+\r
+ // navigation view\r
+ auto navigationView = NavigationView::New();\r
+ navigationView.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);\r
+ SetActorCentered(navigationView);\r
+\r
+ // Set up the background gradient.\r
+ Property::Array stopOffsets;\r
+ stopOffsets.PushBack(0.0f);\r
+ stopOffsets.PushBack(1.0f);\r
+ Property::Array stopColors;\r
+ stopColors.PushBack(Color::BLACK);\r
+ stopColors.PushBack(Vector4(0.45f, 0.7f, 0.8f, 1.f)); // Medium bright, pastel blue\r
+ const float percentageWindowHeight = window.GetSize().GetHeight() * 0.6f;\r
+\r
+ navigationView.SetProperty(Toolkit::Control::Property::BACKGROUND,\r
+ Dali::Property::Map()\r
+ .Add(Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT)\r
+ .Add(Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets)\r
+ .Add(Toolkit::GradientVisual::Property::STOP_COLOR, stopColors)\r
+ .Add(Toolkit::GradientVisual::Property::START_POSITION, Vector2(0.f, -percentageWindowHeight))\r
+ .Add(Toolkit::GradientVisual::Property::END_POSITION, Vector2(0.f, percentageWindowHeight))\r
+ .Add(Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE));\r
+ window.Add(navigationView);\r
+ mNavigationView = navigationView;\r
+\r
+ // item view\r
+ auto tapDetector = TapGestureDetector::New();\r
+ mItemFactory.reset(new ::ItemFactoryImpl(mSceneNames, tapDetector));\r
+\r
+ auto items = ItemView::New(*mItemFactory);\r
+ SetActorCentered(items);\r
+ items.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);\r
+ items.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
+\r
+ Vector3 windowSize(window.GetSize());\r
+ auto itemLayout = DefaultItemLayout::New(DefaultItemLayout::LIST);\r
+ itemLayout->SetItemSize(Vector3(windowSize.x * 0.9f, ITEM_HEIGHT, 1.f));\r
+ items.AddLayout(*itemLayout);\r
+ navigationView.Push(items);\r
+\r
+ mItemLayout = itemLayout;\r
+ mItemView = items;\r
+\r
+ mItemView.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);\r
+ KeyboardFocusManager::Get().PreFocusChangeSignal().Connect(this, &Scene3DExample::OnKeyboardPreFocusChange);\r
+ KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect(this, &Scene3DExample::OnKeyboardFocusedActorActivated);\r
+ KeyboardFocusManager::Get().FocusChangedSignal().Connect(this, &Scene3DExample::OnKeyboardFocusChanged);\r
+\r
+ SetActorCentered(KeyboardFocusManager::Get().GetFocusIndicatorActor());\r
+\r
+ // camera\r
+ auto camera = CameraActor::New();\r
+ camera.SetInvertYAxis(true);\r
+ window.Add(camera);\r
+ mSceneCamera = camera;\r
+\r
+ // event handling\r
+ window.KeyEventSignal().Connect(this, &Scene3DExample::OnKey);\r
+\r
+ tapDetector.DetectedSignal().Connect(this, &Scene3DExample::OnTap);\r
+ mTapDetector = tapDetector;\r
+\r
+ // activate layout\r
+ mItemView.ActivateLayout(0, windowSize, 0.f);\r
+\r
+ mScene3DExtension->SetSceneLoader(this);\r
+}\r
+\r
+Actor Scene3DExample::OnKeyboardPreFocusChange(Actor current, Actor proposed, Control::KeyboardFocus::Direction direction)\r
+{\r
+ if(!current && !proposed)\r
+ {\r
+ return mItemView;\r
+ }\r
+\r
+ return proposed;\r
+}\r
+\r
+void Scene3DExample::OnKeyboardFocusedActorActivated(Actor activatedActor)\r
+{\r
+ if(activatedActor)\r
+ {\r
+ OnTap(activatedActor, Dali::TapGesture());\r
+ }\r
+}\r
+\r
+void Scene3DExample::OnKeyboardFocusChanged(Actor originalFocusedActor, Actor currentFocusedActor)\r
+{\r
+ if(currentFocusedActor)\r
+ {\r
+ auto itemId = mItemView.GetItemId(currentFocusedActor);\r
+ mItemView.ScrollToItem(itemId, 0.1f);\r
+ }\r
+}\r
+\r
+void Scene3DExample::OnTerminate(Application& app)\r
+{\r
+ mTapDetector.Reset();\r
+ mPanDetector.Reset();\r
+\r
+ auto window = app.GetWindow();\r
+ auto renderTasks = window.GetRenderTaskList();\r
+ renderTasks.RemoveTask(mSceneRender);\r
+ mSceneRender.Reset();\r
+\r
+ UnparentAndReset(mNavigationView);\r
+ UnparentAndReset(mSceneCamera);\r
+\r
+ mItemFactory.reset();\r
+}\r
+\r
+void Scene3DExample::OnKey(const KeyEvent& e)\r
+{\r
+ if(e.GetState() == KeyEvent::UP)\r
+ {\r
+ if(IsKey(e, DALI_KEY_ESCAPE) || IsKey(e, DALI_KEY_BACK))\r
+ {\r
+ if(mScene)\r
+ {\r
+ mPanDetector.Reset();\r
+\r
+ mNavigationView.Pop();\r
+ mScene.Reset();\r
+\r
+ if(mActivatedActor)\r
+ {\r
+ KeyboardFocusManager::Get().SetCurrentFocusActor(mActivatedActor);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ mApp.Quit();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ mScene3DExtension->OnKey(e);\r
+ }\r
+ }\r
+}\r
+\r
+void Scene3DExample::OnPan(Actor actor, const PanGesture& pan)\r
+{\r
+ auto windowSize = mApp.GetWindow().GetSize();\r
+ Vector2 size{float(windowSize.GetWidth()), float(windowSize.GetHeight())};\r
+ float aspect = size.y / size.x;\r
+\r
+ size /= ROTATION_SCALE;\r
+\r
+ Vector2 rotation{pan.GetDisplacement().x / size.x, pan.GetDisplacement().y / size.y * aspect};\r
+\r
+ Quaternion q = Quaternion(Radian(Degree(rotation.y)), Radian(Degree(rotation.x)), Radian(0.f));\r
+ Quaternion q0 = mScene.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();\r
+\r
+ mScene.SetProperty(Actor::Property::ORIENTATION, q * q0);\r
+}\r
+\r
+void Scene3DExample::OnTap(Dali::Actor actor, const Dali::TapGesture& tap)\r
+{\r
+ mActivatedActor = actor;\r
+\r
+ auto id = mItemView.GetItemId(actor);\r
+\r
+ try\r
+ {\r
+ auto window = mApp.GetWindow();\r
+ auto renderTasks = window.GetRenderTaskList();\r
+ renderTasks.RemoveTask(mSceneRender);\r
+\r
+ auto scene = LoadScene(mSceneNames[id], mSceneCamera, &mSceneAnimations, mCurrentAnimation);\r
+\r
+ auto sceneRender = renderTasks.CreateTask();\r
+ sceneRender.SetCameraActor(mSceneCamera);\r
+ sceneRender.SetSourceActor(scene);\r
+ sceneRender.SetExclusive(true);\r
+\r
+ mScene = scene;\r
+ mSceneRender = sceneRender;\r
+\r
+ mPanDetector = PanGestureDetector::New();\r
+ mPanDetector.DetectedSignal().Connect(this, &Scene3DExample::OnPan);\r
+ mPanDetector.Attach(mNavigationView);\r
+ }\r
+ catch(const DaliException& e)\r
+ {\r
+ mScene = CreateErrorMessage(e.condition);\r
+ }\r
+\r
+ mNavigationView.Push(mScene);\r
+\r
+ mScene3DExtension->ConnectTouchSignals();\r
+}\r
--- /dev/null
+#ifndef SCENE_LAUNCHER_H_\r
+#define SCENE_LAUNCHER_H_\r
+/*\r
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <memory>\r
+#include "dali-scene3d/public-api/loader/animation-definition.h"\r
+#include "dali-scene3d/public-api/loader/camera-parameters.h"\r
+#include "dali-scene3d/public-api/loader/node-definition.h"\r
+#include "dali-scene3d/public-api/loader/scene-definition.h"\r
+#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h"\r
+#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h"\r
+#include "dali/public-api/actors/camera-actor.h"\r
+#include "dali/public-api/adaptor-framework/application.h"\r
+#include "dali/public-api/common/vector-wrapper.h"\r
+#include "dali/public-api/events/pan-gesture-detector.h"\r
+#include "dali/public-api/render-tasks/render-task.h"\r
+#include "dali/public-api/signals/connection-tracker.h"\r
+\r
+class Scene3DExtension;\r
+\r
+class Scene3DExample : public Dali::ConnectionTracker\r
+{\r
+public:\r
+ Scene3DExample(Dali::Application& app);\r
+ ~Scene3DExample();\r
+\r
+private: // data\r
+ Dali::Application& mApp;\r
+\r
+ std::vector<std::string> mSceneNames;\r
+\r
+ Dali::Toolkit::NavigationView mNavigationView;\r
+\r
+ std::unique_ptr<Dali::Toolkit::ItemFactory> mItemFactory;\r
+ Dali::Toolkit::ItemLayoutPtr mItemLayout;\r
+ Dali::Toolkit::ItemView mItemView;\r
+\r
+ Dali::CameraActor mSceneCamera;\r
+ Dali::RenderTask mSceneRender;\r
+\r
+ Dali::Quaternion mCameraOrientationInv;\r
+\r
+ Dali::TapGestureDetector mTapDetector;\r
+ Dali::PanGestureDetector mPanDetector;\r
+\r
+ Dali::Actor mActivatedActor;\r
+\r
+public:\r
+ Dali::Actor mScene;\r
+\r
+ std::vector<Dali::Scene3D::Loader::AnimationDefinition> mSceneAnimations;\r
+ Dali::Animation mCurrentAnimation;\r
+\r
+ std::unique_ptr<Scene3DExtension> mScene3DExtension;\r
+\r
+private: // methods\r
+ void OnInit(Dali::Application& app);\r
+ void OnTerminate(Dali::Application& app);\r
+\r
+ void OnKey(const Dali::KeyEvent& e);\r
+ void OnPan(Dali::Actor actor, const Dali::PanGesture& pan);\r
+ void OnTap(Dali::Actor actor, const Dali::TapGesture& tap);\r
+\r
+ Dali::Actor OnKeyboardPreFocusChange(Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction);\r
+ void OnKeyboardFocusedActorActivated(Dali::Actor activatedActor);\r
+ void OnKeyboardFocusChanged(Dali::Actor originalFocusedActor, Dali::Actor currentFocusedActor);\r
+};\r
+\r
+#endif //SCENE_LAUNCHER_H_\r
--- /dev/null
+/*\r
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <dali-toolkit/dali-toolkit.h>\r
+#include <dali/dali.h>\r
+#include <cstring>\r
+\r
+class Scene3DExtension : public Dali::ConnectionTracker\r
+{\r
+public:\r
+ Scene3DExtension()\r
+ : mSceneLoader(nullptr),\r
+ mCurrentAnimationIndex(ANIMATION_IDLE)\r
+ {\r
+ }\r
+\r
+ ~Scene3DExtension() = default; // Nothing to do in destructor\r
+\r
+ void SetSceneLoader(Scene3DExample* scene3D)\r
+ {\r
+ mSceneLoader = scene3D;\r
+ }\r
+\r
+ void ConnectTouchSignals()\r
+ {\r
+ // This is a temporary hack for now to manually connect these signals.\r
+ // We should connect these signals automatically when loading the scene.\r
+\r
+ if(mSceneLoader)\r
+ {\r
+ ConnectTouchSignal(ICON_IDLE);\r
+ ConnectTouchSignal(ICON_SQUAT);\r
+ ConnectTouchSignal(ICON_JUMPING_JACK);\r
+ ConnectTouchSignal(ICON_LUNGE);\r
+ }\r
+ }\r
+\r
+ void OnKey(const Dali::KeyEvent& e)\r
+ {\r
+ // This is a temporary hack for now to manually handle these key events.\r
+ // We should links them to the animations automatically when loading the scene.\r
+\r
+ switch(e.GetKeyCode())\r
+ {\r
+ case KEY_ONE:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_IDLE);\r
+ break;\r
+ }\r
+ case KEY_TWO:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_IDLE_TO_SQUAT);\r
+ break;\r
+ }\r
+ case KEY_THREE:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_IDLE_TO_JUMPING_JACK);\r
+ break;\r
+ }\r
+ case KEY_FOUR:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_IDLE_TO_LUNGE);\r
+ break;\r
+ }\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+private:\r
+ bool PlaySceneAnimation(unsigned int animationIndex)\r
+ {\r
+ if(mSceneLoader && mSceneLoader->mScene)\r
+ {\r
+ if(mSceneLoader->mCurrentAnimation &&\r
+ mCurrentAnimationIndex != ANIMATION_IDLE &&\r
+ mSceneLoader->mCurrentAnimation.GetState() != Dali::Animation::STOPPED)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ auto root = mSceneLoader->mScene;\r
+ auto getActor = [&root](const std::string& name) {\r
+ return root.FindChildByName(name);\r
+ };\r
+\r
+ if(mSceneLoader->mSceneAnimations.size() > animationIndex)\r
+ {\r
+ mCurrentAnimationIndex = animationIndex;\r
+ mSceneLoader->mCurrentAnimation = mSceneLoader->mSceneAnimations[animationIndex].ReAnimate(getActor);\r
+ mSceneLoader->mCurrentAnimation.FinishedSignal().Connect(this, &Scene3DExtension::OnAnimationFinished);\r
+ mSceneLoader->mCurrentAnimation.Play();\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ void ConnectTouchSignal(const std::string actorName)\r
+ {\r
+ if(mSceneLoader && mSceneLoader->mScene)\r
+ {\r
+ auto actor = mSceneLoader->mScene.FindChildByName(actorName);\r
+ if(actor)\r
+ {\r
+ actor.TouchedSignal().Connect(this, &Scene3DExtension::OnTouch);\r
+ }\r
+ }\r
+ }\r
+\r
+ void OnAnimationFinished(Dali::Animation& source)\r
+ {\r
+ switch(mCurrentAnimationIndex)\r
+ {\r
+ case ANIMATION_IDLE_TO_SQUAT:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_SQUAT_TO_IDLE);\r
+ break;\r
+ }\r
+ case ANIMATION_IDLE_TO_JUMPING_JACK:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_JUMPING_JACK);\r
+ break;\r
+ }\r
+ case ANIMATION_JUMPING_JACK:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_JUMPING_JACK_TO_IDLE);\r
+ break;\r
+ }\r
+ case ANIMATION_IDLE_TO_LUNGE:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_LUNGE);\r
+ break;\r
+ }\r
+ case ANIMATION_LUNGE:\r
+ {\r
+ PlaySceneAnimation(ANIMATION_LUNGE_TO_IDLE);\r
+ break;\r
+ }\r
+ default:\r
+ {\r
+ mCurrentAnimationIndex = ANIMATION_IDLE;\r
+ break;\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& touch)\r
+ {\r
+ bool processed = false;\r
+\r
+ if(touch.GetPointCount() > 0)\r
+ {\r
+ if(touch.GetState(0) == Dali::PointState::DOWN)\r
+ {\r
+ auto actorName = actor.GetProperty<std::string>(Dali::Actor::Property::NAME);\r
+\r
+ if(ICON_IDLE == actorName)\r
+ {\r
+ processed = PlaySceneAnimation(ANIMATION_IDLE);\r
+ }\r
+ else if(ICON_SQUAT == actorName)\r
+ {\r
+ processed = PlaySceneAnimation(ANIMATION_IDLE_TO_SQUAT);\r
+ }\r
+ else if(ICON_JUMPING_JACK == actorName)\r
+ {\r
+ processed = PlaySceneAnimation(ANIMATION_IDLE_TO_JUMPING_JACK);\r
+ }\r
+ else if(ICON_LUNGE == actorName)\r
+ {\r
+ processed = PlaySceneAnimation(ANIMATION_IDLE_TO_LUNGE);\r
+ }\r
+ }\r
+ }\r
+ return processed;\r
+ }\r
+\r
+private:\r
+ static constexpr unsigned int KEY_ONE = 10;\r
+ static constexpr unsigned int KEY_TWO = 11;\r
+ static constexpr unsigned int KEY_THREE = 12;\r
+ static constexpr unsigned int KEY_FOUR = 13;\r
+\r
+ // Idle animation\r
+ static constexpr unsigned int ANIMATION_IDLE = 0;\r
+ // Squat animation\r
+ static constexpr unsigned int ANIMATION_IDLE_TO_SQUAT = 3;\r
+ static constexpr unsigned int ANIMATION_SQUAT_TO_IDLE = 15;\r
+ // JumpingJack animation\r
+ static constexpr unsigned int ANIMATION_IDLE_TO_JUMPING_JACK = 1;\r
+ static constexpr unsigned int ANIMATION_JUMPING_JACK = 5;\r
+ static constexpr unsigned int ANIMATION_JUMPING_JACK_TO_IDLE = 6;\r
+ // Lunge animation\r
+ static constexpr unsigned int ANIMATION_IDLE_TO_LUNGE = 2;\r
+ static constexpr unsigned int ANIMATION_LUNGE = 9;\r
+ static constexpr unsigned int ANIMATION_LUNGE_TO_IDLE = 10;\r
+\r
+ inline static const std::string ICON_IDLE = "Idle";\r
+ inline static const std::string ICON_SQUAT = "Squat";\r
+ inline static const std::string ICON_JUMPING_JACK = "JumpingJack";\r
+ inline static const std::string ICON_LUNGE = "Lunge";\r
+\r
+ Scene3DExample* mSceneLoader;\r
+ unsigned int mCurrentAnimationIndex;\r
+};\r
BuildRequires: pkgconfig(dali2-core)
BuildRequires: pkgconfig(dali2-adaptor)
BuildRequires: pkgconfig(dali2-toolkit)
-BuildRequires: pkgconfig(dali2-scene-loader)
+BuildRequires: pkgconfig(dali2-scene3d)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(gles20)
BuildRequires: pkgconfig(glesv2)
msgid "DALI_DEMO_STR_TITLE_RENDERER_STENCIL"
msgstr "Renderer Stencil"
-msgid "DALI_DEMO_STR_TITLE_SCENE_LOADER"
-msgstr "Scene Loader"
+msgid "DALI_DEMO_STR_TITLE_SCENE3D"
+msgstr "Scene3D"
msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
msgstr "Script-based UI"
msgid "DALI_DEMO_STR_TITLE_RENDERER_STENCIL"
msgstr "Renderer Stencil"
-msgid "DALI_DEMO_STR_TITLE_SCENE_LOADER"
-msgstr "Scene Loader"
+msgid "DALI_DEMO_STR_TITLE_SCENE3D"
+msgstr "Scene3D"
msgid "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI"
msgstr "Script-based UI"
#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_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D_VIEW")
-#define DALI_DEMO_STR_TITLE_SCENE_LOADER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE_LOADER")
+#define DALI_DEMO_STR_TITLE_SCENE3D dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCENE3D")
#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")
#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_VIEW "Scene3D View glTF"
-#define DALI_DEMO_STR_TITLE_SCENE_LOADER "Scene Loader"
+#define DALI_DEMO_STR_TITLE_SCENE3D "Scene3D"
#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"