/*
* 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
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
///
/// Creates an initialized path handle.
///
/// 3
public Path() : this(Interop.Path.Path_New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal Path(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Path.Path_SWIGUpcast(cPtr), cMemoryOwn)
{
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
///
/// 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.CONTROL_POINTS).Get(temp);
return temp;
}
set
{
Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.CONTROL_POINTS, new Tizen.NUI.PropertyValue(value));
}
}
///
/// Adds an interpolation point.
///
/// The new interpolation point to be added.
/// 3
public void AddPoint(Position point)
{
Interop.Path.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.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.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.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.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.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.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;
}
///
/// Dispose
///
/// The dispoase type
/// 3
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Interop.Path.delete_Path(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
base.Dispose(type);
}
internal class Property
{
internal static readonly int POINTS = Interop.Path.Path_Property_POINTS_get();
internal static readonly int CONTROL_POINTS = Interop.Path.Path_Property_CONTROL_POINTS_get();
}
}
}