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_JOINT_MATRICES_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_JOINT_MATRICES_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/math/matrix.h>
22 #include <base/math/vector.h>
23 #include <core/ecs/component_struct_macros.h>
24 #include <core/ecs/intf_component_manager.h>
25 
CORE3D_BEGIN_NAMESPACE()26 CORE3D_BEGIN_NAMESPACE()
27 namespace {
28 #include <3d/shaders/common/3d_dm_structures_common.h>
29 }
30 #endif
31 /** Contains the joint matrices of a skinned entity.
32 SkinComponent points the ISkin resources containing joint names and the inverse bind matrices of the joints.
33 SkinJointsComponent contains the entities which match the joint names in the hierarchy of the skinned entity.
34 */
35 BEGIN_COMPONENT(IJointMatricesComponentManager, JointMatricesComponent)
36 
37     /**
38      * Number of valid entries in jointMatrices array.
39      */
40     DEFINE_PROPERTY(size_t, count, "Number of Matrices", 0, 0)
41 
42     /**
43      * Joint matrices for the skinned entity. SkinningSystem calculates the joint matrices
44      */
45     DEFINE_ARRAY_PROPERTY(
46         BASE_NS::Math::Mat4X4, CORE_DEFAULT_MATERIAL_MAX_JOINT_COUNT, jointMatrices, "Joint Matrices", 0, ARRAY_VALUE())
47 
48     /**
49      * Array of AABB minimum values for each joint in world space. Updated each frame by the SkinningSystem.
50      */
51     DEFINE_ARRAY_PROPERTY(BASE_NS::Math::Vec3, CORE_DEFAULT_MATERIAL_MAX_JOINT_COUNT, jointAabbMinArray,
52         "Joint AABB Min Values", 0, ARRAY_VALUE())
53 
54     /**
55      * Array of AABB maximium values for each joint in world space. Updated each frame by the SkinningSystem.
56      */
57     DEFINE_ARRAY_PROPERTY(BASE_NS::Math::Vec3, CORE_DEFAULT_MATERIAL_MAX_JOINT_COUNT, jointAabbMaxArray,
58         "Joint AABB Max Values", 0, ARRAY_VALUE())
59 
60     /**
61      * Minimum corner for the AABB that contains all the joints.
62      */
63     DEFINE_PROPERTY(
64         BASE_NS::Math::Vec3, jointsAabbMin, "Combined Joint AABB Min Values", 0, ARRAY_VALUE(0.0f, 0.0f, 0.0f))
65 
66     /**
67      * Maximum corner for the AABB that contains all the joints.
68      */
69     DEFINE_PROPERTY(
70         BASE_NS::Math::Vec3, jointsAabbMax, "Combined Joint AABB Max Values", 0, ARRAY_VALUE(0.0f, 0.0f, 0.0f))
71 
72 END_COMPONENT(IJointMatricesComponentManager, JointMatricesComponent, "59d701be-f741-4faa-b5d6-a4f20ad4e317")
73 #if !defined(IMPLEMENT_MANAGER)
74 CORE3D_END_NAMESPACE()
75 #endif
76 
77 #endif