[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / model-loader.h
1 #ifndef DALI_SCENE3D_LOADER_MODEL_LOADER_H
2 #define DALI_SCENE3D_LOADER_MODEL_LOADER_H
3 /*
4  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // INTERNAL INCLUDES
21 #include <dali-scene3d/public-api/api.h>
22 #include <dali-scene3d/public-api/loader/load-result.h>
23 #include <dali-scene3d/public-api/loader/scene-definition.h>
24
25 // EXTERNAL INCLUDES
26 #include <string>
27
28 namespace Dali::Scene3D::Loader
29 {
30 namespace Internal
31 {
32 class ModelLoaderImpl;
33 }
34
35 class DALI_SCENE3D_API ModelLoader
36 {
37 public:
38   class InputParameter
39   {
40   };
41
42   /**
43    * @brief ModelLoader Constructor.
44    * @SINCE_2_2.17
45    * @param[in] modelUrl Url of the model file to be loaded
46    * @param[in] resourceDirectoryUrl Url of directory that contains resources.
47    * @param[out] loadResult Loaded result that includes scene tree and resources.
48    */
49   ModelLoader(const std::string& modelUrl, const std::string& resourceDirectoryUrl, Dali::Scene3D::Loader::LoadResult& loadResult);
50
51   /**
52    * @brief Request to load model from model url.
53    * @SINCE_2_2.17
54    * @param[in] pathProvider Path provider that defines resource paths.
55    * @param[in] loadOnlyRawResource If true, load Raw resource only, and do not create Dali::Handle
56    * If false, this loader load Raw resource and create Dali::Handle too.
57    * Default value is false;
58    * @return True if model loading is successfully finished.
59    */
60   bool LoadModel(Dali::Scene3D::Loader::ResourceBundle::PathProvider& pathProvider, bool loadOnlyRawResource = false);
61
62   /**
63    * @brief Set InputParameter.
64    *
65    * This method store only a pointer of InputParameter.
66    * The object of InputParameter should not be deleted until it is no longer used.
67    * @SINCE_2_2.17
68    * @param[in] inputParameter Input parameters that can be used in loading time.
69    */
70   void SetInputParameter(InputParameter& inputParameter);
71
72   /**
73    * @brief Retrieves loaded scene.
74    * @SINCE_2_2.17
75    * @return SceneDefinition that is loaded from file
76    */
77   Dali::Scene3D::Loader::SceneDefinition& GetScene();
78
79   /**
80    * @brief Retrieves resource bundle that includes resource information.
81    * @SINCE_2_2.17
82    * @return ResourceBundle for model resources
83    */
84   Dali::Scene3D::Loader::ResourceBundle& GetResources();
85
86   /**
87    * @brief Retrieves loaded AnimationDefinition.
88    * @SINCE_2_2.17
89    * @return AnimationDefinition that is loaded from file
90    */
91   std::vector<Dali::Scene3D::Loader::AnimationDefinition>& GetAnimations();
92
93   /**
94    * @brief Retrieves loaded CameraParameters.
95    * @SINCE_2_2.17
96    * @return CameraParameters list that is loaded from file
97    */
98   std::vector<Dali::Scene3D::Loader::CameraParameters>& GetCameras();
99
100   /**
101    * @brief Retrieves ResourceChoices.
102    * @SINCE_2_2.17
103    * @return Choices for loaded Resources
104    */
105   Dali::Scene3D::Loader::Customization::Choices& GetResourceChoices();
106
107 private:
108   /**
109    * @brief Create model loader for each file format.
110    * @SINCE_2_2.17
111    */
112   void CreateModelLoader();
113
114   /**
115    * @brief Load resource of the model.
116    * @SINCE_2_2.17
117    */
118   void LoadResource(Dali::Scene3D::Loader::ResourceBundle::PathProvider& pathProvider, bool loadOnlyRawResource);
119
120 private:
121   std::string mModelUrl;
122   std::string mResourceDirectoryUrl;
123
124   Dali::Scene3D::Loader::LoadResult             mLoadResult;
125   Dali::Scene3D::Loader::Customization::Choices mResourceChoices;
126
127   std::shared_ptr<Internal::ModelLoaderImpl> mImpl;
128 };
129 } // namespace Dali::Scene3D::Loader
130
131 #endif // DALI_SCENE3D_LOADER_MODEL_LOADER_H