• 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_MESH_SUBMESH_H
17 #define SCENE_SRC_MESH_SUBMESH_H
18 
19 #include <scene/interface/intf_mesh.h>
20 #include <scene/interface/intf_shader.h>
21 
22 #include <meta/ext/implementation_macros.h>
23 #include <meta/ext/object.h>
24 
25 #include "component/mesh_component.h"
26 #include "util_interfaces.h"
27 
SCENE_BEGIN_NAMESPACE()28 SCENE_BEGIN_NAMESPACE()
29 
30 class SubMesh : public META_NS::IntroduceInterfaces<EcsLazyProperty, ArrayElementIndex, META_NS::INotifyOnChange,
31                     META_NS::INamed, META_NS::IPropertyOwner, ISubMesh> {
32     META_OBJECT(SubMesh, ClassId::SubMesh, IntroduceInterfaces)
33 
34 public:
35     META_BEGIN_STATIC_DATA()
36     META_STATIC_PROPERTY_DATA(META_NS::INamed, BASE_NS::string, Name)
37     SCENE_STATIC_DYNINIT_PROPERTY_DATA(ISubMesh, IMaterial::Ptr, Material, "material")
38     SCENE_STATIC_DYNINIT_PROPERTY_DATA(ISubMesh, BASE_NS::Math::Vec3, AABBMin, "aabbMin")
39     SCENE_STATIC_DYNINIT_PROPERTY_DATA(ISubMesh, BASE_NS::Math::Vec3, AABBMax, "aabbMax")
40     META_END_STATIC_DATA()
41 
42     META_IMPLEMENT_PROPERTY(BASE_NS::string, Name)
43     META_IMPLEMENT_PROPERTY(IMaterial::Ptr, Material)
44     META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec3, AABBMin)
45     META_IMPLEMENT_PROPERTY(BASE_NS::Math::Vec3, AABBMax)
46 
47     bool InitDynamicProperty(const META_NS::IProperty::Ptr& p, BASE_NS::string_view path) override;
48     void OnPropertyChanged(const META_NS::IProperty&) override;
49 
50     BASE_NS::string GetName() const override
51     {
52         return META_NS::GetValue(Name());
53     }
54 
55     BASE_NS::shared_ptr<META_NS::IEvent> EventOnChanged(META_NS::MetadataQuery) const override
56     {
57         return event_;
58     }
59 
60 private:
61     BASE_NS::shared_ptr<META_NS::EventImpl<META_NS::IOnChanged>> event_ { new META_NS::EventImpl<META_NS::IOnChanged>(
62         "OnChanged") };
63 };
64 
65 SCENE_END_NAMESPACE()
66 
67 #endif