• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.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     META_READONLY_PROPERTY(bool, Completed);
45 };
46 
47 META_REGISTER_CLASS(
48     AnimationComponent, "8f89820a-6484-4a5e-9ee3-814ed2a1f8f9", META_NS::ObjectCategoryBits::NO_CATEGORY)
49 
50 class AnimationComponent : public META_NS::IntroduceInterfaces<Component, IInternalAnimation> {
51     META_OBJECT(AnimationComponent, SCENE_NS::ClassId::AnimationComponent, IntroduceInterfaces)
52 
53 public:
54     META_BEGIN_STATIC_DATA()
55     SCENE_STATIC_PROPERTY_DATA(
56         IInternalAnimation, CORE3D_NS::AnimationComponent::PlaybackState, State, "AnimationComponent.state")
57     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, uint32_t, RepeatCount, "AnimationComponent.repeatCount")
58     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, StartOffset, "AnimationComponent.startOffset")
59     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Duration, "AnimationComponent.duration")
60     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Weight, "AnimationComponent.weight")
61     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Speed, "AnimationComponent.speed")
62     SCENE_STATIC_ARRAY_PROPERTY_DATA(IInternalAnimation, CORE_NS::EntityReference, Tracks, "AnimationComponent.tracks")
63     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, float, Time, "AnimationStateComponent.time")
64     SCENE_STATIC_PROPERTY_DATA(IInternalAnimation, bool, Completed, "AnimationStateComponent.completed")
65     META_END_STATIC_DATA()
66 
67     META_IMPLEMENT_PROPERTY(CORE3D_NS::AnimationComponent::PlaybackState, State)
68     META_IMPLEMENT_PROPERTY(uint32_t, RepeatCount)
69     META_IMPLEMENT_PROPERTY(float, StartOffset)
70     META_IMPLEMENT_PROPERTY(float, Duration)
71     META_IMPLEMENT_PROPERTY(float, Weight)
72     META_IMPLEMENT_PROPERTY(float, Speed)
73     META_IMPLEMENT_ARRAY_PROPERTY(CORE_NS::EntityReference, Tracks)
74 
75     META_IMPLEMENT_PROPERTY(float, Time)
76     META_IMPLEMENT_READONLY_PROPERTY(bool, Completed)
77 public:
78     BASE_NS::string GetName() const override;
79     bool SetEcsObject(const IEcsObject::Ptr& obj) override;
80 };
81 
82 SCENE_END_NAMESPACE()
83 
84 #endif
85