#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
+#include <dali-scene3d/internal/light/light-impl.h>
#include <dali-scene3d/internal/model-components/model-primitive-impl.h>
namespace Dali
Actor self = Self();
GetImplementation(modelPrimitive).AddPrimitiveObserver(this);
+ if(mShadowMapTexture)
+ {
+ GetImplementation(modelPrimitive).SetShadowMapTexture(mShadowMapTexture);
+ }
+
if(mDiffuseTexture && mSpecularTexture)
{
GetImplementation(modelPrimitive).SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor, mSpecularMipmapLevels);
}
+ GetImplementation(modelPrimitive).UpdateShader(mShaderManager);
+
Dali::Renderer renderer = GetImplementation(modelPrimitive).GetRenderer();
if(renderer)
{
{
continue;
}
+
RemoveModelPrimitive(i);
break;
}
return;
}
+ GetImplementation(mModelPrimitiveContainer[index]).UpdateShader(nullptr);
+
Actor self = Self();
GetImplementation(mModelPrimitiveContainer[index]).RemovePrimitiveObserver(this);
return Scene3D::ModelNode::DownCast(childActor);
}
+void ModelNode::RetrieveBlendShapeNames(std::vector<std::string>& 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::SetShadowMapTexture(Dali::Texture shadowMapTexture)
+{
+ mShadowMapTexture = shadowMapTexture;
+ for(auto&& primitive : mModelPrimitiveContainer)
+ {
+ GetImplementation(primitive).SetShadowMapTexture(mShadowMapTexture);
+ }
+}
+
void ModelNode::SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float iblScaleFactor, uint32_t specularMipmapLevels)
{
mDiffuseTexture = diffuseTexture;
}
}
+void ModelNode::UpdateShader(Scene3D::Loader::ShaderManagerPtr shaderManager)
+{
+ if(mShaderManager != shaderManager)
+ {
+ mShaderManager = shaderManager;
+ for(auto&& primitive : mModelPrimitiveContainer)
+ {
+ GetImplementation(primitive).UpdateShader(mShaderManager);
+ }
+ }
+}
+
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);
}
continue;
}
- Dali::Shader shader = renderer.GetShader();
- if(!shader)
- {
- continue;
- }
-
if(boneData.constraint)
{
boneData.constraint.Remove();
boneData.constraint.Reset();
}
- if(shader.GetPropertyIndex(boneData.propertyName) == Property::INVALID_INDEX)
+ auto propBoneXform = renderer.GetPropertyIndex(boneData.propertyName);
+ if(propBoneXform == Property::INVALID_INDEX)
{
- auto propBoneXform = shader.RegisterProperty(boneData.propertyName, Matrix{false});
+ propBoneXform = renderer.RegisterProperty(boneData.propertyName, Matrix{false});
+ }
- Matrix inverseMatrix = boneData.inverseMatrix;
- // Constrain bone matrix to joint transform.
- boneData.constraint = Constraint::New<Matrix>(shader, propBoneXform, [inverseMatrix](Matrix& output, const PropertyInputContainer& inputs)
- { Matrix::Multiply(output, inverseMatrix, inputs[0]->GetMatrix()); });
+ Matrix inverseMatrix = boneData.inverseMatrix;
+ // Constrain bone matrix to joint transform.
+ boneData.constraint = Constraint::New<Matrix>(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});
- boneData.constraint.ApplyPost();
- }
+ Actor joint = Self();
+ boneData.constraint.AddSource(Source{joint, Actor::Property::WORLD_MATRIX});
+ boneData.constraint.ApplyPost();
break;
}
}