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_MESH_COMPONENT_H
17 #define SCENE_SRC_COMPONENT_MESH_COMPONENT_H
18
19 #include <scene/ext/component.h>
20 #include <scene/interface/intf_mesh.h>
21
22 #include <3d/ecs/components/mesh_component.h>
23 #include <3d/ecs/components/morph_component.h>
24 #include <3d/ecs/components/render_mesh_component.h>
25
26 #include <meta/ext/object.h>
27
28 META_TYPE(CORE3D_NS::MeshComponent::Submesh)
29
SCENE_BEGIN_NAMESPACE()30 SCENE_BEGIN_NAMESPACE()
31
32 class IInternalMesh : public CORE_NS::IInterface {
33 META_INTERFACE(CORE_NS::IInterface, IInternalMesh, "8926f642-01ee-411f-8fa0-c17d9cda4bb8")
34 public:
35 META_ARRAY_PROPERTY(CORE3D_NS::MeshComponent::Submesh, SubMeshes)
36 META_ARRAY_PROPERTY(float, JointBounds)
37 META_PROPERTY(BASE_NS::Math::Vec3, AABBMin)
38 META_PROPERTY(BASE_NS::Math::Vec3, AABBMax)
39 };
40
41 META_REGISTER_CLASS(MeshComponent, "3350d990-8d83-4d29-b916-db9854c7fa6f", META_NS::ObjectCategoryBits::NO_CATEGORY)
42
43 class MeshComponent : public META_NS::IntroduceInterfaces<Component, IInternalMesh> {
44 META_OBJECT(MeshComponent, ClassId::MeshComponent, IntroduceInterfaces)
45
46 public:
47 META_BEGIN_STATIC_DATA()
48 SCENE_STATIC_ARRAY_PROPERTY_DATA(
49 IInternalMesh, CORE3D_NS::MeshComponent::Submesh, SubMeshes, "MeshComponent.submeshes")
50 SCENE_STATIC_ARRAY_PROPERTY_DATA(IInternalMesh, float, JointBounds, "MeshComponent.jointBounds")
51 SCENE_STATIC_PROPERTY_DATA(IInternalMesh, BASE_NS::Math::Vec3, AABBMin, "MeshComponent.aabbMin")
52 SCENE_STATIC_PROPERTY_DATA(IInternalMesh, BASE_NS::Math::Vec3, AABBMax, "MeshComponent.aabbMax")
53 META_END_STATIC_DATA()
54
55 META_IMPLEMENT_ARRAY_PROPERTY(CORE3D_NS::MeshComponent::Submesh, SubMeshes)
56 META_IMPLEMENT_ARRAY_PROPERTY(float, JointBounds)
57 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec3, AABBMin)
58 META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec3, AABBMax)
59 public:
60 BASE_NS::string GetName() const override;
61 };
62
63 class IInternalRenderMesh : public CORE_NS::IInterface {
64 META_INTERFACE(CORE_NS::IInterface, IInternalRenderMesh, "2031ecad-eb1f-4017-8ebb-d4d2880a397f")
65 public:
66 META_PROPERTY(CORE_NS::Entity, Mesh)
67 };
68
69 META_REGISTER_CLASS(
70 RenderMeshComponent, "af2f8d45-b34d-4598-8374-ed48a8db69af", META_NS::ObjectCategoryBits::NO_CATEGORY)
71
72 class RenderMeshComponent : public META_NS::IntroduceInterfaces<Component, IInternalRenderMesh> {
73 META_OBJECT(RenderMeshComponent, SCENE_NS::ClassId::RenderMeshComponent, IntroduceInterfaces)
74
75 public:
76 META_BEGIN_STATIC_DATA()
77 SCENE_STATIC_PROPERTY_DATA(IInternalRenderMesh, CORE_NS::Entity, Mesh, "RenderMeshComponent.mesh")
78 META_END_STATIC_DATA()
79
80 META_IMPLEMENT_PROPERTY(CORE_NS::Entity, Mesh)
81 public:
82 BASE_NS::string GetName() const override;
83 };
84
85 META_REGISTER_CLASS(MorphComponent, "8feeb648-23fe-4dc5-9f33-cf502e671fe9", META_NS::ObjectCategoryBits::NO_CATEGORY)
86
87 class MorphComponent : public META_NS::IntroduceInterfaces<Component, IMorpher> {
88 META_OBJECT(MorphComponent, ClassId::MorphComponent, IntroduceInterfaces)
89
90 public:
91 META_BEGIN_STATIC_DATA()
92 SCENE_STATIC_ARRAY_PROPERTY_DATA(IMorpher, BASE_NS::string, MorphNames, "MorphComponent.morphNames")
93 SCENE_STATIC_ARRAY_PROPERTY_DATA(IMorpher, float, MorphWeights, "MorphComponent.morphWeights")
94 META_END_STATIC_DATA()
95
96 META_IMPLEMENT_ARRAY_PROPERTY(BASE_NS::string, MorphNames)
97 META_IMPLEMENT_ARRAY_PROPERTY(float, MorphWeights)
98 public:
99 BASE_NS::string GetName() const override;
100 };
101
102 SCENE_END_NAMESPACE()
103
104 #endif
105