X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-scene-loader%2Fpublic-api%2Fnode-definition.cpp;h=e8dafa8c6dd2e2733405312dbf592718b240b224;hp=e8f6b82d968685eeac0a508b2e050013174f3e80;hb=59d7a437c93f4864515c64d0aa3eacaebd293db6;hpb=1bc53ac578137a8f0f0ecedb30a6d76dc9d743c2 diff --git a/dali-scene-loader/public-api/node-definition.cpp b/dali-scene-loader/public-api/node-definition.cpp index e8f6b82..e8dafa8 100644 --- a/dali-scene-loader/public-api/node-definition.cpp +++ b/dali-scene-loader/public-api/node-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,19 @@ namespace Dali { +namespace +{ +constexpr std::string_view IBL_INTENSITY_STRING("uIblIntensity"); +constexpr std::string_view IBL_Y_DIRECTION("uYDirection"); +} + namespace SceneLoader { +bool NodeDefinition::Renderable::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const +{ + return false; +} + void NodeDefinition::Renderable::RegisterResources(IResourceReceiver& receiver) const { receiver.Register(ResourceType::Shader, mShaderIdx); @@ -89,6 +100,50 @@ Matrix NodeDefinition::GetLocalSpace() const return localSpace; } +std::string_view NodeDefinition::GetIblScaleFactorUniformName() +{ + return IBL_INTENSITY_STRING; +} + +std::string_view NodeDefinition::GetIblYDirectionUniformName() +{ + return IBL_Y_DIRECTION; +} + +bool NodeDefinition::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const +{ + if(mRenderable) + { + if(!mRenderable->GetExtents(resources, min, max)) + { + // If the renderable node don't have mesh accessor, use size to compute extents. + min = -mSize / 2.0f; + max = mSize / 2.0f; + } + return true; + } + return false; +} + +bool ModelNode::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const +{ + auto& mesh = resources.mMeshes[mMeshIdx]; + uint32_t minSize = mesh.first.mPositions.mBlob.mMin.size(); + uint32_t maxSize = mesh.first.mPositions.mBlob.mMax.size(); + if(minSize == maxSize && minSize >= 2u && maxSize >= 2u) + { + min = Vector3(mesh.first.mPositions.mBlob.mMin[0], mesh.first.mPositions.mBlob.mMin[1], 0.0f); + max = Vector3(mesh.first.mPositions.mBlob.mMax[0], mesh.first.mPositions.mBlob.mMax[1], 0.0f); + if(minSize == 3u) + { + min.z = mesh.first.mPositions.mBlob.mMin[2]; + max.z = mesh.first.mPositions.mBlob.mMax[2]; + } + return true; + } + return false; +} + void ModelNode::RegisterResources(IResourceReceiver& receiver) const { Renderable::RegisterResources(receiver); @@ -150,9 +205,13 @@ void ModelNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParam actor.SetProperty(Actor::Property::COLOR, mColor); + actor.RegisterProperty("uHasVertexColor", static_cast(mesh.first.mColors.IsDefined())); + auto& matDef = resources.mMaterials[mMaterialIdx].first; + actor.RegisterProperty("uColorFactor", matDef.mBaseColorFactor); actor.RegisterProperty("uMetallicFactor", matDef.mMetallic); actor.RegisterProperty("uRoughnessFactor", matDef.mRoughness); + actor.RegisterProperty("uNormalScale", matDef.mNormalScale); if(matDef.mFlags & MaterialDefinition::OCCLUSION) { actor.RegisterProperty("uOcclusionStrength", matDef.mOcclusionStrength); @@ -163,13 +222,26 @@ void ModelNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParam } Index envIdx = matDef.mEnvironmentIdx; - actor.RegisterProperty("uIblIntensity", resources.mEnvironmentMaps[envIdx].first.mIblIntensity); + actor.RegisterProperty(IBL_INTENSITY_STRING.data(), resources.mEnvironmentMaps[envIdx].first.mIblIntensity); + actor.RegisterProperty(IBL_Y_DIRECTION.data(), resources.mEnvironmentMaps[envIdx].first.mYDirection); - const auto alphaCutoff = matDef.GetAlphaCutoff(); - if(alphaCutoff > 0.f) + float opaque = 0.0f; + float mask = 0.0f; + float alphaCutoff = matDef.GetAlphaCutoff(); + if(!MaskMatch(matDef.mFlags, MaterialDefinition::TRANSPARENCY)) + { + opaque = 1.0f; + } + else { - actor.RegisterProperty("uAlphaThreshold", alphaCutoff); + if(alphaCutoff > 0.f) + { + mask = 1.0f; + } } + actor.RegisterProperty("uOpaque", opaque); + actor.RegisterProperty("uMask", mask); + actor.RegisterProperty("uAlphaThreshold", alphaCutoff); } void ArcNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParams& params, Actor& actor) const