• 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_SCENE_H
17 #define SCENE_SRC_SCENE_H
18 
19 #include <scene/ext/ecs_lazy_property_fwd.h>
20 #include <scene/ext/scene_property.h>
21 #include <scene/interface/intf_raycast.h>
22 #include <scene/interface/intf_scene.h>
23 
24 #include <meta/ext/implementation_macros.h>
25 #include <meta/ext/object.h>
26 #include <meta/interface/intf_task_queue.h>
27 
28 #include "core/internal_scene.h"
29 
SCENE_BEGIN_NAMESPACE()30 SCENE_BEGIN_NAMESPACE()
31 
32 class SceneObject : public META_NS::IntroduceInterfaces<META_NS::MetaObject, IScene, IEnginePropertyInit, IRayCast> {
33     META_OBJECT(SceneObject, SCENE_NS::ClassId::Scene, IntroduceInterfaces)
34 
35 public:
36     SceneObject() = default;
37     ~SceneObject();
38 
39     META_BEGIN_STATIC_DATA()
40     SCENE_STATIC_DYNINIT_PROPERTY_DATA(IScene, SCENE_NS::IRenderConfiguration::Ptr, RenderConfiguration, "")
41     META_END_STATIC_DATA()
42 
43     META_IMPLEMENT_READONLY_PROPERTY(IRenderConfiguration::Ptr, RenderConfiguration)
44 
45 public:
46     bool Build(const META_NS::IMetadata::Ptr&) override;
47     bool InitDynamicProperty(const META_NS::IProperty::Ptr& p, BASE_NS::string_view path) override;
48     bool AttachEngineProperty(const META_NS::IProperty::Ptr& p, BASE_NS::string_view path) override;
49 
50     Future<BASE_NS::vector<ICamera::Ptr>> GetCameras() const override;
51     Future<BASE_NS::vector<META_NS::IAnimation::Ptr>> GetAnimations() const override;
52 
53     Future<INode::Ptr> GetRootNode() const override;
54     Future<INode::Ptr> CreateNode(const BASE_NS::string_view path, META_NS::ObjectId id) override;
55     Future<INode::Ptr> FindNode(BASE_NS::string_view path, META_NS::ObjectId id) const override;
56     Future<bool> ReleaseNode(INode::Ptr&& node, bool recursive) override;
57     Future<bool> RemoveNode(const INode::Ptr& node) override;
58 
59     using Super::CreateObject;
60     Future<META_NS::IObject::Ptr> CreateObject(META_NS::ObjectId id) override;
61 
62     void StartAutoUpdate(META_NS::TimeSpan interval) override;
63 
64     Future<bool> SetRenderMode(RenderMode) override;
65     Future<RenderMode> GetRenderMode() const override;
66     Future<NodeHits> CastRay(
67         const BASE_NS::Math::Vec3& pos, const BASE_NS::Math::Vec3& dir, const RayCastOptions& options) const override;
68 public:
69     IInternalScene::Ptr GetInternalScene() const override;
70 
71 private:
72     IInternalScene::Ptr internal_;
73     META_NS::ITaskQueue::Token updateTask_ {};
74 };
75 
76 SCENE_END_NAMESPACE()
77 
78 #endif