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