From: seungho baek Date: Thu, 23 Feb 2023 01:51:40 +0000 (+0900) Subject: [Tizen] Change to use ModelLoader instead of Gltf2Loader and DliLoader X-Git-Tag: accepted/tizen/7.0/unified/20230404.033736 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Faccepted%2Ftizen%2F7.0%2Funified%2F20230404.033736;p=platform%2Fcore%2Fuifw%2Fdali-demo.git [Tizen] Change to use ModelLoader instead of Gltf2Loader and DliLoader Change-Id: Ib9a64eef388799d4534d86f95b20735bc03a7fdd --- diff --git a/examples/scene3d/scene3d-example.cpp b/examples/scene3d/scene3d-example.cpp index da9ea20..6759c6c 100644 --- a/examples/scene3d/scene3d-example.cpp +++ b/examples/scene3d/scene3d-example.cpp @@ -19,8 +19,7 @@ #include #include #include -#include "dali-scene3d/public-api/loader/dli-loader.h" -#include "dali-scene3d/public-api/loader/gltf2-loader.h" +#include "dali-scene3d/public-api/loader/model-loader.h" #include "dali-scene3d/public-api/loader/light-parameters.h" #include "dali-scene3d/public-api/loader/load-result.h" #include "dali-scene3d/public-api/loader/shader-definition-factory.h" @@ -141,7 +140,7 @@ void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition } } -Actor LoadScene(std::string sceneName, CameraActor camera, std::vector* animations, Animation& animation) +Actor LoadScene(std::string sceneName, CameraActor camera, std::vector& generatedAnimations, Animation& animation) { ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) { return Application::GetResourcePath() + RESOURCE_TYPE_DIRS[type]; @@ -149,48 +148,27 @@ Actor LoadScene(std::string sceneName, CameraActor camera, std::vector animGroups; - std::vector cameraParameters; - std::vector lights; + ResourceBundle resources; + SceneDefinition scene; + SceneMetadata metaData; + std::vector animations; + std::vector animGroups; + std::vector cameraParameters; + std::vector lights; - animations->clear(); + animations.clear(); LoadResult output{ resources, scene, metaData, - *animations, + animations, animGroups, cameraParameters, lights}; - if(sceneName.rfind(DLI_EXTENSION) == sceneName.size() - DLI_EXTENSION.size()) - { - DliLoader loader; - DliLoader::InputParams input{ - pathProvider(ResourceType::Mesh), - nullptr, - {}, - {}, - nullptr, - {}}; - DliLoader::LoadParams loadParams{input, output}; - if(!loader.LoadScene(path, loadParams)) - { - ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << path << "': " << loader.GetParseError(); - } - } - else - { - ShaderDefinitionFactory sdf; - sdf.SetResources(resources); - LoadGltfScene(path, sdf, output); - - resources.mEnvironmentMaps.push_back({}); - } + Dali::Scene3D::Loader::ModelLoader modelLoader(path, pathProvider(ResourceType::Mesh) + "/", output); + modelLoader.LoadModel(pathProvider); if(cameraParameters.empty()) { @@ -210,20 +188,14 @@ Actor LoadScene(std::string sceneName, CameraActor camera, std::vectorempty()) + generatedAnimations.clear(); + if(!animations.empty()) { + generatedAnimations.reserve(animations.size()); auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property) { Dali::Actor actor; @@ -255,8 +229,11 @@ Actor LoadScene(std::string sceneName, CameraActor camera, std::vector mSceneAnimations; - Dali::Animation mCurrentAnimation; + std::vector mSceneAnimations; + Dali::Animation mCurrentAnimation; std::unique_ptr mScene3DExtension; diff --git a/examples/scene3d/scene3d-extension.h b/examples/scene3d/scene3d-extension.h index 7317d32..fd56d7f 100644 --- a/examples/scene3d/scene3d-extension.h +++ b/examples/scene3d/scene3d-extension.h @@ -93,16 +93,14 @@ private: return false; } - auto root = mSceneLoader->mScene; - auto getActor = [&root](const Dali::Scene3D::Loader::AnimatedProperty& property) { - return root.FindChildByName(property.mNodeName); - }; - if(mSceneLoader->mSceneAnimations.size() > animationIndex) { mCurrentAnimationIndex = animationIndex; - mSceneLoader->mCurrentAnimation = mSceneLoader->mSceneAnimations[animationIndex].ReAnimate(getActor); - mSceneLoader->mCurrentAnimation.FinishedSignal().Connect(this, &Scene3DExtension::OnAnimationFinished); + mSceneLoader->mCurrentAnimation = mSceneLoader->mSceneAnimations[animationIndex]; + if(mSceneLoader->mCurrentAnimation.FinishedSignal().GetConnectionCount() == 0) + { + mSceneLoader->mCurrentAnimation.FinishedSignal().Connect(this, &Scene3DExtension::OnAnimationFinished); + } mSceneLoader->mCurrentAnimation.Play(); } }