2 * Copyright (c) 2024 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-value-impl.h>
22 #include <dali/devel-api/animation/key-frames-devel.h>
23 #include <dali/public-api/object/type-registry-helper.h>
24 #include <dali/public-api/object/type-registry.h>
37 * Creates control through type registry
41 return Scene3D::MotionValue::New();
44 // Setup properties, signals and actions using the type-registry.
45 DALI_TYPE_REGISTRATION_BEGIN(Scene3D::MotionValue, Dali::BaseHandle, Create);
46 DALI_TYPE_REGISTRATION_END()
48 } // unnamed namespace
50 MotionValuePtr MotionValue::New()
52 MotionValuePtr motionValue = new MotionValue();
54 motionValue->Initialize();
59 MotionValue::MotionValue()
63 MotionValue::~MotionValue()
67 void MotionValue::Initialize()
73 Scene3D::MotionValue::ValueType MotionValue::GetValueType() const
78 void MotionValue::SetValue(Property::Value propertyValue)
80 mType = Scene3D::MotionValue::ValueType::PROPERTY_VALUE;
83 mPropertyValue = propertyValue;
86 void MotionValue::SetValue(Dali::KeyFrames keyFrames)
88 mType = Scene3D::MotionValue::ValueType::KEY_FRAMES;
90 mKeyFrames = keyFrames;
91 mPropertyValue = Property::Value();
94 void MotionValue::Clear()
96 mType = Scene3D::MotionValue::ValueType::INVALID;
99 mPropertyValue = Property::Value();
102 Property::Value MotionValue::GetPropertyValue() const
104 if(mType == Scene3D::MotionValue::ValueType::PROPERTY_VALUE)
106 return mPropertyValue;
108 else if(mType == Scene3D::MotionValue::ValueType::KEY_FRAMES)
110 // Get last value of keyframes
111 auto keyFrameCount = DevelKeyFrames::GetKeyFrameCount(mKeyFrames);
112 if(keyFrameCount > 0u)
115 Property::Value propertyValue;
116 DevelKeyFrames::GetKeyFrame(mKeyFrames, keyFrameCount - 1u, dummyProgress, propertyValue);
118 return propertyValue;
121 return Property::Value();
124 KeyFrames MotionValue::GetKeyFrames() const
126 if(mType == Scene3D::MotionValue::ValueType::KEY_FRAMES)
130 else if(mType == Scene3D::MotionValue::ValueType::PROPERTY_VALUE)
132 // Generate stable keyframe animation here.
133 // TODO : Should we check property value is animatable type or not?
134 KeyFrames keyFrames = KeyFrames::New();
135 keyFrames.Add(0.0f, mPropertyValue);
136 keyFrames.Add(1.0f, mPropertyValue);
139 return Dali::KeyFrames();
142 } // namespace Internal
144 } // namespace Scene3D