• 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 // clang-format off
17 #include <meta/interface/object_macros.h>
18 #include <meta/interface/intf_object_registry.h>
19 // clang-format on
20 
21 #include <scene/base/namespace.h>
22 
23 #include <3d/implementation_uids.h>
24 #include <core/intf_engine.h>
25 #include <core/plugin/intf_plugin.h>
26 #include <core/plugin/intf_plugin_register.h>
27 #include <render/implementation_uids.h>
28 
29 #include <meta/base/plugin.h>
30 
31 #include "asset/asset_object.h"
32 #include "bitmap.h"
33 #include "component/animation_component.h"
34 #include "component/camera_component.h"
35 #include "component/environment_component.h"
36 #include "component/generic_component.h"
37 #include "component/layer_component.h"
38 #include "component/light_component.h"
39 #include "component/material_component.h"
40 #include "component/mesh_component.h"
41 #include "component/node_component.h"
42 #include "component/postprocess_component.h"
43 #include "component/text_component.h"
44 #include "component/transform_component.h"
45 #include "core/ecs_object.h"
46 #include "ecs_animation.h"
47 #include "ecs_component/entity_owner_component_info.h"
48 #include "environment.h"
49 #include "mesh/material.h"
50 #include "mesh/mesh.h"
51 #include "mesh/mesh_creator.h"
52 #include "mesh/mesh_resource.h"
53 #include "mesh/shader.h"
54 #include "mesh/shader_util.h"
55 #include "mesh/submesh.h"
56 #include "mesh/texture.h"
57 #include "node/camera_node.h"
58 #include "node/light_node.h"
59 #include "node/mesh_node.h"
60 #include "node/node.h"
61 #include "node/text_node.h"
62 #include "postprocess/bloom.h"
63 #include "postprocess/postprocess.h"
64 #include "postprocess/tonemap.h"
65 #include "render_configuration.h"
66 #include "scene.h"
67 #include "scene_manager.h"
68 
69 static CORE_NS::IPluginRegister* gPluginRegistry { nullptr };
70 
CORE_BEGIN_NAMESPACE()71 CORE_BEGIN_NAMESPACE()
72 IPluginRegister& GetPluginRegister()
73 {
74     return *gPluginRegistry;
75 }
76 CORE_END_NAMESPACE()
77 
78 SCENE_BEGIN_NAMESPACE()
79 
80 void RegisterEngineAccess();
81 void UnregisterEngineAccess();
82 
83 using namespace CORE_NS;
84 
RegisterInterfaces(IPluginRegister & pluginRegistry)85 static PluginToken RegisterInterfaces(IPluginRegister& pluginRegistry)
86 {
87     // Initializing dynamic plugin.
88     // Plugin registry access via the provided registry instance which is saved here.
89     gPluginRegistry = &pluginRegistry;
90     pluginRegistry.RegisterTypeInfo(ENTITY_OWNER_COMPONENT_TYPE_INFO);
91 
92     RegisterEngineAccess();
93 
94     META_NS::RegisterObjectType<SceneManager>();
95     META_NS::RegisterObjectType<SceneObject>();
96 
97     META_NS::RegisterObjectType<Node>();
98     META_NS::RegisterObjectType<CameraNode>();
99     META_NS::RegisterObjectType<LightNode>();
100     META_NS::RegisterObjectType<MeshNode>();
101     META_NS::RegisterObjectType<TextNode>();
102 
103     META_NS::RegisterObjectType<GenericComponent>();
104     META_NS::RegisterObjectType<CameraComponent>();
105     META_NS::RegisterObjectType<TransformComponent>();
106     META_NS::RegisterObjectType<PostProcessComponent>();
107     META_NS::RegisterObjectType<AnimationComponent>();
108     META_NS::RegisterObjectType<EnvironmentComponent>();
109     META_NS::RegisterObjectType<LayerComponent>();
110     META_NS::RegisterObjectType<LightComponent>();
111     META_NS::RegisterObjectType<MaterialComponent>();
112     META_NS::RegisterObjectType<MeshComponent>();
113     META_NS::RegisterObjectType<RenderMeshComponent>();
114     META_NS::RegisterObjectType<NodeComponent>();
115     META_NS::RegisterObjectType<TextComponent>();
116 
117     META_NS::RegisterObjectType<EcsObject>();
118     META_NS::RegisterObjectType<Bitmap>();
119     META_NS::RegisterObjectType<Bloom>();
120     META_NS::RegisterObjectType<Tonemap>();
121     META_NS::RegisterObjectType<PostProcess>();
122 
123     META_NS::RegisterObjectType<Environment>();
124     META_NS::RegisterObjectType<EcsAnimation>();
125     META_NS::RegisterObjectType<RenderConfiguration>();
126     META_NS::RegisterObjectType<Material>();
127     META_NS::RegisterObjectType<Shader>();
128     META_NS::RegisterObjectType<ShaderUtil>();
129     META_NS::RegisterObjectType<SubMesh>();
130     META_NS::RegisterObjectType<Mesh>();
131     META_NS::RegisterObjectType<MeshCreator>();
132     META_NS::RegisterObjectType<MeshResource>();
133     META_NS::RegisterObjectType<Texture>();
134 
135     META_NS::RegisterObjectType<AssetObject>();
136 
137     return {};
138 }
UnregisterInterfaces(PluginToken)139 static void UnregisterInterfaces(PluginToken)
140 {
141     META_NS::UnregisterObjectType<SceneManager>();
142     META_NS::UnregisterObjectType<SceneObject>();
143 
144     META_NS::UnregisterObjectType<Node>();
145     META_NS::UnregisterObjectType<CameraNode>();
146     META_NS::UnregisterObjectType<LightNode>();
147     META_NS::UnregisterObjectType<MeshNode>();
148     META_NS::UnregisterObjectType<TextNode>();
149 
150     META_NS::UnregisterObjectType<GenericComponent>();
151     META_NS::UnregisterObjectType<CameraComponent>();
152     META_NS::UnregisterObjectType<TransformComponent>();
153     META_NS::UnregisterObjectType<PostProcessComponent>();
154     META_NS::UnregisterObjectType<AnimationComponent>();
155     META_NS::UnregisterObjectType<EnvironmentComponent>();
156     META_NS::UnregisterObjectType<LayerComponent>();
157     META_NS::UnregisterObjectType<LightComponent>();
158     META_NS::UnregisterObjectType<MaterialComponent>();
159     META_NS::UnregisterObjectType<MeshComponent>();
160     META_NS::UnregisterObjectType<RenderMeshComponent>();
161     META_NS::UnregisterObjectType<NodeComponent>();
162     META_NS::UnregisterObjectType<TextComponent>();
163 
164     META_NS::UnregisterObjectType<EcsObject>();
165     META_NS::UnregisterObjectType<Bitmap>();
166     META_NS::UnregisterObjectType<Bloom>();
167     META_NS::UnregisterObjectType<Tonemap>();
168     META_NS::UnregisterObjectType<PostProcess>();
169 
170     META_NS::UnregisterObjectType<Environment>();
171     META_NS::UnregisterObjectType<EcsAnimation>();
172     META_NS::UnregisterObjectType<RenderConfiguration>();
173     META_NS::UnregisterObjectType<Material>();
174     META_NS::UnregisterObjectType<Shader>();
175     META_NS::UnregisterObjectType<ShaderUtil>();
176     META_NS::UnregisterObjectType<SubMesh>();
177     META_NS::UnregisterObjectType<Mesh>();
178     META_NS::UnregisterObjectType<MeshCreator>();
179     META_NS::UnregisterObjectType<MeshResource>();
180     META_NS::UnregisterObjectType<Texture>();
181 
182     META_NS::UnregisterObjectType<AssetObject>();
183 
184     UnregisterEngineAccess();
185 
186     // remove all weak refs still in the object registry referring to scene
187     META_NS::GetObjectRegistry().Purge();
188 
189     GetPluginRegister().UnregisterTypeInfo(ENTITY_OWNER_COMPONENT_TYPE_INFO);
190 }
VersionString()191 static const char* VersionString()
192 {
193     return "2.0";
194 }
195 
196 const BASE_NS::Uid plugin_deps[] { RENDER_NS::UID_RENDER_PLUGIN, CORE3D_NS::UID_3D_PLUGIN,
197     META_NS::META_OBJECT_PLUGIN_UID };
198 
SCENE_END_NAMESPACE()199 SCENE_END_NAMESPACE()
200 
201 extern "C" {
202 #if _MSC_VER
203 _declspec(dllexport)
204 #else
205 __attribute__((visibility("default")))
206 #endif
207     CORE_NS::IPlugin gPluginData { { CORE_NS::IPlugin::UID }, "Scene",
208         /** Version information of the plugin. */
209         CORE_NS::Version { SCENE_NS::UID_SCENE_PLUGIN, SCENE_NS::VersionString }, SCENE_NS::RegisterInterfaces,
210         SCENE_NS::UnregisterInterfaces, SCENE_NS::plugin_deps };
211 }
212