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_INTERFACE_ISCENE_H 17 #define SCENE_INTERFACE_ISCENE_H 18 19 #include <scene/base/types.h> 20 #include <scene/interface/intf_camera.h> 21 #include <scene/interface/intf_node.h> 22 #include <scene/interface/intf_render_configuration.h> 23 24 #include <render/intf_render_context.h> 25 26 #include <meta/base/interface_macros.h> 27 #include <meta/interface/animation/intf_animation.h> 28 29 SCENE_BEGIN_NAMESPACE() 30 31 class IInternalScene; 32 33 class IScene : public CORE_NS::IInterface { 34 META_INTERFACE(CORE_NS::IInterface, IScene, "b61d5521-bfa9-4465-9e4d-65d4358ede26") 35 public: 36 META_READONLY_PROPERTY(IRenderConfiguration::Ptr, RenderConfiguration) 37 38 public: 39 virtual Future<INode::Ptr> GetRootNode() const = 0; 40 virtual Future<INode::Ptr> CreateNode(BASE_NS::string_view path, META_NS::ObjectId id = {}) = 0; 41 virtual Future<INode::Ptr> FindNode(BASE_NS::string_view path, META_NS::ObjectId id = {}) const = 0; 42 virtual Future<bool> ReleaseNode(INode::Ptr&& node, bool recursive) = 0; 43 virtual Future<bool> RemoveNode(const INode::Ptr& node) = 0; 44 45 template<class T> 46 Future<typename T::Ptr> CreateNode(BASE_NS::string_view path, META_NS::ObjectId id = {}) 47 { 48 return CreateNode(path, id).Then([](INode::Ptr d) { return interface_pointer_cast<T>(d); }, nullptr); 49 } 50 51 template<class T> 52 Future<typename T::Ptr> FindNode(BASE_NS::string_view path, META_NS::ObjectId id = {}) const 53 { 54 return FindNode(path, id).Then([](INode::Ptr d) { return interface_pointer_cast<T>(d); }, nullptr); 55 } 56 57 virtual Future<META_NS::IObject::Ptr> CreateObject(META_NS::ObjectId id) = 0; 58 59 template<class T> CreateObject(META_NS::ObjectId id)60 Future<typename T::Ptr> CreateObject(META_NS::ObjectId id) 61 { 62 return CreateObject(id).Then([](META_NS::IObject::Ptr d) { return interface_pointer_cast<T>(d); }, nullptr); 63 } 64 65 virtual Future<BASE_NS::vector<ICamera::Ptr>> GetCameras() const = 0; 66 virtual Future<BASE_NS::vector<META_NS::IAnimation::Ptr>> GetAnimations() const = 0; 67 68 virtual BASE_NS::shared_ptr<IInternalScene> GetInternalScene() const = 0; 69 70 virtual void StartAutoUpdate(META_NS::TimeSpan interval) = 0; 71 virtual Future<bool> SetRenderMode(RenderMode) = 0; 72 virtual Future<RenderMode> GetRenderMode() const = 0; 73 }; 74 75 META_REGISTER_CLASS(Scene, "ef6321d7-071c-414a-bb3d-55ea6f94688e", META_NS::ObjectCategoryBits::NO_CATEGORY) 76 77 SCENE_END_NAMESPACE() 78 79 META_INTERFACE_TYPE(SCENE_NS::IScene) 80 META_TYPE(BASE_NS::shared_ptr<RENDER_NS::IRenderContext>) 81 82 #endif 83