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 #if !defined(API_3D_ECS_COMPONENTS_ANIMATION_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_ANIMATION_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/containers/vector.h>
22 #include <core/ecs/component_struct_macros.h>
23 #include <core/ecs/intf_component_manager.h>
24 
25 CORE_BEGIN_NAMESPACE()
26 class EntityReference;
27 CORE_END_NAMESPACE()
28 
29 CORE3D_BEGIN_NAMESPACE()
30 #endif
31 
32 /**
33  * Animation component is the playback state for a collection of animations tracks.
34  */
35 BEGIN_COMPONENT(IAnimationComponentManager, AnimationComponent)
36 #if !defined(IMPLEMENT_MANAGER)
37     /** Playback states for an animation. */
38     enum class PlaybackState : uint8_t { STOP = 0, PLAY = 1, PAUSE = 2 };
39     /**  Special value for always repeating an animation. */
40     static constexpr uint32_t REPEAT_COUNT_INFINITE = ~0u;
41 #endif
42     /** State of the animation. */
43     DEFINE_PROPERTY(PlaybackState, state, "Playback State", 0, VALUE(PlaybackState::STOP))
44     /** Repeat the animation. */
45     DEFINE_PROPERTY(uint32_t, repeatCount, "Playback Repeat Count", 0, VALUE(1))
46     /** Track start offset in seconds. Allows skipping the beginning of the animation tracks. */
47     DEFINE_PROPERTY(float, startOffset, "Playback Start Offset", 0, VALUE(0.0f))
48     /** Track duration in seconds. Allows skipping the end of the animation tracks. */
49     DEFINE_PROPERTY(float, duration, "Playback Duration", 0, VALUE(0.0f))
50     /** Weight factor for this animation. */
51     DEFINE_PROPERTY(float, weight, "Playback Weight", 0, VALUE(1.f))
52     /** Playback speed. Negative speed plays the animation in reverse. */
53     DEFINE_PROPERTY(float, speed, "Playback Speed", 0, VALUE(1.f))
54     /** Tracks for this animation. */
55     DEFINE_PROPERTY(BASE_NS::vector<CORE_NS::EntityReference>, tracks, "Track Entities", 0, )
56 
57 END_COMPONENT(IAnimationComponentManager, AnimationComponent, "65f8a318-8931-4bc8-8476-02863937b1fa")
58 #if !defined(IMPLEMENT_MANAGER)
59 CORE3D_END_NAMESPACE()
60 #endif
61 #endif // API_3D_ECS_COMPONENTS_ANIMATION_COMPONENT_H
62