• 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_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> {
29     META_OBJECT(MeshNode, ClassId::MeshNode, IntroduceInterfaces)
30 
31 public:
32     META_FORWARD_PROPERTY(IMaterial::Ptr, MaterialOverride, mesh_->MaterialOverride())
33 
34 
35     META_FORWARD_READONLY_PROPERTY(BASE_NS::Math::Vec3, AABBMin, mesh_->AABBMin())
36     META_FORWARD_READONLY_PROPERTY(BASE_NS::Math::Vec3, AABBMax, mesh_->AABBMax())
37 
38     Future<BASE_NS::vector<ISubMesh::Ptr>> GetSubmeshes() const override;
39     Future<bool> SetSubmeshes(const BASE_NS::vector<ISubMesh::Ptr>&) override;
40 
41     Future<bool> SetMesh(const IMesh::Ptr&) override;
42     Future<IMesh::Ptr> GetMesh() const override;
43     bool SetEcsObject(const IEcsObject::Ptr&) override;
44 
45 public:
46     CORE_NS::Entity CreateEntity(const IInternalScene::Ptr& scene) override;
47     void SetOwnedEntity(CORE_NS::Entity ent);
48 
49 private:
50     bool Init(IInternalRenderMesh::Ptr);
51     bool Init(IEcsObject::Ptr);
52 
53 private:
54     IMesh::Ptr mesh_;
55 };
56 
57 SCENE_END_NAMESPACE()
58 
59 #endif