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
16 #ifndef SCENE_SRC_COMPONENT_ANIMATION_COMPONENT_H
17 #define SCENE_SRC_COMPONENT_ANIMATION_COMPONENT_H
18
19 #include <scene/ext/component_fwd.h>
20
21 #include <3d/ecs/components/animation_component.h>
22 #include <core/ecs/entity_reference.h>
23
24 #include <meta/base/meta_types.h>
25 #include <meta/ext/object.h>
26
27 META_TYPE(CORE3D_NS::AnimationComponent::PlaybackState)
28
SCENE_BEGIN_NAMESPACE()29 SCENE_BEGIN_NAMESPACE()
30
31 class IInternalAnimation : public CORE_NS::IInterface {
32 META_INTERFACE(CORE_NS::IInterface, IInternalAnimation, "2674d7bb-354d-45c4-8e09-f4c5fd9aa2e4")
33 public:
34 META_PROPERTY(CORE3D_NS::AnimationComponent::PlaybackState, State)
35 META_PROPERTY(uint32_t, RepeatCount)
36 META_PROPERTY(float, StartOffset)
37 META_PROPERTY(float, Duration)
38 META_PROPERTY(float, Weight)
39 META_PROPERTY(float, Speed)
40 META_ARRAY_PROPERTY(CORE_NS::EntityReference, Tracks)
41
42 // Part of AnimationStateComponent
43 META_PROPERTY(float, Time)
44 };
45
46 META_REGISTER_CLASS(
47 AnimationComponent, "8f89820a-6484-4a5e-9ee3-814ed2a1f8f9", META_NS::ObjectCategoryBits::NO_CATEGORY)
48
49 class AnimationComponent : public META_NS::IntroduceInterfaces<ComponentFwd, IInternalAnimation> {
50 META_OBJECT(AnimationComponent, SCENE_NS::ClassId::AnimationComponent, IntroduceInterfaces)
51
52 public:
53 META_BEGIN_STATIC_DATA()
54 SCENE_STATIC_PROPERTY_DATA(
55 IInternalAnimation, CORE3D_NS::AnimationComponent::PlaybackState, State, "AnimationComponent.state")
56 SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, uint32_t, RepeatCount, "AnimationComponent.repeatCount")
57 SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, StartOffset, "AnimationComponent.startOffset")
58 SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Duration, "AnimationComponent.duration")
59 SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Weight, "AnimationComponent.weight")
60 SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Speed, "AnimationComponent.speed")
61 SCENE_STATIC_ARRAY_PROPERTY_DATA(IInternalAnimation, CORE_NS::EntityReference, Tracks, "AnimationComponent.tracks")
62 SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Time, "AnimationStateComponent.time")
63 META_END_STATIC_DATA()
64
65 META_IMPLEMENT_PROPERTY(CORE3D_NS::AnimationComponent::PlaybackState, State)
66 META_IMPLEMENT_PROPERTY(uint32_t, RepeatCount)
67 META_IMPLEMENT_PROPERTY(float, StartOffset)
68 META_IMPLEMENT_PROPERTY(float, Duration)
69 META_IMPLEMENT_PROPERTY(float, Weight)
70 META_IMPLEMENT_PROPERTY(float, Speed)
71 META_IMPLEMENT_ARRAY_PROPERTY(CORE_NS::EntityReference, Tracks)
72
73 META_IMPLEMENT_PROPERTY(float, Time)
74 public:
75 BASE_NS::string GetName() const override;
76 bool SetEcsObject(const IEcsObject::Ptr& obj) override;
77 };
78
79 SCENE_END_NAMESPACE()
80
81 #endif