1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #ifndef SCENE_PLUGIN_INTF_ECS_ANIMATION_H
16 #define SCENE_PLUGIN_INTF_ECS_ANIMATION_H
17
18 #include <scene_plugin/namespace.h>
19
20 #include <core/ecs/intf_ecs.h>
21
22 #include <meta/ext/object.h>
23 #include <meta/ext/event_impl.h>
24 #include <meta/interface/animation/intf_animation.h>
25
SCENE_BEGIN_NAMESPACE()26 SCENE_BEGIN_NAMESPACE()
27
28 class IEcsTrackAnimation : public CORE_NS::IInterface {
29 META_INTERFACE(CORE_NS::IInterface, IEcsTrackAnimation, "fba5e210-b382-4391-b589-3e9b356556d5")
30 public:
31 virtual void SetEntity(CORE_NS::Entity entity) = 0;
32 virtual CORE_NS::Entity GetEntity() const = 0;
33 };
34
35 SCENE_END_NAMESPACE()
36
37 META_TYPE(SCENE_NS::IEcsTrackAnimation::Ptr);
38 META_TYPE(SCENE_NS::IEcsTrackAnimation::WeakPtr);
39
40 SCENE_BEGIN_NAMESPACE()
41
42 REGISTER_CLASS(EcsAnimation, "267fb911-f25a-4921-9909-8c71c4b499fe", META_NS::ObjectCategoryBits::NO_CATEGORY)
43 REGISTER_CLASS(EcsTrackAnimation, "0c8441e9-ed38-4bb4-9946-e0f71ae796cc", META_NS::ObjectCategoryBits::NO_CATEGORY)
44
45 class IEcsAnimation : public CORE_NS::IInterface {
46 META_INTERFACE(CORE_NS::IInterface, IEcsAnimation, "6eab865c-6aaf-472d-bf23-302df559c97e")
47
48 public:
49 META_READONLY_PROPERTY(bool, ReadOnly)
50
51 virtual bool SetRootEntity(CORE_NS::Entity entity) = 0;
52 virtual CORE_NS::Entity GetRootEntity() const = 0;
53
54 virtual void SetEntity(CORE_NS::IEcs& ecs, CORE_NS::Entity entity) = 0;
55 virtual CORE_NS::Entity GetEntity() const = 0;
56
57 virtual bool Retarget(CORE_NS::Entity entity) = 0;
58
59 virtual void SetDuration(uint32_t ms) = 0;
60
61 virtual void AddKey(IEcsTrackAnimation::Ptr track, float time) = 0;
62
63 // Remove key and timestamp at index.
64 virtual void RemoveKey(IEcsTrackAnimation::Ptr track, uint32_t index) = 0;
65
66 // Change key data position index.
67 virtual void UpdateKey(IEcsTrackAnimation::Ptr track, uint32_t oldKeyIndex, uint32_t newKeyIndex, float time) = 0;
68
69 virtual IEcsTrackAnimation::Ptr CreateAnimationTrack(
70 CORE_NS::Entity rootEntity, CORE_NS::Entity target, BASE_NS::string_view property) = 0;
71 virtual IEcsTrackAnimation::Ptr GetAnimationTrack(CORE_NS::Entity target, BASE_NS::string_view property) = 0;
72 virtual void DestroyAnimationTrack(IEcsTrackAnimation::Ptr track) = 0;
73 virtual void DestroyAllAnimationTracks() = 0;
74 virtual void Destroy() = 0;
75
76 virtual BASE_NS::vector<CORE_NS::EntityReference> GetAllRelatedEntities() const = 0;
77 };
78
79 SCENE_END_NAMESPACE()
80
81 META_TYPE(SCENE_NS::IEcsAnimation::Ptr);
82 META_TYPE(SCENE_NS::IEcsAnimation::WeakPtr);
83
84 void RegisterEcsAnimationObjectType();
85 void UnregisterEcsAnimationObjectType();
86
87 #endif // SCENE_PLUGIN_INTF_ECS_ANIMATION_H
88