• 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 #include <scene/base/namespace.h>
17 #include <scene/interface/intf_camera.h>
18 #include <scene/interface/intf_environment.h>
19 #include <scene/interface/intf_light.h>
20 #include <scene/interface/intf_material.h>
21 #include <scene/interface/intf_text.h>
22 #include <text_3d/ecs/components/text_component.h>
23 
24 #include <3d/ecs/components/animation_component.h>
25 #include <3d/ecs/components/animation_state_component.h>
26 #include <3d/ecs/components/camera_component.h>
27 #include <3d/ecs/components/environment_component.h>
28 #include <3d/ecs/components/light_component.h>
29 #include <3d/ecs/components/material_component.h>
30 #include <3d/ecs/components/mesh_component.h>
31 #include <3d/ecs/components/post_process_component.h>
32 
33 #include <meta/base/namespace.h>
34 #include <meta/ext/any_builder.h>
35 #include <meta/ext/engine/internal_access.h>
36 #include <meta/interface/engine/intf_engine_data.h>
37 #include <meta/interface/intf_object_registry.h>
38 
39 using CORE3D_NS::EnvironmentComponent;
40 using CORE3D_NS::LightComponent;
41 using CORE3D_NS::MaterialComponent;
42 using CORE3D_NS::MeshComponent;
43 using Submesh = MeshComponent::Submesh;
44 using BASE_NS::Format;
45 using BASE_NS::vector;
46 using CORE3D_NS::AnimationComponent;
47 using CORE3D_NS::AnimationStateComponent;
48 using CORE3D_NS::CameraComponent;
49 
50 using RENDER_NS::BloomConfiguration;
51 using RENDER_NS::BlurConfiguration;
52 using RENDER_NS::ColorConversionConfiguration;
53 using RENDER_NS::ColorFringeConfiguration;
54 using RENDER_NS::DitherConfiguration;
55 using RENDER_NS::DofConfiguration;
56 using RENDER_NS::FxaaConfiguration;
57 using RENDER_NS::MotionBlurConfiguration;
58 using RENDER_NS::TaaConfiguration;
59 using RENDER_NS::TonemapConfiguration;
60 using RENDER_NS::VignetteConfiguration;
61 using TEXT3D_NS::TextComponent;
62 
63 CORE_BEGIN_NAMESPACE()
64 DECLARE_PROPERTY_TYPE(EnvironmentComponent::Background);
65 DECLARE_PROPERTY_TYPE(LightComponent::Type);
66 DECLARE_PROPERTY_TYPE(MaterialComponent::Type);
67 DECLARE_PROPERTY_TYPE(MaterialComponent::RenderSort);
68 DECLARE_PROPERTY_TYPE(MaterialComponent::Shader);
69 DECLARE_PROPERTY_TYPE(MaterialComponent::TextureInfo);
70 DECLARE_PROPERTY_TYPE(MaterialComponent::TextureTransform);
71 
72 DECLARE_PROPERTY_TYPE(TonemapConfiguration);
73 DECLARE_PROPERTY_TYPE(TonemapConfiguration::TonemapType);
74 DECLARE_PROPERTY_TYPE(BloomConfiguration);
75 DECLARE_PROPERTY_TYPE(BloomConfiguration::BloomType);
76 DECLARE_PROPERTY_TYPE(BloomConfiguration::BloomQualityType);
77 DECLARE_PROPERTY_TYPE(BlurConfiguration);
78 DECLARE_PROPERTY_TYPE(ColorConversionConfiguration);
79 DECLARE_PROPERTY_TYPE(ColorFringeConfiguration);
80 DECLARE_PROPERTY_TYPE(DitherConfiguration);
81 DECLARE_PROPERTY_TYPE(DofConfiguration);
82 DECLARE_PROPERTY_TYPE(FxaaConfiguration);
83 DECLARE_PROPERTY_TYPE(MotionBlurConfiguration);
84 DECLARE_PROPERTY_TYPE(TaaConfiguration);
85 DECLARE_PROPERTY_TYPE(VignetteConfiguration);
86 
87 DECLARE_PROPERTY_TYPE(vector<MeshComponent::Submesh>);
88 DECLARE_PROPERTY_TYPE(AnimationComponent::PlaybackState);
89 DECLARE_PROPERTY_TYPE(BASE_NS::vector<AnimationStateComponent::TrackState>);
90 DECLARE_PROPERTY_TYPE(CameraComponent::RenderingPipeline);
91 DECLARE_PROPERTY_TYPE(CameraComponent::Culling);
92 DECLARE_PROPERTY_TYPE(CameraComponent::Projection);
93 DECLARE_PROPERTY_TYPE(CameraComponent::TargetUsage);
94 DECLARE_PROPERTY_TYPE(vector<CameraComponent::TargetUsage>);
95 DECLARE_PROPERTY_TYPE(Format);
96 
97 DECLARE_PROPERTY_TYPE(TextComponent::FontMethod);
98 CORE_END_NAMESPACE()
99 
100 META_TYPE(CORE3D_NS::EnvironmentComponent::Background);
101 META_TYPE(CORE3D_NS::LightComponent::Type);
102 META_TYPE(CORE3D_NS::MaterialComponent::Type);
103 META_TYPE(CORE3D_NS::MaterialComponent::RenderSort);
104 META_TYPE(CORE3D_NS::MaterialComponent::Shader);
105 META_TYPE(CORE3D_NS::MaterialComponent::TextureInfo);
106 META_TYPE(CORE3D_NS::MaterialComponent::TextureTransform);
107 
108 META_TYPE(RENDER_NS::TonemapConfiguration);
109 META_TYPE(RENDER_NS::TonemapConfiguration::TonemapType);
110 META_TYPE(RENDER_NS::BloomConfiguration);
111 META_TYPE(RENDER_NS::BloomConfiguration::BloomType);
112 META_TYPE(RENDER_NS::BloomConfiguration::BloomQualityType);
113 META_TYPE(RENDER_NS::BlurConfiguration);
114 META_TYPE(RENDER_NS::ColorConversionConfiguration);
115 META_TYPE(RENDER_NS::ColorFringeConfiguration);
116 META_TYPE(RENDER_NS::DitherConfiguration);
117 META_TYPE(RENDER_NS::DofConfiguration);
118 META_TYPE(RENDER_NS::FxaaConfiguration);
119 META_TYPE(RENDER_NS::MotionBlurConfiguration);
120 META_TYPE(RENDER_NS::TaaConfiguration);
121 META_TYPE(RENDER_NS::VignetteConfiguration);
122 META_TYPE(RENDER_NS::RenderHandle)
123 
124 META_TYPE(CORE3D_NS::MeshComponent::Submesh)
125 META_TYPE(CORE3D_NS::AnimationComponent::PlaybackState);
126 META_TYPE(CORE3D_NS::AnimationStateComponent::TrackState);
127 META_TYPE(CORE3D_NS::CameraComponent::RenderingPipeline);
128 META_TYPE(CORE3D_NS::CameraComponent::Culling);
129 META_TYPE(CORE3D_NS::CameraComponent::Projection);
130 META_TYPE(CORE3D_NS::CameraComponent::TargetUsage);
131 
132 META_TYPE(TEXT3D_NS::TextComponent::FontMethod);
133 
134 SCENE_BEGIN_NAMESPACE()
135 
136 namespace Internal {
137 
138 template<typename Prop>
RegisterEngineAccessImpl()139 void RegisterEngineAccessImpl()
140 {
141     static_assert(CORE_NS::PropertySystem::is_defined<Prop>().value);
142     META_NS::GetObjectRegistry().GetEngineData().RegisterInternalValueAccess(
143         META_NS::MetaType<Prop>::coreType, CreateShared<META_NS::EngineInternalValueAccess<Prop>>());
144 }
145 
146 template<typename Prop>
RegisterEngineArrayAccessImpl()147 void RegisterEngineArrayAccessImpl()
148 {
149     static_assert(CORE_NS::PropertySystem::is_defined<Prop>().value);
150     META_NS::GetObjectRegistry().GetEngineData().RegisterInternalValueAccess(
151         META_NS::MetaType<Prop[]>::coreType, CreateShared<META_NS::EngineInternalArrayValueAccess<Prop>>());
152 }
153 
154 template<typename Prop>
RegisterEngineAccessImplAndAny()155 void RegisterEngineAccessImplAndAny()
156 {
157     META_NS::GetObjectRegistry().GetPropertyRegister().RegisterAny(
158         CreateShared<META_NS::DefaultAnyBuilder<META_NS::Any<Prop>>>());
159     RegisterEngineAccessImpl<Prop>();
160 }
161 
162 template<typename Prop, typename AccessType>
RegisterMapEngineAccessImpl()163 void RegisterMapEngineAccessImpl()
164 {
165     static_assert(CORE_NS::PropertySystem::is_defined<Prop>().value);
166 
167     auto& r = META_NS::GetObjectRegistry();
168     r.GetEngineData().RegisterInternalValueAccess(
169         META_NS::MetaType<Prop>::coreType, CreateShared<META_NS::EngineInternalValueAccess<Prop, AccessType>>());
170 }
171 
172 template<typename Prop>
UnregisterEngineAccessImpl()173 void UnregisterEngineAccessImpl()
174 {
175     META_NS::GetObjectRegistry().GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<Prop>::coreType);
176 }
177 
178 template<typename Prop>
UnregisterEngineArrayAccessImpl()179 void UnregisterEngineArrayAccessImpl()
180 {
181     META_NS::GetObjectRegistry().GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<Prop[]>::coreType);
182 }
183 
184 template<typename Prop>
UnregisterEngineAccessImplAndAny()185 void UnregisterEngineAccessImplAndAny()
186 {
187     UnregisterEngineAccessImpl<Prop>();
188     META_NS::GetObjectRegistry().GetPropertyRegister().UnregisterAny(META_NS::Any<Prop>::StaticGetClassId());
189 }
190 
RegisterEngineAccess()191 void RegisterEngineAccess()
192 {
193     static_assert(CORE_NS::PropertySystem::is_defined<EnvironmentComponent::Background>().value);
194 
195     RegisterMapEngineAccessImpl<CameraComponent::Projection, CameraProjection>();
196     RegisterMapEngineAccessImpl<CameraComponent::Culling, CameraCulling>();
197     RegisterMapEngineAccessImpl<CameraComponent::RenderingPipeline, CameraPipeline>();
198 
199     RegisterMapEngineAccessImpl<EnvironmentComponent::Background, EnvBackgroundType>();
200     RegisterMapEngineAccessImpl<LightComponent::Type, LightType>();
201     RegisterMapEngineAccessImpl<MaterialComponent::Type, MaterialType>();
202     RegisterMapEngineAccessImpl<TonemapConfiguration::TonemapType, TonemapType>();
203     RegisterMapEngineAccessImpl<BloomConfiguration::BloomType, BloomType>();
204     RegisterMapEngineAccessImpl<BloomConfiguration::BloomQualityType, EffectQualityType>();
205     RegisterMapEngineAccessImpl<TextComponent::FontMethod, SCENE_NS::FontMethod>();
206 
207     RegisterEngineAccessImplAndAny<MaterialComponent::RenderSort>();
208     RegisterEngineAccessImplAndAny<MaterialComponent::Shader>();
209     RegisterEngineAccessImplAndAny<MaterialComponent::TextureInfo>();
210     RegisterEngineAccessImplAndAny<MaterialComponent::TextureTransform>();
211 
212     RegisterEngineAccessImpl<BloomConfiguration>();
213     RegisterEngineAccessImpl<BlurConfiguration>();
214     RegisterEngineAccessImpl<ColorConversionConfiguration>();
215     RegisterEngineAccessImpl<ColorFringeConfiguration>();
216     RegisterEngineAccessImpl<DitherConfiguration>();
217     RegisterEngineAccessImpl<DofConfiguration>();
218     RegisterEngineAccessImpl<FxaaConfiguration>();
219     RegisterEngineAccessImpl<MotionBlurConfiguration>();
220     RegisterEngineAccessImpl<TaaConfiguration>();
221     RegisterEngineAccessImpl<TonemapConfiguration>();
222     RegisterEngineAccessImpl<VignetteConfiguration>();
223     RegisterEngineAccessImpl<RENDER_NS::RenderHandle>();
224 
225     RegisterEngineAccessImpl<BASE_NS::vector<Submesh>>();
226     RegisterEngineAccessImpl<BASE_NS::vector<AnimationStateComponent::TrackState>>();
227     RegisterEngineAccessImpl<BASE_NS::vector<CameraComponent::TargetUsage>>();
228     RegisterEngineAccessImpl<AnimationComponent::PlaybackState>();
229     RegisterEngineArrayAccessImpl<MaterialComponent::TextureInfo>();
230 }
UnregisterEngineAccess()231 void UnregisterEngineAccess()
232 {
233     UnregisterEngineArrayAccessImpl<MaterialComponent::TextureInfo>();
234     UnregisterEngineAccessImpl<BASE_NS::vector<CameraComponent::TargetUsage>>();
235     UnregisterEngineAccessImpl<BASE_NS::vector<AnimationStateComponent::TrackState>>();
236     UnregisterEngineAccessImpl<BASE_NS::vector<Submesh>>();
237 
238     UnregisterEngineAccessImpl<BloomConfiguration>();
239     UnregisterEngineAccessImpl<BlurConfiguration>();
240     UnregisterEngineAccessImpl<ColorConversionConfiguration>();
241     UnregisterEngineAccessImpl<ColorFringeConfiguration>();
242     UnregisterEngineAccessImpl<DitherConfiguration>();
243     UnregisterEngineAccessImpl<DofConfiguration>();
244     UnregisterEngineAccessImpl<FxaaConfiguration>();
245     UnregisterEngineAccessImpl<MotionBlurConfiguration>();
246     UnregisterEngineAccessImpl<TaaConfiguration>();
247     UnregisterEngineAccessImpl<TonemapConfiguration>();
248     UnregisterEngineAccessImpl<VignetteConfiguration>();
249     UnregisterEngineAccessImpl<RENDER_NS::RenderHandle>();
250 
251     UnregisterEngineAccessImplAndAny<MaterialComponent::RenderSort>();
252     UnregisterEngineAccessImplAndAny<MaterialComponent::Shader>();
253     UnregisterEngineAccessImplAndAny<MaterialComponent::TextureInfo>();
254     UnregisterEngineAccessImplAndAny<MaterialComponent::TextureTransform>();
255 
256     auto& r = META_NS::GetObjectRegistry();
257     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<BloomConfiguration::BloomType>::coreType);
258     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<BloomConfiguration::BloomQualityType>::coreType);
259     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<TonemapConfiguration::TonemapType>::coreType);
260     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<MaterialComponent::Type>::coreType);
261     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<LightComponent::Type>::coreType);
262     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<EnvironmentComponent::Background>::coreType);
263     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<AnimationComponent::PlaybackState>::coreType);
264     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<CameraComponent::RenderingPipeline>::coreType);
265     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<CameraComponent::Culling>::coreType);
266     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<CameraComponent::Projection>::coreType);
267 
268     r.GetEngineData().UnregisterInternalValueAccess(META_NS::MetaType<TextComponent::FontMethod>::coreType);
269 }
270 
271 } // namespace Internal
272 SCENE_END_NAMESPACE()
273