// INTERNAL INCLUDES
#include "dali-scene3d/public-api/api.h"
+#include "dali-scene3d/public-api/loader/index.h"
// EXTERNAL INCLUDES
#include <functional>
{
public: // METHODS
/**
- * @brief Function to obtain an Actor based on its name. Its processing will
+ * @brief Function to obtain an Actor based on its property. Its processing will
* ignore empty handles returned by it.
*/
- using GetActor = std::function<Actor(const std::string&)>;
+ using GetActor = std::function<Actor(const AnimatedProperty&)>;
/**
* @return The Property object (of the given @a actor) whose value is being animated.
bool mIsRelative;
};
+ Index mNodeIndex = INVALID_INDEX;
std::string mNodeName;
std::string mPropertyName;
} // namespace Scene3D
} // namespace Dali
-#endif //DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H
+#endif // DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H
return duration;
}
-float LoadBlendShapeKeyFrames(const std::string& path, const gt::Animation::Channel& channel, const std::string& nodeName, uint32_t& propertyIndex, std::vector<Dali::Scene3D::Loader::AnimatedProperty>& properties)
+float LoadBlendShapeKeyFrames(const std::string& path, const gt::Animation::Channel& channel, Index nodeIndex, uint32_t& propertyIndex, std::vector<Dali::Scene3D::Loader::AnimatedProperty>& properties)
{
const gltf2::Accessor& input = *channel.mSampler->mInput;
const gltf2::Accessor& output = *channel.mSampler->mOutput;
{
AnimatedProperty& animatedProperty = properties[propertyIndex++];
- animatedProperty.mNodeName = nodeName;
+ animatedProperty.mNodeIndex = nodeIndex;
snprintf(pWeightName, remainingSize, "%d]", weightIndex);
animatedProperty.mPropertyName = std::string(weightNameBuffer);
}
uint32_t numberOfProperties = 0u;
-
for(const auto& channel : animation.mChannels)
{
- numberOfProperties += channel.mSampler->mOutput->mCount;
+ if(channel.mTarget.mPath == gt::Animation::Channel::Target::WEIGHTS)
+ {
+ numberOfProperties += channel.mSampler->mOutput->mCount / channel.mSampler->mInput->mCount;
+ }
+ else
+ {
+ numberOfProperties++;
+ }
}
animationDef.mProperties.resize(numberOfProperties);
Index propertyIndex = 0u;
for(const auto& channel : animation.mChannels)
{
- std::string nodeName;
- if(!channel.mTarget.mNode->mName.empty())
- {
- nodeName = channel.mTarget.mNode->mName;
- }
- else
- {
- Index index = cctx.mNodeIndices.GetRuntimeId(channel.mTarget.mNode.GetIndex());
- nodeName = cctx.mOutput.mScene.GetNode(index)->mName;
- }
+ Index nodeIndex = cctx.mNodeIndices.GetRuntimeId(channel.mTarget.mNode.GetIndex());
float duration = 0.f;
{
AnimatedProperty& animatedProperty = animationDef.mProperties[propertyIndex];
- animatedProperty.mNodeName = nodeName;
+ animatedProperty.mNodeIndex = nodeIndex;
animatedProperty.mPropertyName = POSITION_PROPERTY;
animatedProperty.mKeyFrames = KeyFrames::New();
{
AnimatedProperty& animatedProperty = animationDef.mProperties[propertyIndex];
- animatedProperty.mNodeName = nodeName;
+ animatedProperty.mNodeIndex = nodeIndex;
animatedProperty.mPropertyName = ORIENTATION_PROPERTY;
animatedProperty.mKeyFrames = KeyFrames::New();
{
AnimatedProperty& animatedProperty = animationDef.mProperties[propertyIndex];
- animatedProperty.mNodeName = nodeName;
+ animatedProperty.mNodeIndex = nodeIndex;
animatedProperty.mPropertyName = SCALE_PROPERTY;
animatedProperty.mKeyFrames = KeyFrames::New();
}
case gt::Animation::Channel::Target::WEIGHTS:
{
- duration = LoadBlendShapeKeyFrames(cctx.mPath, channel, nodeName, propertyIndex, animationDef.mProperties);
+ duration = LoadBlendShapeKeyFrames(cctx.mPath, channel, nodeIndex, propertyIndex, animationDef.mProperties);
break;
}
}
#endif //DEBUG_JOINTS
-class ActorCreatorVisitor : public NodeDefinition::IConstVisitor
+class ActorCreatorVisitor : public NodeDefinition::IVisitor
{
public:
ActorCreatorVisitor(NodeDefinition::CreateParams& params)
{
}
- void Start(const NodeDefinition& n)
+ void Start(NodeDefinition& n)
{
mCreationContext.mXforms.modelStack.Push(n.GetLocalSpace());
mActorStack.push_back(a);
}
- void Finish(const NodeDefinition& n)
+ void Finish(NodeDefinition& n)
{
mActorStack.pop_back();
mCreationContext.mXforms.modelStack.Pop();
Visit(iNode, choices, refCounterVisitor);
}
-Actor SceneDefinition::CreateNodes(Index iNode, const Customization::Choices& choices, NodeDefinition::CreateParams& params) const
+Actor SceneDefinition::CreateNodes(Index iNode, const Customization::Choices& choices, NodeDefinition::CreateParams& params)
{
ActorCreatorVisitor actorCreatorVisitor(params);