[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / model-motion / motion-data-load-task.h
1 #ifndef DALI_SCENE3D_MODEL_MOTION_MOTION_DATA_LOAD_TASK_H
2 #define DALI_SCENE3D_MODEL_MOTION_MOTION_DATA_LOAD_TASK_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/async-task-manager.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-scene3d/public-api/loader/animation-definition.h>
26 #include <dali-scene3d/public-api/model-motion/motion-data.h>
27
28 namespace Dali
29 {
30 namespace Scene3D
31 {
32 namespace Internal
33 {
34 class MotionDataLoadTask;
35 typedef IntrusivePtr<MotionDataLoadTask> MotionDataLoadTaskPtr;
36
37 /**
38  * @brief AsyncTask for load MotionData from various type.
39  * After load finished, it will keep result as Loader::AnimationDefinition.
40  */
41 class MotionDataLoadTask : public AsyncTask
42 {
43 public:
44   enum class LoadMethod
45   {
46     BVH_FILE,
47     BVH_BUFFER,
48     FACIAL_FILE,
49     FACIAL_BUFFER,
50   };
51
52 public:
53   /**
54    * Constructor for load bvh from file.
55    */
56   MotionDataLoadTask(const std::string& path, bool useRootTranslationOnly, const Vector3& scale, CallbackBase* callback);
57
58   /**
59    * Constructor for load bvh from buffer.
60    */
61   MotionDataLoadTask(const uint8_t* rawBuffer, int rawBufferLength, bool useRootTranslationOnly, const Vector3& scale, CallbackBase* callback);
62
63   /**
64    * Constructor for load facial from file.
65    */
66   MotionDataLoadTask(const std::string& url, CallbackBase* callback);
67
68   /**
69    * Constructor for load facial from buffer.
70    */
71   MotionDataLoadTask(const uint8_t* rawBuffer, int rawBufferLength, CallbackBase* callback);
72
73   /**
74    * Destructor.
75    */
76   ~MotionDataLoadTask();
77
78 public: // Implementation of AsyncTask
79   /**
80    * @copydoc Dali::AsyncTask::Process()
81    */
82   void Process();
83
84   /**
85    * @copydoc Dali::AsyncTask::IsReady()
86    */
87   bool IsReady();
88
89   /**
90    * @copydoc Dali::AsyncTask::GetTaskName()
91    */
92   std::string_view GetTaskName() const override
93   {
94     return "MotionDataLoadTask";
95   }
96
97 public:
98   const Scene3D::Loader::AnimationDefinition& GetAnimationDefinition() const;
99
100 private:
101   // Undefined
102   MotionDataLoadTask(const MotionDataLoadTask& task) = delete;
103
104   // Undefined
105   MotionDataLoadTask& operator=(const MotionDataLoadTask& task) = delete;
106
107 private:
108   std::string mFileUrl;
109   uint8_t*    mRawBuffer;
110   int         mRawBufferLength;
111   Vector3     mScale;
112   bool        mUseRootTranslationOnly;
113
114   Scene3D::Loader::AnimationDefinition mAnimationDefinition;
115   LoadMethod                           mLoadMethod;
116 };
117
118 } // namespace Internal
119
120 } // namespace Scene3D
121
122 } // namespace Dali
123
124 #endif // DALI_SCENE3D_MODEL_MOTION_MOTION_DATA_LOAD_TASK_H