2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-scene3d/internal/loader/gltf2-loader-impl.h>
22 #include <dali/integration-api/debug.h>
25 #include <dali-scene3d/internal/loader/gltf2-util.h>
26 #include <dali-scene3d/public-api/loader/load-result.h>
27 #include <dali-scene3d/public-api/loader/utils.h>
32 namespace Dali::Scene3D::Loader::Internal
34 bool Gltf2LoaderImpl::LoadModel(const std::string& url, Dali::Scene3D::Loader::LoadResult& result)
37 auto gltfText = LoadTextFile(url.c_str(), &failed);
40 DALI_LOG_ERROR("Failed to load %s\n", url.c_str());
44 json::unique_ptr root(json_parse(gltfText.c_str(), gltfText.size()));
47 DALI_LOG_ERROR("Failed to parse %s\n", url.c_str());
51 gt::Document document;
53 bool isMRendererModel(false);
54 if(!Gltf2Util::GenerateDocument(root, document, isMRendererModel))
59 auto path = url.substr(0, url.rfind('/') + 1);
60 Gltf2Util::ConversionContext context{result, path, INVALID_INDEX};
62 Gltf2Util::ConvertGltfToContext(document, context, isMRendererModel);
67 } // namespace Dali::Scene3D::Loader::Internal