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_NODE_MESH_NODE_H
17 #define SCENE_SRC_NODE_MESH_NODE_H
18
19 #include <scene/ext/intf_create_entity.h>
20 #include <scene/interface/intf_mesh.h>
21
22 #include "component/mesh_component.h"
23 #include "mesh/mesh.h"
24 #include "node.h"
25
SCENE_BEGIN_NAMESPACE()26 SCENE_BEGIN_NAMESPACE()
27
28 class MeshNode : public META_NS::IntroduceInterfaces<Node, IMesh, IMeshAccess, ICreateEntity, IMorphAccess> {
29 META_OBJECT(MeshNode, ClassId::MeshNode, IntroduceInterfaces)
30
31 public:
32 META_BEGIN_STATIC_DATA()
33 META_STATIC_FORWARDED_PROPERTY_DATA(IMesh, BASE_NS::Math::Vec3, AABBMin)
34 META_STATIC_FORWARDED_PROPERTY_DATA(IMesh, BASE_NS::Math::Vec3, AABBMax)
35 META_STATIC_FORWARDED_ARRAY_PROPERTY_DATA(IMesh, ISubMesh::Ptr, SubMeshes)
36 META_STATIC_PROPERTY_DATA(IMorphAccess, IMorpher::Ptr, Morpher)
37 META_END_STATIC_DATA()
38
39 META_FORWARD_READONLY_PROPERTY(BASE_NS::Math::Vec3, AABBMin, mesh_->AABBMin())
40 META_FORWARD_READONLY_PROPERTY(BASE_NS::Math::Vec3, AABBMax, mesh_->AABBMax())
41 META_FORWARD_READONLY_ARRAY_PROPERTY(ISubMesh::Ptr, SubMeshes, mesh_->SubMeshes())
42 META_IMPLEMENT_READONLY_PROPERTY(IMorpher::Ptr, Morpher)
43
44 Future<bool> SetMesh(const IMesh::Ptr&) override;
45 Future<IMesh::Ptr> GetMesh() const override;
46
47 bool SetEcsObject(const IEcsObject::Ptr&) override;
48
49 public:
50 CORE_NS::Entity CreateEntity(const IInternalScene::Ptr& scene) override;
51 void SetOwnedEntity(CORE_NS::Entity ent);
52
53 private:
54 bool Init(const IInternalRenderMesh::Ptr&);
55 bool Init(const IEcsObject::Ptr&);
56
57 private:
58 IMesh::Ptr mesh_;
59 };
60
61 SCENE_END_NAMESPACE()
62
63 #endif
64