• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #ifndef CORE_GLTF_GLTF2_H
16 #define CORE_GLTF_GLTF2_H
17 
18 #include <3d/gltf/gltf.h>
19 #include <core/namespace.h>
20 #include <render/namespace.h>
21 
22 CORE_BEGIN_NAMESPACE()
23 class IEcs;
24 class IEngine;
25 class IFileManager;
26 CORE_END_NAMESPACE()
27 
28 RENDER_BEGIN_NAMESPACE()
29 class IRenderContext;
30 RENDER_END_NAMESPACE()
31 
32 CORE3D_BEGIN_NAMESPACE()
33 class IGraphicsContext;
34 
35 // implementation of public api..
36 class Gltf2 final : public IGltf2 {
37 public:
38     explicit Gltf2(IGraphicsContext& graphicsContext);
39     // allows for partial initialization. (used by tests)
40     explicit Gltf2(CORE_NS::IFileManager& fileManager);
41     ~Gltf2() override = default;
42 
43     GLTFLoadResult LoadGLTF(BASE_NS::string_view uri) override;
44     GLTFLoadResult LoadGLTF(BASE_NS::array_view<uint8_t const> data) override;
45     bool SaveGLTF(CORE_NS::IEcs& ecs, BASE_NS::string_view uri) override;
46     IGLTF2Importer::Ptr CreateGLTF2Importer(CORE_NS::IEcs& ecs) override;
47     IGLTF2Importer::Ptr CreateGLTF2Importer(CORE_NS::IEcs& ecs, CORE_NS::IThreadPool& pool) override;
48     CORE_NS::Entity ImportGltfScene(size_t sceneIndex, const IGLTFData& gltfData,
49         const GLTFResourceData& gltfImportData, CORE_NS::IEcs& ecs, CORE_NS::Entity rootEntity,
50         GltfSceneImportFlags flags) override;
51 
52 private:
53     CORE_NS::IEngine* engine_ { nullptr };
54     RENDER_NS::IRenderContext* renderContext_ { nullptr };
55     CORE_NS::IFileManager& fileManager_;
56 };
57 CORE3D_END_NAMESPACE()
58 #endif // CORE_GLTF_GLTF2_H