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.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include <dali-scene3d/internal/loader/gltf2-loader-impl.h>
22 #include <dali-scene3d/public-api/loader/load-result.h>
23 #include <dali-scene3d/public-api/loader/resource-bundle.h>
24 #include <dali-scene3d/public-api/loader/scene-definition.h>
25 #include <dali-scene3d/public-api/loader/shader-manager.h>
26 #include <dali-test-suite-utils.h>
27 #include <string_view>
30 using namespace Dali::Scene3D::Loader;
32 #define DALI_TEST_THROW(expression, exception, predicate) \
34 bool daliTestThrowSuccess__ = false; \
41 printf("No exception was thrown.\n"); \
43 catch(std::decay<exception>::type & ex) \
45 daliTestThrowSuccess__ = predicate(ex); \
49 printf("Wrong type of exception thrown.\n"); \
51 DALI_TEST_CHECK(daliTestThrowSuccess__); \
58 ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type)
60 return TEST_RESOURCE_DIR "/";
63 ResourceBundle resources;
64 SceneDefinition scene;
65 SceneMetadata metaData;
67 std::vector<AnimationDefinition> animations;
68 std::vector<AnimationGroupDefinition> animationGroups;
69 std::vector<CameraParameters> cameras;
70 std::vector<LightParameters> lights;
72 LoadResult loadResult{
81 Dali::Scene3D::Loader::Internal::Gltf2LoaderImpl loader;
84 struct ExceptionMessageStartsWith
86 const std::string_view expected;
88 bool operator()(const std::runtime_error& e)
90 const bool success = (0 == strncmp(e.what(), expected.data(), expected.size()));
93 printf("Expected: %s, got: %s.\n", expected.data(), e.what());
101 int UtcDaliGltfLoaderFailedToLoad(void)
105 DALI_TEST_EQUAL(ctx.loader.LoadModel("non-existent.gltf", ctx.loadResult), false);
107 DALI_TEST_EQUAL(0, ctx.scene.GetRoots().size());
108 DALI_TEST_EQUAL(0, ctx.scene.GetNodeCount());
110 DALI_TEST_EQUAL(0, ctx.resources.mEnvironmentMaps.size());
111 DALI_TEST_EQUAL(0, ctx.resources.mMaterials.size());
112 DALI_TEST_EQUAL(0, ctx.resources.mMeshes.size());
113 DALI_TEST_EQUAL(0, ctx.resources.mShaders.size());
114 DALI_TEST_EQUAL(0, ctx.resources.mSkeletons.size());
116 DALI_TEST_EQUAL(0, ctx.cameras.size());
117 DALI_TEST_EQUAL(0, ctx.lights.size());
118 DALI_TEST_EQUAL(0, ctx.animations.size());
119 DALI_TEST_EQUAL(0, ctx.animationGroups.size());
124 int UtcDaliGltfLoaderFailedToParse(void)
128 DALI_TEST_EQUAL(ctx.loader.LoadModel(TEST_RESOURCE_DIR "/invalid.gltf", ctx.loadResult), false);
130 DALI_TEST_EQUAL(0, ctx.scene.GetRoots().size());
131 DALI_TEST_EQUAL(0, ctx.scene.GetNodeCount());
133 DALI_TEST_EQUAL(0, ctx.resources.mEnvironmentMaps.size());
134 DALI_TEST_EQUAL(0, ctx.resources.mMaterials.size());
135 DALI_TEST_EQUAL(0, ctx.resources.mMeshes.size());
136 DALI_TEST_EQUAL(0, ctx.resources.mSkeletons.size());
138 DALI_TEST_EQUAL(0, ctx.cameras.size());
139 DALI_TEST_EQUAL(0, ctx.lights.size());
140 DALI_TEST_EQUAL(0, ctx.animations.size());
141 DALI_TEST_EQUAL(0, ctx.animationGroups.size());
146 int UtcDaliGltfLoaderSuccess1(void)
150 LoadSceneMetadata(TEST_RESOURCE_DIR "/AnimatedCube.metadata", ctx.metaData);
152 std::unordered_map<std::string, ImageMetadata> imageMetadataGroundTruth;
153 imageMetadataGroundTruth["AnimatedCube_BaseColor.png"] = ImageMetadata{ImageDimensions(256, 256), Dali::SamplingMode::BOX_THEN_NEAREST};
154 imageMetadataGroundTruth["AnimatedCube_MetallicRoughness.png"] = ImageMetadata{ImageDimensions(256, 256), Dali::SamplingMode::NEAREST};
156 auto metaData = ctx.metaData.mImageMetadata.begin();
157 for(auto& groundTruth : imageMetadataGroundTruth)
159 DALI_TEST_EQUAL(groundTruth.first, metaData->first);
160 DALI_TEST_EQUAL(groundTruth.second.mMinSize, metaData->second.mMinSize);
161 DALI_TEST_EQUAL(groundTruth.second.mSamplingMode, metaData->second.mSamplingMode);
165 ctx.loader.LoadModel(TEST_RESOURCE_DIR "/AnimatedCube.gltf", ctx.loadResult);
167 DALI_TEST_EQUAL(1u, ctx.scene.GetRoots().size());
168 DALI_TEST_EQUAL(9u, ctx.scene.GetNodeCount());
170 // Default envmap is used
171 DALI_TEST_EQUAL(1u, ctx.resources.mEnvironmentMaps.size());
175 Customization::Choices choices;
176 for(auto iRoot : ctx.scene.GetRoots())
178 auto resourceRefs = ctx.resources.CreateRefCounter();
179 ctx.scene.CountResourceRefs(iRoot, choices, resourceRefs);
180 ctx.resources.mReferenceCounts = std::move(resourceRefs);
181 ctx.resources.CountEnvironmentReferences();
182 ctx.resources.LoadResources(ctx.pathProvider);
185 auto& materials = ctx.resources.mMaterials;
186 DALI_TEST_EQUAL(2u, materials.size());
187 const MaterialDefinition materialGroundTruth[]{
190 MaterialDefinition::ALBEDO | MaterialDefinition::EMISSIVE | MaterialDefinition::OCCLUSION |
191 MaterialDefinition::NORMAL | MaterialDefinition::SPECULAR | MaterialDefinition::SPECULAR_COLOR |
192 MaterialDefinition::GLTF_CHANNELS | (0x80 << MaterialDefinition::ALPHA_CUTOFF_SHIFT),
197 Vector4(1.000, 0.766, 0.336, 1.0),
200 Vector3(0.2, 0.1, 0.0),
209 Scene3D::Material::AlphaModeType::MASK,
214 MaterialDefinition::ALBEDO,
216 "AnimatedCube_BaseColor.png",
217 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
218 ImageDimensions(256, 256),
219 SamplingMode::BOX_THEN_NEAREST,
223 MaterialDefinition::NORMAL,
225 "AnimatedCube_BaseColor.png",
226 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
227 ImageDimensions(256, 256),
228 SamplingMode::BOX_THEN_NEAREST,
232 MaterialDefinition::OCCLUSION,
234 "AnimatedCube_BaseColor.png",
235 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
236 ImageDimensions(256, 256),
237 SamplingMode::BOX_THEN_NEAREST,
241 MaterialDefinition::EMISSIVE,
243 "AnimatedCube_BaseColor.png",
244 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
245 ImageDimensions(256, 256),
246 SamplingMode::BOX_THEN_NEAREST,
250 MaterialDefinition::SPECULAR,
252 "AnimatedCube_BaseColor.png",
253 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
254 ImageDimensions(256, 256),
255 SamplingMode::BOX_THEN_NEAREST,
259 MaterialDefinition::SPECULAR_COLOR,
261 "AnimatedCube_BaseColor.png",
262 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
263 ImageDimensions(256, 256),
264 SamplingMode::BOX_THEN_NEAREST,
272 MaterialDefinition::ALBEDO | MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS |
273 MaterialDefinition::EMISSIVE | MaterialDefinition::OCCLUSION | MaterialDefinition::NORMAL |
274 MaterialDefinition::GLTF_CHANNELS,
279 Vector4(1.000, 0.766, 0.336, 1.0),
282 Vector3(0.2, 0.1, 0.0),
291 Scene3D::Material::AlphaModeType::OPAQUE,
296 MaterialDefinition::ALBEDO,
298 "AnimatedCube_BaseColor.png",
299 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
300 ImageDimensions(256, 256),
301 SamplingMode::BOX_THEN_NEAREST,
305 MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS,
307 "AnimatedCube_MetallicRoughness.png",
308 SamplerFlags::Encode(FilterMode::NEAREST_MIPMAP_LINEAR, FilterMode::NEAREST, WrapMode::CLAMP_TO_EDGE, WrapMode::MIRRORED_REPEAT),
309 ImageDimensions(256, 256),
310 SamplingMode::NEAREST,
314 MaterialDefinition::NORMAL,
316 "AnimatedCube_BaseColor.png",
317 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
318 ImageDimensions(256, 256),
319 SamplingMode::BOX_THEN_NEAREST,
323 MaterialDefinition::OCCLUSION,
325 "AnimatedCube_BaseColor.png",
326 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
327 ImageDimensions(256, 256),
328 SamplingMode::BOX_THEN_NEAREST,
332 MaterialDefinition::EMISSIVE,
334 "AnimatedCube_BaseColor.png",
335 SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT),
336 ImageDimensions(256, 256),
337 SamplingMode::BOX_THEN_NEAREST,
345 auto iMaterial = materials.begin();
346 auto iMetadata = ctx.metaData.mImageMetadata.begin();
347 for(auto& m : materialGroundTruth)
349 printf("material %ld\n", iMaterial - materials.begin());
350 auto& md = iMaterial->first;
351 DALI_TEST_EQUAL(md.mFlags, m.mFlags);
352 DALI_TEST_EQUAL(md.mEnvironmentIdx, m.mEnvironmentIdx);
353 DALI_TEST_EQUAL(md.mColor, m.mColor);
354 DALI_TEST_EQUAL(md.mMetallic, m.mMetallic);
355 DALI_TEST_EQUAL(md.mRoughness, m.mRoughness);
356 DALI_TEST_EQUAL(md.mBaseColorFactor, m.mBaseColorFactor);
357 DALI_TEST_EQUAL(md.mNormalScale, m.mNormalScale);
358 DALI_TEST_EQUAL(md.mOcclusionStrength, m.mOcclusionStrength);
359 DALI_TEST_EQUAL(md.mEmissiveFactor, m.mEmissiveFactor);
360 DALI_TEST_EQUAL(md.mIor, m.mIor);
361 DALI_TEST_EQUAL(md.mDielectricSpecular, m.mDielectricSpecular);
362 DALI_TEST_EQUAL(md.mSpecularFactor, m.mSpecularFactor);
363 DALI_TEST_EQUAL(md.mSpecularColorFactor, m.mSpecularColorFactor);
364 DALI_TEST_EQUAL(md.mNeedAlbedoTexture, m.mNeedAlbedoTexture);
365 DALI_TEST_EQUAL(md.mNeedMetallicRoughnessTexture, m.mNeedMetallicRoughnessTexture);
366 DALI_TEST_EQUAL(md.mNeedNormalTexture, m.mNeedNormalTexture);
367 DALI_TEST_EQUAL(md.mAlphaModeType, m.mAlphaModeType);
368 DALI_TEST_EQUAL(md.mIsOpaque, m.mIsOpaque);
369 DALI_TEST_EQUAL(md.mIsMask, m.mIsMask);
371 DALI_TEST_EQUAL(md.mTextureStages.size(), m.mTextureStages.size());
372 auto iTexture = md.mTextureStages.begin();
373 for(auto& ts : m.mTextureStages)
375 printf("texture %ld\n", iTexture - md.mTextureStages.begin());
376 DALI_TEST_EQUAL(iTexture->mSemantic, ts.mSemantic);
377 DALI_TEST_EQUAL(iTexture->mTexture.mImageUri, ts.mTexture.mImageUri);
378 DALI_TEST_EQUAL(uint32_t(iTexture->mTexture.mSamplerFlags), uint32_t(ts.mTexture.mSamplerFlags)); // don't interpret it as a character
379 DALI_TEST_EQUAL(iTexture->mTexture.mMinImageDimensions, ts.mTexture.mMinImageDimensions);
380 DALI_TEST_EQUAL(iTexture->mTexture.mSamplingMode, ts.mTexture.mSamplingMode);
388 auto& meshes = ctx.resources.mMeshes;
389 DALI_TEST_EQUAL(2u, meshes.size());
391 using Blob = MeshDefinition::Blob;
392 using Accessor = MeshDefinition::Accessor;
393 const MeshDefinition meshGroundTruth[]{
399 Accessor{Blob{0, 0}, {}},
400 Accessor{Blob{0, 0}, {}},
401 Accessor{Blob{0, 0}, {}},
402 Accessor{Blob{0, 0}, {}},
403 Accessor{Blob{0, 0}, {}},
404 Accessor{Blob{0, 0}, {}},
411 Accessor{Blob{0, 0}, {}},
412 Accessor{Blob{0, 0}, {}},
413 Accessor{Blob{0, 0}, {}},
414 Accessor{Blob{0, 0}, {}},
415 Accessor{Blob{0, 0}, {}},
416 Accessor{Blob{0, 0}, {}},
420 auto iMesh = meshes.begin();
421 for(auto& m : meshGroundTruth)
423 printf("mesh %ld\n", iMesh - meshes.begin());
425 auto& md = iMesh->first;
426 DALI_TEST_EQUAL(md.mFlags, m.mFlags);
427 DALI_TEST_EQUAL(md.mPrimitiveType, m.mPrimitiveType);
429 &MeshDefinition::mIndices,
430 &MeshDefinition::mPositions,
431 &MeshDefinition::mNormals,
432 &MeshDefinition::mTexCoords,
433 &MeshDefinition::mColors,
434 &MeshDefinition::mTangents,
435 &MeshDefinition::mJoints0,
436 &MeshDefinition::mWeights0})
438 DALI_TEST_EQUAL((md.*mp).IsDefined(), (m.*mp).IsDefined());
439 DALI_TEST_EQUAL((md.*mp).mBlob.IsDefined(), (m.*mp).mBlob.IsDefined());
442 DALI_TEST_EQUAL(md.mBlendShapeHeader.IsDefined(), m.mBlendShapeHeader.IsDefined());
447 DALI_TEST_EQUAL(0u, ctx.resources.mSkeletons.size());
449 DALI_TEST_EQUAL(6u, ctx.cameras.size());
450 DALI_TEST_EQUAL(0u, ctx.lights.size());
451 DALI_TEST_EQUAL(1u, ctx.animations.size());
452 DALI_TEST_EQUAL(0u, ctx.animationGroups.size());
457 int UtcDaliGltfLoaderSuccess2(void)
461 ctx.loader.LoadModel(TEST_RESOURCE_DIR "/AnimatedCubeStride.gltf", ctx.loadResult);
463 DALI_TEST_EQUAL(1u, ctx.scene.GetRoots().size());
464 DALI_TEST_EQUAL(1u, ctx.scene.GetNodeCount());
468 Customization::Choices choices;
469 for(auto iRoot : ctx.scene.GetRoots())
471 auto resourceRefs = ctx.resources.CreateRefCounter();
472 ctx.scene.CountResourceRefs(iRoot, choices, resourceRefs);
473 ctx.resources.mReferenceCounts = std::move(resourceRefs);
474 ctx.resources.LoadResources(ctx.pathProvider);
477 DALI_TEST_EQUAL(true, ctx.resources.mMeshes[0u].first.mPositions.IsDefined());
478 DALI_TEST_EQUAL(432, ctx.resources.mMeshes[0u].first.mPositions.mBlob.mLength);
483 int UtcDaliGltfLoaderSuccessShort(void)
487 const std::string resourcePath = TEST_RESOURCE_DIR "/";
488 auto pathProvider = [resourcePath](ResourceType::Value)
493 Customization::Choices choices;
494 for(auto modelName : {
497 "AnimatedMorphCubeAnimateNonZeroFrame",
498 "AnimatedMorphSphere",
505 "MorphPrimitivesTest",
507 "SimpleSparseAccessor",
513 auto& resources = ctx.resources;
514 resources.mEnvironmentMaps.push_back({});
516 printf("%s\n", modelName);
517 ctx.loader.LoadModel(resourcePath + modelName + ".gltf", ctx.loadResult);
518 DALI_TEST_CHECK(ctx.scene.GetNodeCount() > 0);
520 auto& scene = ctx.scene;
521 for(auto iRoot : scene.GetRoots())
523 struct Visitor : NodeDefinition::IVisitor
525 struct ResourceReceiver : IResourceReceiver
527 std::vector<bool> mCounts;
529 void Register(ResourceType::Value type, Index id) override
531 if(type == ResourceType::Mesh)
538 void Start(NodeDefinition& n) override
540 for(auto& renderable : n.mRenderables)
542 renderable->RegisterResources(receiver);
546 void Finish(NodeDefinition& n) override
550 visitor.receiver.mCounts.resize(resources.mMeshes.size(), false);
552 scene.Visit(iRoot, choices, visitor);
553 for(uint32_t i0 = 0, i1 = resources.mMeshes.size(); i0 < i1; ++i0)
555 if(visitor.receiver.mCounts[i0])
557 auto raw = resources.mMeshes[i0].first.LoadRaw(resourcePath, resources.mBuffers);
558 DALI_TEST_CHECK(!raw.mAttribs.empty());
560 resources.mMeshes[i0].second = resources.mMeshes[i0].first.Load(std::move(raw));
561 DALI_TEST_CHECK(resources.mMeshes[i0].second.geometry);
570 int UtcDaliGltfLoaderMRendererTest(void)
573 auto& resources = ctx.resources;
575 ctx.loader.LoadModel(TEST_RESOURCE_DIR "/MRendererTest.gltf", ctx.loadResult);
577 auto& scene = ctx.scene;
578 auto& roots = scene.GetRoots();
579 DALI_TEST_EQUAL(roots.size(), 1u);
580 DALI_TEST_EQUAL(scene.GetNode(roots[0])->mName, "RootNode");
581 DALI_TEST_EQUAL(scene.GetNode(roots[0])->mScale, Vector3(1.0f, 1.0f, 1.0f));
583 DALI_TEST_EQUAL(scene.GetNodeCount(), 1u);
585 Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
586 ViewProjection viewProjection;
590 NodeDefinition::CreateParams nodeParams{
596 Customization::Choices choices;
600 Actor root = Actor::New();
601 SetActorCentered(root);
602 for(auto iRoot : roots)
604 auto resourceRefs = resources.CreateRefCounter();
605 scene.CountResourceRefs(iRoot, choices, resourceRefs);
606 ctx.resources.mReferenceCounts = std::move(resourceRefs);
607 ctx.resources.CountEnvironmentReferences();
608 ctx.resources.LoadResources(ctx.pathProvider);
609 if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
611 scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
612 scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
617 DALI_TEST_EQUAL(root.GetChildCount(), 1u);
618 Actor child = root.GetChildAt(0);
620 DALI_TEST_EQUAL(child.GetProperty(Actor::Property::NAME).Get<std::string>(), "RootNode");
621 DALI_TEST_EQUAL(child.GetProperty(Actor::Property::SCALE).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f));
622 DALI_TEST_EQUAL(child.GetRendererCount(), 1u);
623 DALI_TEST_EQUAL(child.GetRendererAt(0).GetTextures().GetTextureCount(), 4u);
625 DALI_TEST_EQUAL(child.GetRendererCount(), 1u);
626 DALI_TEST_EQUAL(child.GetRendererAt(0u).GetProperty<decltype(BlendMode::ON)>(Renderer::Property::BLEND_MODE), BlendMode::ON);
631 int UtcDaliGltfLoaderAnimationLoadingTest(void)
636 auto& resources = ctx.resources;
638 ctx.loader.LoadModel(TEST_RESOURCE_DIR "/CesiumMan_e.gltf", ctx.loadResult);
640 auto& scene = ctx.scene;
641 auto& roots = scene.GetRoots();
642 DALI_TEST_EQUAL(roots.size(), 1u);
644 Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
645 ViewProjection viewProjection;
649 NodeDefinition::CreateParams nodeParams{
655 Customization::Choices choices;
657 Actor root = Actor::New();
658 SetActorCentered(root);
659 for(auto iRoot : roots)
661 auto resourceRefs = resources.CreateRefCounter();
662 scene.CountResourceRefs(iRoot, choices, resourceRefs);
663 resources.mReferenceCounts = std::move(resourceRefs);
664 resources.CountEnvironmentReferences();
665 resources.LoadResources(ctx.pathProvider);
666 if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
668 scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
669 scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
674 DALI_TEST_EQUAL(ctx.loadResult.mAnimationDefinitions.size(), 1u);
675 DALI_TEST_EQUAL(ctx.loadResult.mAnimationDefinitions[0].GetPropertyCount(), 57u);
677 uint32_t id = ctx.loadResult.mScene.GetNode(ctx.loadResult.mAnimationDefinitions[0].GetPropertyAt(0).mNodeIndex)->mNodeId;
678 DALI_TEST_EQUAL(id, root.FindChildByName("Skeleton_torso_joint_1").GetProperty<int32_t>(Dali::Actor::Property::ID));
683 int UtcDaliGltfLoaderImageFromBufferView(void)
687 auto& resources = ctx.resources;
689 ctx.loader.LoadModel(TEST_RESOURCE_DIR "/EnvironmentTest_b.gltf", ctx.loadResult);
691 auto& scene = ctx.scene;
692 auto& roots = scene.GetRoots();
693 DALI_TEST_EQUAL(roots.size(), 1u);
695 Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
696 ViewProjection viewProjection;
700 NodeDefinition::CreateParams nodeParams{
706 Customization::Choices choices;
710 Actor root = Actor::New();
711 SetActorCentered(root);
712 for(auto iRoot : roots)
714 auto resourceRefs = resources.CreateRefCounter();
715 scene.CountResourceRefs(iRoot, choices, resourceRefs);
716 resources.mReferenceCounts = std::move(resourceRefs);
717 resources.CountEnvironmentReferences();
718 resources.LoadResources(ctx.pathProvider);
719 if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
721 scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
722 scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
727 DALI_TEST_CHECK(resources.mMaterials[0].second.GetTextureCount() > 1);
728 DALI_TEST_EQUAL(resources.mMaterials[0].second.GetTexture(0).GetWidth(), 256);
729 DALI_TEST_EQUAL(resources.mMaterials[0].second.GetTexture(0).GetHeight(), 256);
734 int UtcDaliGltfLoaderUint8Indices(void)
738 auto& resources = ctx.resources;
740 ctx.loader.LoadModel(TEST_RESOURCE_DIR "/AlphaBlendModeTest.gltf", ctx.loadResult);
742 auto& scene = ctx.scene;
743 auto& roots = scene.GetRoots();
744 DALI_TEST_EQUAL(roots.size(), 1u);
746 Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
747 ViewProjection viewProjection;
751 NodeDefinition::CreateParams nodeParams{
757 Customization::Choices choices;
761 Actor root = Actor::New();
762 SetActorCentered(root);
763 for(auto iRoot : roots)
765 auto resourceRefs = resources.CreateRefCounter();
766 scene.CountResourceRefs(iRoot, choices, resourceRefs);
767 resources.mReferenceCounts = std::move(resourceRefs);
768 resources.CountEnvironmentReferences();
769 resources.LoadResources(ctx.pathProvider);
770 if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
772 scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
773 scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
778 DALI_TEST_CHECK(root.FindChildByName("Bed"));
779 DALI_TEST_CHECK(root.FindChildByName("DecalBlend"));
780 DALI_TEST_CHECK(root.FindChildByName("DecalOpaque"));