18bf80f4bSopenharmony_ci/* 28bf80f4bSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License. 58bf80f4bSopenharmony_ci * You may obtain a copy of the License at 68bf80f4bSopenharmony_ci * 78bf80f4bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88bf80f4bSopenharmony_ci * 98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and 138bf80f4bSopenharmony_ci * limitations under the License. 148bf80f4bSopenharmony_ci */ 158bf80f4bSopenharmony_ci#ifndef CORE_GLTF_GLTF2_H 168bf80f4bSopenharmony_ci#define CORE_GLTF_GLTF2_H 178bf80f4bSopenharmony_ci 188bf80f4bSopenharmony_ci#include <3d/gltf/gltf.h> 198bf80f4bSopenharmony_ci#include <3d/loaders/intf_scene_loader.h> 208bf80f4bSopenharmony_ci#include <core/namespace.h> 218bf80f4bSopenharmony_ci#include <render/namespace.h> 228bf80f4bSopenharmony_ci 238bf80f4bSopenharmony_ciCORE_BEGIN_NAMESPACE() 248bf80f4bSopenharmony_ciclass IEcs; 258bf80f4bSopenharmony_ciclass IEngine; 268bf80f4bSopenharmony_ciclass IFileManager; 278bf80f4bSopenharmony_ciCORE_END_NAMESPACE() 288bf80f4bSopenharmony_ci 298bf80f4bSopenharmony_ciRENDER_BEGIN_NAMESPACE() 308bf80f4bSopenharmony_ciclass IRenderContext; 318bf80f4bSopenharmony_ciRENDER_END_NAMESPACE() 328bf80f4bSopenharmony_ci 338bf80f4bSopenharmony_ciCORE3D_BEGIN_NAMESPACE() 348bf80f4bSopenharmony_ciclass IGraphicsContext; 358bf80f4bSopenharmony_ci 368bf80f4bSopenharmony_ci// implementation of public api.. 378bf80f4bSopenharmony_ciclass Gltf2 final : public IGltf2, ISceneLoader { 388bf80f4bSopenharmony_cipublic: 398bf80f4bSopenharmony_ci explicit Gltf2(IGraphicsContext& graphicsContext); 408bf80f4bSopenharmony_ci // allows for partial initialization. (used by tests) 418bf80f4bSopenharmony_ci explicit Gltf2(CORE_NS::IFileManager& fileManager); 428bf80f4bSopenharmony_ci ~Gltf2() override = default; 438bf80f4bSopenharmony_ci 448bf80f4bSopenharmony_ci // IGltf2 458bf80f4bSopenharmony_ci GLTFLoadResult LoadGLTF(BASE_NS::string_view uri) override; 468bf80f4bSopenharmony_ci GLTFLoadResult LoadGLTF(BASE_NS::array_view<uint8_t const> data) override; 478bf80f4bSopenharmony_ci bool SaveGLTF(CORE_NS::IEcs& ecs, BASE_NS::string_view uri) override; 488bf80f4bSopenharmony_ci IGLTF2Importer::Ptr CreateGLTF2Importer(CORE_NS::IEcs& ecs) override; 498bf80f4bSopenharmony_ci IGLTF2Importer::Ptr CreateGLTF2Importer(CORE_NS::IEcs& ecs, CORE_NS::IThreadPool& pool) override; 508bf80f4bSopenharmony_ci CORE_NS::Entity ImportGltfScene(size_t sceneIndex, const IGLTFData& gltfData, 518bf80f4bSopenharmony_ci const GLTFResourceData& gltfImportData, CORE_NS::IEcs& ecs, CORE_NS::Entity rootEntity, 528bf80f4bSopenharmony_ci GltfSceneImportFlags flags) override; 538bf80f4bSopenharmony_ci 548bf80f4bSopenharmony_ci // ISceneLoader 558bf80f4bSopenharmony_ci Result Load(BASE_NS::string_view uri) override; 568bf80f4bSopenharmony_ci ISceneImporter::Ptr CreateSceneImporter(CORE_NS::IEcs& ecs) override; 578bf80f4bSopenharmony_ci ISceneImporter::Ptr CreateSceneImporter(CORE_NS::IEcs& ecs, CORE_NS::IThreadPool& pool) override; 588bf80f4bSopenharmony_ci BASE_NS::array_view<const BASE_NS::string_view> GetSupportedExtensions() const override; 598bf80f4bSopenharmony_ci 608bf80f4bSopenharmony_ci // IInterface 618bf80f4bSopenharmony_ci const IInterface* GetInterface(const BASE_NS::Uid& uid) const override; 628bf80f4bSopenharmony_ci IInterface* GetInterface(const BASE_NS::Uid& uid) override; 638bf80f4bSopenharmony_ci void Ref() override; 648bf80f4bSopenharmony_ci void Unref() override; 658bf80f4bSopenharmony_ci 668bf80f4bSopenharmony_ciprivate: 678bf80f4bSopenharmony_ci CORE_NS::IEngine* engine_ { nullptr }; 688bf80f4bSopenharmony_ci RENDER_NS::IRenderContext* renderContext_ { nullptr }; 698bf80f4bSopenharmony_ci CORE_NS::IFileManager& fileManager_; 708bf80f4bSopenharmony_ci}; 718bf80f4bSopenharmony_ciinline constexpr BASE_NS::string_view GetName(const ISceneLoader*) 728bf80f4bSopenharmony_ci{ 738bf80f4bSopenharmony_ci return "ISceneLoader"; 748bf80f4bSopenharmony_ci} 758bf80f4bSopenharmony_ciCORE3D_END_NAMESPACE() 768bf80f4bSopenharmony_ci#endif // CORE_GLTF_GLTF2_H