1 #ifndef DALI_SCENE3D_MODEL_MOTION_MOTION_DATA_IMPL_H
2 #define DALI_SCENE3D_MODEL_MOTION_MOTION_DATA_IMPL_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/common/intrusive-ptr.h>
24 #include <dali/public-api/object/base-object.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <utility> ///< for std::pair
30 #include <dali-scene3d/internal/model-motion/motion-data-load-task.h>
31 #include <dali-scene3d/public-api/loader/animation-definition.h>
32 #include <dali-scene3d/public-api/model-motion/motion-data.h>
40 using MotionDataPtr = IntrusivePtr<MotionData>;
43 * @brief Internal data for Scene3D::MotionData.
45 class MotionData : public BaseObject
47 public: // Creation & Destruction
49 * @brief Create a new MotionData object.
50 * @return A smart-pointer to the newly allocated MotionData.
52 static MotionDataPtr New();
56 * @brief Construct a new MotionData.
61 * @brief Second-phase constructor.
66 * @brief Virtual destructor.
68 virtual ~MotionData();
70 public: // Public Method
72 * @copydoc Dali::Scene3D::MotionData::GetMotionCount()
74 uint32_t GetMotionCount() const;
77 * @copydoc Dali::Scene3D::MotionData::GetIndex()
79 Scene3D::MotionIndex GetIndex(uint32_t index) const;
82 * @copydoc Dali::Scene3D::MotionData::GetValue()
84 Scene3D::MotionValue GetValue(uint32_t index) const;
87 * @copydoc Dali::Scene3D::MotionData::Add()
89 void Add(Scene3D::MotionIndex index, Scene3D::MotionValue value);
92 * @copydoc Dali::Scene3D::MotionData::Clear()
97 * @copydoc Dali::Scene3D::MotionData::SetDuration()
99 void SetDuration(float durationSeconds);
102 * @copydoc Dali::Scene3D::MotionData::GetDuration()
104 float GetDuration() const;
107 * @copydoc Dali::Scene3D::MotionData::LoadBvh()
109 void LoadBvh(const std::string& path, bool useRootTranslationOnly, const Vector3& scale = Vector3::ONE, bool synchronousLoad = false);
112 * @copydoc Dali::Scene3D::MotionData::LoadBvhFromBuffer()
114 void LoadBvhFromBuffer(const uint8_t* rawBuffer, int rawBufferLength, bool useRootTranslationOnly, const Vector3& scale = Vector3::ONE, bool synchronousLoad = false);
117 * @copydoc Dali::Scene3D::MotionData::LoadFacialAnimation()
119 void LoadFacialAnimation(const std::string& url, bool synchronousLoad = false);
122 * @copydoc Dali::Scene3D::MotionData::LoadFacialAnimationFromBuffer()
124 void LoadFacialAnimationFromBuffer(const uint8_t* rawBuffer, int rawBufferLength, bool synchronousLoad = false);
128 * @copydoc Dali::Scene3D::MotionData::LoadCompletedSignal()
130 Scene3D::MotionData::LoadCompletedSignalType& LoadCompletedSignal()
132 return mLoadCompletedSignal;
137 * @brief Request motion data load task process.
139 * @param[in] synchronousLoad True if we want to load result synchronously.
141 void RequestMotionDataLoad(bool synchronousLoad);
144 * @brief Cancel requested motion data load task process.
146 void CancelMotionDataLoad();
150 * @brief Called when async load task completed.
152 * @param[in] task Completed tasks
154 void OnLoadCompleted(MotionDataLoadTaskPtr task);
157 // Asynchronous loading variable
158 MotionDataLoadTaskPtr mMotionDataLoadTask{nullptr};
159 Scene3D::MotionData::LoadCompletedSignalType mLoadCompletedSignal;
161 std::vector<std::pair<Scene3D::MotionIndex, Scene3D::MotionValue>> mMotions{};
163 float mDurationSeconds{0.0f}; ///< Duration of animation if we generate this motion data as Dali::Animation.
166 } // namespace Internal
168 // Helpers for public-api forwarding methods
170 inline Internal::MotionData& GetImplementation(Dali::Scene3D::MotionData& motionData)
172 DALI_ASSERT_ALWAYS(motionData && "MotionData handle is empty");
174 BaseObject& handle = motionData.GetBaseObject();
176 return static_cast<Internal::MotionData&>(handle);
179 inline const Internal::MotionData& GetImplementation(const Dali::Scene3D::MotionData& motionData)
181 DALI_ASSERT_ALWAYS(motionData && "MotionData handle is empty");
183 const BaseObject& handle = motionData.GetBaseObject();
185 return static_cast<const Internal::MotionData&>(handle);
188 } // namespace Scene3D
192 #endif // DALI_SCENE3D_MODEL_MOTION_MOTION_DATA_IMPL_H