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_MATERIAL_COMPONENT_H
17 #define SCENE_SRC_COMPONENT_MATERIAL_COMPONENT_H
18
19 #include <scene/ext/component_fwd.h>
20 #include <scene/interface/intf_material.h>
21
22 #include <3d/ecs/components/material_component.h>
23
24 #include <meta/ext/object.h>
25
26 META_TYPE(CORE3D_NS::MaterialComponent::Type)
META_TYPE(CORE3D_NS::MaterialComponent::Shader)27 META_TYPE(CORE3D_NS::MaterialComponent::Shader)
28 META_TYPE(CORE3D_NS::MaterialComponent::TextureInfo)
29 META_TYPE(CORE3D_NS::MaterialComponent::RenderSort)
30
31 SCENE_BEGIN_NAMESPACE()
32
33 class IInternalMaterial : public CORE_NS::IInterface {
34 META_INTERFACE(CORE_NS::IInterface, IInternalMaterial, "63a98b32-f062-42d0-81f7-490f3290df8a")
35 public:
36 META_PROPERTY(MaterialType, Type)
37 META_PROPERTY(float, AlphaCutoff)
38 META_PROPERTY(uint32_t, LightingFlags)
39 META_PROPERTY(CORE3D_NS::MaterialComponent::RenderSort, RenderSort)
40
41 META_PROPERTY(CORE3D_NS::MaterialComponent::Shader, MaterialShader)
42 META_PROPERTY(CORE3D_NS::MaterialComponent::Shader, DepthShader)
43
44 META_ARRAY_PROPERTY(CORE3D_NS::MaterialComponent::TextureInfo, Textures)
45
46 META_PROPERTY(uint32_t, UseTexcoordSetBit)
47 META_PROPERTY(uint32_t, CustomRenderSlotId)
48
49 META_ARRAY_PROPERTY(CORE_NS::EntityReference, CustomResources)
50 META_PROPERTY(CORE_NS::IPropertyHandle*, CustomProperties)
51 };
52
53 META_REGISTER_CLASS(MaterialComponent, "bc819033-2a5b-4182-bc7a-365ff8e33822", META_NS::ObjectCategoryBits::NO_CATEGORY)
54
55 class MaterialComponent : public META_NS::IntroduceInterfaces<ComponentFwd, IInternalMaterial> {
56 META_OBJECT(MaterialComponent, ClassId::MaterialComponent, IntroduceInterfaces)
57
58 public:
59 META_BEGIN_STATIC_DATA()
60 SCENE_STATIC_PROPERTY_DATA(IInternalMaterial, MaterialType, Type, "MaterialComponent.type")
61 SCENE_STATIC_PROPERTY_DATA(IInternalMaterial, float, AlphaCutoff, "MaterialComponent.alphaCutoff")
62 SCENE_STATIC_PROPERTY_DATA(IInternalMaterial, uint32_t, LightingFlags, "MaterialComponent.materialLightingFlags")
63 SCENE_STATIC_PROPERTY_DATA(
64 IInternalMaterial, CORE3D_NS::MaterialComponent::RenderSort, RenderSort, "MaterialComponent.renderSort")
65
66 SCENE_STATIC_PROPERTY_DATA(
67 IInternalMaterial, CORE3D_NS::MaterialComponent::Shader, MaterialShader, "MaterialComponent.materialShader")
68 SCENE_STATIC_PROPERTY_DATA(
69 IInternalMaterial, CORE3D_NS::MaterialComponent::Shader, DepthShader, "MaterialComponent.depthShader")
70
71 SCENE_STATIC_ARRAY_PROPERTY_DATA(
72 IInternalMaterial, CORE3D_NS::MaterialComponent::TextureInfo, Textures, "MaterialComponent.textures")
73
74 SCENE_STATIC_PROPERTY_DATA(IInternalMaterial, uint32_t, UseTexcoordSetBit, "MaterialComponent.useTexcoordSetBit")
75 SCENE_STATIC_PROPERTY_DATA(IInternalMaterial, uint32_t, CustomRenderSlotId, "MaterialComponent.customRenderSlotId")
76
77 SCENE_STATIC_ARRAY_PROPERTY_DATA(
78 IInternalMaterial, CORE_NS::EntityReference, CustomResources, "MaterialComponent.customResources")
79 SCENE_STATIC_PROPERTY_DATA(
80 IInternalMaterial, CORE_NS::IPropertyHandle*, CustomProperties, "MaterialComponent.customProperties")
81 META_END_STATIC_DATA()
82
83 META_IMPLEMENT_PROPERTY(MaterialType, Type)
84 META_IMPLEMENT_PROPERTY(float, AlphaCutoff)
85 META_IMPLEMENT_PROPERTY(uint32_t, LightingFlags)
86 META_IMPLEMENT_PROPERTY(CORE3D_NS::MaterialComponent::RenderSort, RenderSort)
87
88 META_IMPLEMENT_PROPERTY(CORE3D_NS::MaterialComponent::Shader, MaterialShader)
89 META_IMPLEMENT_PROPERTY(CORE3D_NS::MaterialComponent::Shader, DepthShader)
90
91 META_IMPLEMENT_ARRAY_PROPERTY(CORE3D_NS::MaterialComponent::TextureInfo, Textures)
92
93 META_IMPLEMENT_PROPERTY(uint32_t, UseTexcoordSetBit)
94 META_IMPLEMENT_PROPERTY(uint32_t, CustomRenderSlotId)
95
96 META_IMPLEMENT_ARRAY_PROPERTY(CORE_NS::EntityReference, CustomResources)
97 META_IMPLEMENT_PROPERTY(CORE_NS::IPropertyHandle*, CustomProperties)
98
99 public:
100 BASE_NS::string GetName() const override;
101 };
102
103 SCENE_END_NAMESPACE()
104
105 #endif