5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/handle.h>
23 #include <dali/public-api/object/property-index-ranges.h>
28 * @addtogroup dali_core_animation
32 namespace Internal DALI_INTERNAL
38 * @brief A 3D parametric curve.
40 * Paths can be used to animate position and orientation of actors using Dali::Animate().
44 class DALI_CORE_API Path : public Handle
49 * @brief Enumeration for the instance of properties belonging to the Path class.
55 * @brief Enumeration for the instance of properties belonging to the Path class.
60 POINTS = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "points", type Vector3 @SINCE_1_0.0
61 CONTROL_POINTS, ///< name "controlPoints", type Vector3 @SINCE_1_0.0
66 * @brief Creates an initialized Path handle.
69 * @return A handle to a newly allocated Dali resource
74 * @brief Downcasts a handle to Path handle.
76 * If handle points to a Path object, the downcast produces valid handle.
77 * If not, the returned handle is left uninitialized.
79 * @param[in] handle Handle to an object
80 * @return Handle to a Path object or an uninitialized handle
82 static Path DownCast( BaseHandle handle );
85 * @brief Creates an uninitialized Path handle.
87 * This can be initialized with Path::New().
88 * Calling member functions with an uninitialized Path handle is not allowed.
96 * This is non-virtual since derived Handle types must not contain data or virtual methods.
102 * @brief This copy constructor is required for (smart) pointer semantics.
105 * @param[in] handle A reference to the copied handle
107 Path(const Path& handle);
110 * @brief This assignment operator is required for (smart) pointer semantics.
113 * @param[in] rhs A reference to the copied handle
114 * @return A reference to this
116 Path& operator=(const Path& rhs);
119 * @brief Move constructor.
122 * @param[in] rhs A reference to the moved handle
127 * @brief Move assignment operator.
130 * @param[in] rhs A reference to the moved handle
131 * @return A reference to this
133 Path& operator=( Path&& rhs );
136 * @brief Adds an interpolation point.
139 * @param[in] point The new interpolation point to be added
141 void AddPoint(const Vector3& point );
144 * @brief Adds a control point.
147 * @param[in] point The new control point to be added
149 void AddControlPoint(const Vector3& point );
152 * @brief Automatic generation of control points. Generated control points which result in a smooth join between the splines of each segment.
154 * The generating algorithm is as follows:
155 * For a given knot point K[N], find the vector that bisects K[N-1],[N] and [N],[N+1].
156 * Calculate the tangent vector by taking the normal of this bisector.
157 * The in control point is the length of the preceding segment back along this bisector multiplied by the curvature.
158 * The out control point is the length of the succeeding segment forward along this bisector multiplied by the curvature.
161 * @param[in] curvature The curvature of the spline. 0 gives straight lines between the knots,
162 * negative values means the spline contains loops, positive values up to
163 * 0.5 result in a smooth curve, positive values between 0.5 and 1 result
164 * in looped curves where the loops are not distinct (i.e. the curve appears
165 * to be non-continuous), positive values higher than 1 result in looped curves
166 * @pre There are at least two points in the path ( one segment ).
169 void GenerateControlPoints( float curvature );
172 * @brief Sample path at a given progress. Calculates position and tangent at that point of the curve.
175 * @param[in] progress A floating point value between 0.0 and 1.0
176 * @param[out] position The interpolated position at that progress
177 * @param[out] tangent The interpolated tangent at that progress
179 void Sample( float progress, Vector3& position, Vector3& tangent ) const;
182 * @brief Accessor for the interpolation points.
185 * @param[in] index The index of the interpolation point
186 * @return A reference to the interpolation point
188 Vector3& GetPoint( size_t index );
191 * @brief Accessor for the control points.
194 * @param[in] index The index of the control point
195 * @return A reference to the control point
197 Vector3& GetControlPoint( size_t index );
200 * @brief Gets the number of interpolation points in the path.
203 * @return The number of interpolation points in the path
205 size_t GetPointCount() const;
207 public: // Not intended for application developers
210 * @brief This constructor is used by Path::New() methods.
213 * @param[in] path A pointer to an internal path resource
215 explicit DALI_INTERNAL Path(Internal::Path* path);
224 #endif // DALI_PATH_H