X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-scene3d%2Fpublic-api%2Floader%2Ffacial-animation-loader.cpp;h=26afb29e64cf21bb3986c588ea14142d2edeef52;hb=679f02413b55445b39148f4b102c153b1b5fae83;hp=dfd9cc2633c331efd24293088b4d87c734b3f07c;hpb=ad899cb5c733b7c870e5772d7792f57375be0015;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/public-api/loader/facial-animation-loader.cpp b/dali-scene3d/public-api/loader/facial-animation-loader.cpp index dfd9cc2..26afb29 100644 --- a/dali-scene3d/public-api/loader/facial-animation-loader.cpp +++ b/dali-scene3d/public-api/loader/facial-animation-loader.cpp @@ -130,8 +130,8 @@ AnimationDefinition LoadFacialAnimation(const std::string& url) GetFacialAnimationReader().Read(rootObj, facialAnimation); AnimationDefinition animationDefinition; - animationDefinition.mName = std::string(facialAnimation.mName.data()); - animationDefinition.mDuration = MILLISECONDS_TO_SECONDS * static_cast(facialAnimation.mTime[facialAnimation.mNumberOfFrames - 1u]); + animationDefinition.SetName(facialAnimation.mName.data()); + animationDefinition.SetDuration(MILLISECONDS_TO_SECONDS * static_cast(facialAnimation.mTime[facialAnimation.mNumberOfFrames - 1u])); // Calculate the number of animated properties. uint32_t numberOfAnimatedProperties = 0u; @@ -139,46 +139,29 @@ AnimationDefinition LoadFacialAnimation(const std::string& url) { numberOfAnimatedProperties += blendShape.mNumberOfMorphTarget; } - animationDefinition.mProperties.resize(numberOfAnimatedProperties); + animationDefinition.ReserveSize(numberOfAnimatedProperties); - // Create the key frame instances. - for(auto& animatedProperty : animationDefinition.mProperties) - { - animatedProperty.mKeyFrames = Dali::KeyFrames::New(); - } - - // Set the property names uint32_t targets = 0u; for(const auto& blendShape : facialAnimation.mBlendShapes) { for(uint32_t morphTargetIndex = 0u; morphTargetIndex < blendShape.mNumberOfMorphTarget; ++morphTargetIndex) { - AnimatedProperty& animatedProperty = animationDefinition.mProperties[targets + morphTargetIndex]; - animatedProperty.mTimePeriod = Dali::TimePeriod(animationDefinition.mDuration); - + AnimatedProperty animatedProperty; + animatedProperty.mTimePeriod = Dali::TimePeriod(animationDefinition.GetDuration()); animatedProperty.mNodeName = blendShape.mNodeName; - std::stringstream weightPropertyStream; weightPropertyStream << BlendShapes::WEIGHTS_UNIFORM << "[" << morphTargetIndex << "]"; animatedProperty.mPropertyName = weightPropertyStream.str(); - } - targets += blendShape.mNumberOfMorphTarget; - } - targets = 0u; - for(const auto& blendShape : facialAnimation.mBlendShapes) - { - for(uint32_t timeIndex = 0u; timeIndex < facialAnimation.mNumberOfFrames; ++timeIndex) - { - const float progress = MILLISECONDS_TO_SECONDS * static_cast(facialAnimation.mTime[timeIndex]) / animationDefinition.mDuration; - - for(uint32_t morphTargetIndex = 0u; morphTargetIndex < blendShape.mNumberOfMorphTarget; ++morphTargetIndex) + animatedProperty.mKeyFrames = Dali::KeyFrames::New(); + for(uint32_t timeIndex = 0u; timeIndex < facialAnimation.mNumberOfFrames; ++timeIndex) { - AnimatedProperty& animatedProperty = animationDefinition.mProperties[targets + morphTargetIndex]; - + const float progress = MILLISECONDS_TO_SECONDS * static_cast(facialAnimation.mTime[timeIndex]) / animationDefinition.GetDuration(); animatedProperty.mKeyFrames.Add(progress, blendShape.mKeys[timeIndex][morphTargetIndex]); } + animationDefinition.SetProperty(targets + morphTargetIndex, std::move(animatedProperty)); } + targets += blendShape.mNumberOfMorphTarget; }