X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Finternal%2Fmodel-components%2Fmodel-node-impl.cpp;h=a37d4a8b278eda851f6625dbc7a55306ee83a152;hb=2116ad7b1ce51093a891ca6b3e83419b0b5b79dd;hp=54db4bc43a41db91f4b45e21ae445f101170c11a;hpb=977397724abdbd3d967bfefa440099fe04287a6b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/internal/model-components/model-node-impl.cpp b/dali-scene3d/internal/model-components/model-node-impl.cpp index 54db4bc..a37d4a8 100644 --- a/dali-scene3d/internal/model-components/model-node-impl.cpp +++ b/dali-scene3d/internal/model-components/model-node-impl.cpp @@ -24,6 +24,7 @@ #include // INTERNAL INCLUDES +#include #include namespace Dali @@ -74,6 +75,7 @@ ModelNode::~ModelNode() void ModelNode::Initialize() { OnInitialize(); + mLights.resize(Scene3D::Internal::Light::GetMaximumEnabledLightCount()); } void ModelNode::OnInitialize() @@ -191,6 +193,15 @@ void ModelNode::AddModelPrimitive(Dali::Scene3D::ModelPrimitive modelPrimitive) GetImplementation(modelPrimitive).SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor, mSpecularMipmapLevels); } + uint32_t maxLightCount = Scene3D::Internal::Light::GetMaximumEnabledLightCount(); + for(uint32_t i = 0; i < maxLightCount; ++i) + { + if(mLights[i]) + { + GetImplementation(modelPrimitive).AddLight(mLights[i], i); + } + } + Dali::Renderer renderer = GetImplementation(modelPrimitive).GetRenderer(); if(renderer) { @@ -220,6 +231,7 @@ void ModelNode::RemoveModelPrimitive(Dali::Scene3D::ModelPrimitive modelPrimitiv { continue; } + RemoveModelPrimitive(i); break; } @@ -232,6 +244,15 @@ void ModelNode::RemoveModelPrimitive(uint32_t index) return; } + uint32_t maxLightCount = Scene3D::Internal::Light::GetMaximumEnabledLightCount(); + for(uint32_t i = 0; i < maxLightCount; ++i) + { + if(mLights[i]) + { + GetImplementation(mModelPrimitiveContainer[index]).RemoveLight(i); + } + } + Actor self = Self(); GetImplementation(mModelPrimitiveContainer[index]).RemovePrimitiveObserver(this); @@ -259,6 +280,25 @@ Scene3D::ModelNode ModelNode::FindChildModelNodeByName(std::string_view nodeName return Scene3D::ModelNode::DownCast(childActor); } +void ModelNode::RetrieveBlendShapeNames(std::vector& blendShapeNames) const +{ + blendShapeNames.reserve(blendShapeNames.size() + mBlendShapeIndexMap.size()); + for(const auto& iter : mBlendShapeIndexMap) + { + blendShapeNames.push_back(iter.first); + } +} + +Loader::BlendShapes::Index ModelNode::GetBlendShapeIndexByName(std::string_view blendShapeName) const +{ + auto iter = mBlendShapeIndexMap.find(std::string(blendShapeName)); + if(iter != mBlendShapeIndexMap.end()) + { + return iter->second; + } + return Loader::BlendShapes::INVALID_INDEX; +} + void ModelNode::SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float iblScaleFactor, uint32_t specularMipmapLevels) { mDiffuseTexture = diffuseTexture; @@ -280,8 +320,38 @@ void ModelNode::SetImageBasedLightScaleFactor(float iblScaleFactor) } } +void ModelNode::AddLight(Scene3D::Light light, uint32_t lightIndex) +{ + mLights[lightIndex] = light; + for(auto&& primitive : mModelPrimitiveContainer) + { + GetImplementation(primitive).AddLight(light, lightIndex); + } +} + +void ModelNode::RemoveLight(uint32_t lightIndex) +{ + for(auto&& primitive : mModelPrimitiveContainer) + { + GetImplementation(primitive).RemoveLight(lightIndex); + } + mLights[lightIndex].Reset(); +} + void ModelNode::SetBlendShapeData(Scene3D::Loader::BlendShapes::BlendShapeData& data, Scene3D::ModelPrimitive primitive) { + // Update mBlendShapeIndexMap + mBlendShapeIndexMap.clear(); + const auto blendShapeCount = data.names.size(); + for(Loader::BlendShapes::Index index = 0u; index < blendShapeCount; ++index) + { + auto& name = data.names[index]; + if(!name.empty()) + { + mBlendShapeIndexMap[name] = index; + } + } + GetImplementation(primitive).SetBlendShapeData(data); } @@ -333,8 +403,7 @@ void ModelNode::UpdateBoneMatrix(Scene3D::ModelPrimitive primitive) Matrix inverseMatrix = boneData.inverseMatrix; // Constrain bone matrix to joint transform. - boneData.constraint = Constraint::New(renderer, propBoneXform, [inverseMatrix](Matrix& output, const PropertyInputContainer& inputs) - { Matrix::Multiply(output, inverseMatrix, inputs[0]->GetMatrix()); }); + boneData.constraint = Constraint::New(renderer, propBoneXform, [inverseMatrix](Matrix& output, const PropertyInputContainer& inputs) { Matrix::Multiply(output, inverseMatrix, inputs[0]->GetMatrix()); }); Actor joint = Self(); boneData.constraint.AddSource(Source{joint, Actor::Property::WORLD_MATRIX});