2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-scene3d/internal/model-motion/motion-index/blend-shape-index-impl.h>
22 #include <dali/public-api/object/type-registry-helper.h>
23 #include <dali/public-api/object/type-registry.h>
26 #include <dali-scene3d/public-api/loader/blend-shape-details.h> ///< For BlendShapes::WEIGHTS_UNIFORM
37 * Creates control through type registry
41 return Scene3D::BlendShapeIndex::New();
44 // Setup properties, signals and actions using the type-registry.
45 DALI_TYPE_REGISTRATION_BEGIN(Scene3D::BlendShapeIndex, Dali::BaseHandle, Create);
46 DALI_TYPE_REGISTRATION_END()
48 std::string GetBlendShapePropertyNameFromIndex(int index)
52 char weightNameBuffer[32];
54 // Get return value of snprintf to avoid SVACE.
55 [[maybe_unused]] auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[%d]", Loader::BlendShapes::WEIGHTS_UNIFORM, index);
57 return weightNameBuffer;
64 BlendShapeIndexPtr BlendShapeIndex::New()
66 BlendShapeIndexPtr blendShapeIndex = new BlendShapeIndex();
68 blendShapeIndex->Initialize();
70 return blendShapeIndex;
73 BlendShapeIndex::BlendShapeIndex()
77 BlendShapeIndex::~BlendShapeIndex()
81 void BlendShapeIndex::Initialize()
85 void BlendShapeIndex::SetBlendShapeId(Property::Key blendShapeId)
87 mBlendShapeId = blendShapeId;
90 Property::Key BlendShapeIndex::GetBlendShapeId() const
95 std::string BlendShapeIndex::GetPropertyName(Scene3D::ModelNode node)
97 if(mBlendShapeId.type == Property::Key::Type::INDEX)
99 if(mBlendShapeId.indexKey != Property::INVALID_INDEX)
101 return GetBlendShapePropertyNameFromIndex(mBlendShapeId.indexKey);
104 else if(mBlendShapeId.type == Property::Key::Type::STRING)
108 auto index = node.GetBlendShapeIndexByName(mBlendShapeId.stringKey);
109 if(index != Scene3D::Loader::BlendShapes::INVALID_INDEX)
111 return GetBlendShapePropertyNameFromIndex(index);
118 Property::Index BlendShapeIndex::GetPropertyIndex(Scene3D::ModelNode node)
121 return Property::INVALID_INDEX;
124 } // namespace Internal
126 } // namespace Scene3D