1 /*
2 * Copyright (C) 2023 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 #if !defined(RENDER_MESH_COMPONENT) || defined(IMPLEMENT_MANAGER)
17 #define RENDER_MESH_COMPONENT
18
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/math/vector.h>
22 #include <core/ecs/component_struct_macros.h>
23 #include <core/ecs/entity.h>
24 #include <core/ecs/intf_component_manager.h>
25 #include <core/property/property_types.h>
26
27 CORE3D_BEGIN_NAMESPACE()
28 #endif
29 /** Render Mesh component can be used to associate a mesh with an object, and is used by the rendering system.
30 */
BEGIN_COMPONENT(IRenderMeshComponentManager,RenderMeshComponent)31 BEGIN_COMPONENT(IRenderMeshComponentManager, RenderMeshComponent)
32 #if !defined(IMPLEMENT_MANAGER)
33 /** Additional custom data size which is bind with render mesh structure to shader
34 * Should match api/shaders/common/3d_dm_structures_common.h DefaultMaterialSingleMeshStruct customData
35 */
36 static constexpr uint32_t RENDER_MESH_CUSTOM_DATA_VEC4_COUNT { 2u };
37 #endif
38 /** Mesh entity. */
39 DEFINE_PROPERTY(CORE_NS::Entity, mesh, "Mesh", 0,)
40
41 /** Render mesh batch entity. */
42 DEFINE_PROPERTY(CORE_NS::Entity, renderMeshBatch, "Render mesh batch", 0,)
43
44 /** Additional per render mesh custom data for shader customization */
45 DEFINE_ARRAY_PROPERTY(BASE_NS::Math::UVec4, RENDER_MESH_CUSTOM_DATA_VEC4_COUNT, customData,
46 "Additional shader custom data", 0, ARRAY_VALUE({ 0u, 0u, 0u, 0u }))
47 END_COMPONENT(IRenderMeshComponentManager, RenderMeshComponent, "311f8817-1878-4363-a6e6-68cc2299ea8d")
48 #if !defined(IMPLEMENT_MANAGER)
49 CORE3D_END_NAMESPACE()
50 #endif
51
52 #endif
53