/* * Copyright(c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System; using System.ComponentModel; namespace Tizen.NUI { /// /// A 3D parametric curve.
/// Paths can be used to animate the position and orientation of actors.
///
/// 3 public class Path : BaseHandle { /// /// Creates an initialized path handle. /// /// 3 public Path() : this(Interop.Path.New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Path(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Path.Upcast(cPtr), cMemoryOwn) { } /// /// Enumeration for the Points. /// /// 3 public PropertyArray Points { get { Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray(); Tizen.NUI.Object.GetProperty(SwigCPtr, Path.Property.POINTS).Get(temp); return temp; } set { Tizen.NUI.Object.SetProperty(SwigCPtr, Path.Property.POINTS, new Tizen.NUI.PropertyValue(value)); } } /// /// Enumeration for the ControlPoints. /// /// 3 public PropertyArray ControlPoints { get { Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray(); Tizen.NUI.Object.GetProperty(SwigCPtr, Path.Property.ControlPoints).Get(temp); return temp; } set { Tizen.NUI.Object.SetProperty(SwigCPtr, Path.Property.ControlPoints, new Tizen.NUI.PropertyValue(value)); } } /// /// Adds an interpolation point. /// /// The new interpolation point to be added. /// 3 public void AddPoint(Position point) { Interop.Path.AddPoint(SwigCPtr, Position.getCPtr(point)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Adds a control point. /// /// The new control point to be added. /// 3 public void AddControlPoint(Vector3 point) { Interop.Path.AddControlPoint(SwigCPtr, Vector3.getCPtr(point)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Automatic generation of control points. Generated control points which result in a smooth join between the splines of each segment.
/// The generating algorithm is as follows:
/// For a given knot point K[N], find the vector that bisects K[N-1],[N] and [N],[N+1].
/// Calculate the tangent vector by taking the normal of this bisector.
/// The in control point is the length of the preceding segment back along this bisector multiplied by the curvature.
/// The out control point is the length of the succeeding segment forward along this bisector multiplied by the curvature.
///
/// The curvature of the spline. 0 gives straight lines between the knots, negative values means the spline contains loops, positive values up to 0.5 result in a smooth curve, positive values between 0.5 and 1 result in looped curves where the loops are not distinct (i.e., the curve appears to be non-continuous), positive values higher than 1 result in looped curves. /// 3 public void GenerateControlPoints(float curvature) { Interop.Path.GenerateControlPoints(SwigCPtr, curvature); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Sample path at a given progress. Calculates the position and tangent at that point of the curve. /// /// A floating point value between 0.0 and 1.0. /// The interpolated position at that progress. /// The interpolated tangent at that progress. /// 3 public void Sample(float progress, Vector3 position, Vector3 tangent) { Interop.Path.Sample(SwigCPtr, progress, Vector3.getCPtr(position), Vector3.getCPtr(tangent)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// An accessor for the interpolation points. /// /// The index of the interpolation point. /// 3 public Vector3 GetPoint(uint index) { Vector3 ret = new Vector3(Interop.Path.GetPoint(SwigCPtr, index), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// An accessor for the control points. /// /// The index of the control point. /// 3 public Vector3 GetControlPoint(uint index) { Vector3 ret = new Vector3(Interop.Path.GetControlPoint(SwigCPtr, index), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the number of interpolation points in the path. /// /// The number of interpolation points in the path. /// 3 public uint GetPointCount() { uint ret = Interop.Path.GetPointCount(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Path obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr; } /// This will not be public opened. [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.Path.DeletePath(swigCPtr); } internal class Property { internal static readonly int POINTS = Interop.Path.PointsGet(); internal static readonly int ControlPoints = Interop.Path.ControlPointsGet(); } } }