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 API_3D_ECS_SYSTEMS_ISKINNING_SYSTEM_H
17  #define API_3D_ECS_SYSTEMS_ISKINNING_SYSTEM_H
18  
19  #include <3d/namespace.h>
20  #include <base/containers/array_view.h>
21  #include <base/containers/string_view.h>
22  #include <core/ecs/intf_system.h>
23  
24  CORE_BEGIN_NAMESPACE()
25  struct Entity;
26  CORE_END_NAMESPACE()
27  
CORE3D_BEGIN_NAMESPACE()28  CORE3D_BEGIN_NAMESPACE()
29  /** @ingroup group_ecs_systems_iskinning */
30  /** ISkinning system */
31  class ISkinningSystem : public CORE_NS::ISystem {
32  public:
33      static constexpr BASE_NS::Uid UID { "06931e7e-cd68-43b4-8f89-40652dade9fa" };
34  
35      /** Creates a skin instance for the given entity.
36       *  @param skinIbmEntity Entity where we get skin ibm matrices.
37       *  @param joints List of entities which are the joints of the skin. The order should match the order of the skin
38       * IBM entity's matrices.
39       *  @param entity Entity where we get node which we use in instance creation.
40       *  @param skeleton Entity pointing to the node that is the common root of the joint entity hierarchy (optional).
41       */
42      virtual void CreateInstance(CORE_NS::Entity const& skinIbmEntity,
43          BASE_NS::array_view<const CORE_NS::Entity> const& joints, CORE_NS::Entity const& entity,
44          CORE_NS::Entity const& skeleton) = 0;
45  
46      /** Creates a skin instance for the given entity.
47       *  @param skinIbmEntity Entity where we get skin ibm matrices and joint entities.
48       *  @param entity Entity where we get node which we use in instance creation.
49       *  @param skeleton Entity pointing to the node that is the common root of the joint entity hierarchy (optional).
50       */
51      virtual void CreateInstance(
52          CORE_NS::Entity const& skinIbmEntity, CORE_NS::Entity const& entity, CORE_NS::Entity const& skeleton) = 0;
53  
54      /** Destroys Skin Instance.
55       *  @param entity Entity whose skin instance is destroyed.
56       */
57      virtual void DestroyInstance(CORE_NS::Entity const& entity) = 0;
58  
59  protected:
60      ISkinningSystem() = default;
61      ISkinningSystem(const ISkinningSystem&) = delete;
62      ISkinningSystem(ISkinningSystem&&) = delete;
63      ISkinningSystem& operator=(const ISkinningSystem&) = delete;
64      ISkinningSystem& operator=(ISkinningSystem&&) = delete;
65  };
66  
67  /** @ingroup group_ecs_systems_iskinning */
68  /** Return name of this system
69   */
GetName(const ISkinningSystem *)70  inline constexpr BASE_NS::string_view GetName(const ISkinningSystem*)
71  {
72      return "SkinningSystem";
73  }
74  CORE3D_END_NAMESPACE()
75  
76  #endif // API_3D_ECS_SYSTEMS_ISKINNING_SYSTEM_H
77