Skip to content

Commit

Permalink
[NUI.Scene3D] CodeSync MotionData API and documents
Browse files Browse the repository at this point in the history
1. Fix TCT error Samsung#5576
2. Follow some comments fix up as Samsung#5452

Signed-off-by: Eunki, Hong <[email protected]>
  • Loading branch information
Eunki Hong committed Sep 25, 2023
1 parent 1f8dde4 commit 3c40fab
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ internal static partial class MotionIndex
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_Assign")]
public static extern global::System.IntPtr MotionPropertyIndexAssign(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex, global::System.Runtime.InteropServices.HandleRef sourceMotionPropertyIndex);

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionTransformIndex_DownCast")]
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_DownCast")]
public static extern global::System.IntPtr MotionPropertyIndexDownCast(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex);

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionTransformIndex_SetTransformType")]
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_SetPropertyId")]
public static extern void SetPropertyId(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex, global::System.Runtime.InteropServices.HandleRef propertyKey);

[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionTransformIndex_GetTransformType")]
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_GetPropertyId")]
public static extern global::System.IntPtr GetPropertyId(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex);
#endregion

Expand Down
12 changes: 5 additions & 7 deletions src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,8 @@ public Animation LoadBlendShapeAnimationFromBuffer(string jsonBuffer)
/// Generate animation by MotionData.
/// If there is no animatable item for MotionData, return null.
/// </summary>
/// <param name="motionData">Inputed list of pair of MotionIndex and MotionValue, and duration.</param>
/// <returns>Generated animation by input motion data, or null if there is no animatable item exist about inputed motionData</returns>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
/// <param name="motionData">Source motion data.</param>
/// <returns>Generated animation from then given motion data, or null if there is no animatable item in <paramref name="motionData"/></returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public Animation GenerateMotionDataAnimation(MotionData motionData)
{
Expand Down Expand Up @@ -545,12 +544,11 @@ public Animation GenerateMotionDataAnimation(MotionData motionData)
}

/// <summary>
/// Prototype of MotionData setter.
/// Note that this API didn't apply KeyFrames animation.
/// Set values from MotionData.
/// Note that this method doesn not apply KeyFrames animation.
/// If you want to apply the animation, please use <see cref="GenerateMotionDataAnimation(MotionData)"/> and play the result.
/// </summary>
/// <param name="motionData">Inputed list of pair of MotionIndex and MotionValue.</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
/// <param name="motionData">Source motion data.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetMotionData(MotionData motionData)
{
Expand Down
93 changes: 54 additions & 39 deletions src/Tizen.NUI.Scene3D/src/public/ModelMotion/MotionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ namespace Tizen.NUI.Scene3D
/// List of model motion definitions.
/// Each motion has pair of <see cref="MotionIndex"/> and <see cref="MotionValue"/>.
/// MotionIndex is abstract class that specify the target of motion.
/// MotionValue is target value of motion. It can be KeyFrames.
///
/// MotionValue is destination value of target for the motion. It can be expressed with <see cref="Tizen.NUI.PropertyValue"/> or <see cref="Tizen.NUI.KeyFrames"/>.
/// </summary>
/// <remarks>
/// We don't check duplicated MotionIndex internally.
/// We don't check MotionValue type is matched with MotionIndex.
/// </remarks>
/// <example>
/// We can generate list of motions by MotionIndex and MotionValue classes.
///
/// <code>
Expand All @@ -47,7 +52,8 @@ namespace Tizen.NUI.Scene3D
/// // Make MotionIndex with BlendShapeIndex
/// motionData.Add(new BlendShapeIndex(new PropertyKey("nodeName"), new PropertyKey("blendShapeName")), motionData.GetValue(1u));
/// </code>
///
/// </example>
/// <example>
/// We can request to load MotionData from file or buffer asynchronously.
/// If load completed, <see cref="LoadCompleted"/> event will be invoked.
/// If we try to load before LoadCompleted event invoked, previous load request cancel and only latest request loaded.
Expand All @@ -65,7 +71,8 @@ namespace Tizen.NUI.Scene3D
/// /// Do something.
/// }
/// </code>
///
/// </example>
/// <example>
/// We can generate animation of Scene3D.Model from MotionData class.
/// Or, just set values.
///
Expand All @@ -77,11 +84,7 @@ namespace Tizen.NUI.Scene3D
/// // Set values from loaded Model.
/// model2.SetMotionData(motionData);
/// </code>
/// </summary>
/// <remark>
/// We don't check duplicated MotionIndex internally.
/// We don't check MotionValue type is matched with MotionIndex.
/// </remark>
/// </example>
[EditorBrowsable(EditorBrowsableState.Never)]
public class MotionData : BaseHandle
{
Expand All @@ -91,7 +94,7 @@ public class MotionData : BaseHandle
private delegate void LoadCompletedCallbackType(IntPtr motionData);

/// <summary>
/// Create an initialized motion data.
/// Create an initialized, empty motion data.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public MotionData() : this(Interop.MotionData.MotionDataNew(), true)
Expand All @@ -102,9 +105,9 @@ public MotionData() : this(Interop.MotionData.MotionDataNew(), true)
/// <summary>
/// Create an initialized motion data with duration.
/// </summary>
/// <param name="durationMilliSeconds">Duration of this motion data when it be generated as Animation in milliseconds.</param>
/// <param name="durationMilliseconds">Duration of an Animation generated from this motion data, in milliseconds.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public MotionData(int durationMilliSeconds) : this(Interop.MotionData.MotionDataNew(MilliSecondsToSeconds(durationMilliSeconds)), true)
public MotionData(int durationMilliseconds) : this(Interop.MotionData.MotionDataNew(MillisecondsToSeconds(durationMilliseconds)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
Expand Down Expand Up @@ -136,25 +139,25 @@ internal MotionData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cM
}

/// <summary>
/// Get or set the duration of this motion data in milliseconds.
/// Get or set the duration of this motion data in milliseconds.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public int Duration
{
get
{
return SecondsToMilliSeconds(GetDuration());
return SecondsToMilliseconds(GetDuration());
}
set
{
SetDuration(MilliSecondsToSeconds(value));
SetDuration(MillisecondsToSeconds(value));
}
}

/// <summary>
/// Get the number of MotionIndex / MotionValue pair list what this hold.
/// Get the number of contained MotionIndex / MotionValue pair what this hold.
/// </summary>
/// <returns>The number of motions what this hold.</returns>
/// <returns>The number of contained motions.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public uint GetMotionCount()
{
Expand All @@ -164,7 +167,7 @@ public uint GetMotionCount()
}

/// <summary>
/// Append pair of MotionIndex and MotionValue end of list.
/// Append pair of MotionIndex and MotionValue to the list.
/// </summary>
/// <param name="index">MotionIndex to be added</param>
/// <param name="value">MotionValue to be added</param>
Expand All @@ -176,10 +179,10 @@ public void Add(MotionIndex index, MotionValue value)
}

/// <summary>
/// Get MotionIndex at index'th. null if invalid index inputed
/// Get MotionIndex at position, or null if invalid index was given.
/// </summary>
/// <param name="index">The index of motion data list</param>
/// <returns>The index'th MotionIndex. Or empty handle that doesn't have body</returns>
/// <returns>The MotionIndex at position. Or null.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public MotionIndex GetIndex(uint index)
{
Expand All @@ -198,14 +201,20 @@ public MotionIndex GetIndex(uint index)
handle = new HandleRef(null, IntPtr.Zero);
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();

if (!ret.HasBody())
{
ret.Dispose();
ret = null;
}
return ret;
}

/// <summary>
/// Get MotionValue at index'th. null if invalid index inputed
/// Get MotionValue at position, or null if invalid index was given.
/// </summary>
/// <param name="index">The index of motion data list</param>
/// <returns>The index'th MotionValue. Or empty handle that doesn't have body</returns>
/// <returns>The MotionValue at position. Or null.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public MotionValue GetValue(uint index)
{
Expand All @@ -224,21 +233,28 @@ public MotionValue GetValue(uint index)
handle = new HandleRef(null, IntPtr.Zero);
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();

if (!ret.HasBody())
{
ret.Dispose();
ret = null;
}
return ret;
}

/// <summary>
/// Load motion capture animation.
/// Scale is additional scale factor of motion capture animation. It is possible that
/// Model's scale may not matched with motion capture animation scale.
/// If scale is null, default use as Vector3.ONE
/// We support bvh format.
/// After load completed, <see cref="LoadCompleted"/> event will be invoked.
/// After load completes, <see cref="LoadCompleted"/> event will be invoked.
/// </summary>
/// <remarks>
/// Scale is additional scale factor of motion capture animation. It is possible that
/// Model's scale may not match with motion capture animation scale.
/// If scale is null, default value will be used: <cref name="Vector3.ONE"/>
/// </remarks>
/// <param name="motionCaptureFilename">Name of motion capture format file.</param>
/// <param name="scale">Scale value of motion capture animation match with model.</param>
/// <param name="synchronousLoad">Load synchronously or not. Default is async load.</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
public void LoadMotionCaptureAnimation(string motionCaptureFilename, Vector3 scale = null, bool synchronousLoad = false)
{
Expand All @@ -247,17 +263,18 @@ public void LoadMotionCaptureAnimation(string motionCaptureFilename, Vector3 sca
}

/// <summary>
/// Load motion capture animation.
/// Scale is additional scale factor of motion capture animation. It is possible that
/// Model's scale may not matched with motion capture animation scale.
/// If scale is null, default use as Vector3.ONE
/// Load motion capture animation from string.
/// We support bvh format.
/// After load completed, <see cref="LoadCompleted"/> event will be invoked.
/// After load completes, <see cref="LoadCompleted"/> event will be invoked.
/// </summary>
/// <param name="motionCaptureBuffer">Contents of motion capture format file.</param>
/// <remarks>
/// Scale is additional scale factor of motion capture animation. It is possible that
/// Model's scale may not match with motion capture animation scale.
/// If scale is null, default value will be used: <cref name="Vector3.ONE"/>
/// </remarks>
/// <param name="motionCaptureBuffer">Contents of motion capture format string.</param>
/// <param name="scale">Scale value of motion capture animation match with model.</param>
/// <param name="synchronousLoad">Load synchronously or not. Default is async load.</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
public void LoadMotionCaptureAnimationFromBuffer(string motionCaptureBuffer, Vector3 scale = null, bool synchronousLoad = false)
{
Expand All @@ -271,7 +288,6 @@ public void LoadMotionCaptureAnimationFromBuffer(string motionCaptureBuffer, Vec
/// </summary>
/// <param name="blendShapeFilename">Name of json format file what we predefined.</param>
/// <param name="synchronousLoad">Load synchronously or not. Default is async load.</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
public void LoadBlendShapeAnimation(string blendShapeFilename, bool synchronousLoad = false)
{
Expand All @@ -285,7 +301,6 @@ public void LoadBlendShapeAnimation(string blendShapeFilename, bool synchronousL
/// </summary>
/// <param name="blendShapeBuffer">Contents of json format file what we predefined.</param>
/// <param name="synchronousLoad">Load synchronously or not. Default is async load.</param>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[EditorBrowsable(EditorBrowsableState.Never)]
public void LoadBlendShapeAnimationFromBuffer(string blendShapeBuffer, bool synchronousLoad = false)
{
Expand Down Expand Up @@ -332,7 +347,7 @@ private void OnLoadCompleted(IntPtr motionData)
}

/// <summary>
/// Clear all inputed values.
/// Removes all stored motions.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void Clear()
Expand All @@ -354,12 +369,12 @@ internal float GetDuration()
return ret;
}

private static float MilliSecondsToSeconds(int millisec)
private static float MillisecondsToSeconds(int millisec)
{
return (float)millisec / 1000.0f;
}

private static int SecondsToMilliSeconds(float sec)
private static int SecondsToMilliseconds(float sec)
{
return (int)(sec * 1000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ namespace Tizen.NUI.Scene3D
/// Specialized <see cref="MotionIndex"/> to control blend shape.
/// We can control the blend shape by index (when we set BlendShapeId as IndexKey),
/// or by name (when we set BlendShapeId as StringKey).
///
/// </summary>
/// <remarks>
/// <see cref="MotionValue"/> should be float type.
///
/// </remarks>
/// <example>
/// <code>
/// BlendShapeIndex blendShapeIndex0 = new BlendShapeIndex(new PropertyKey("nodeName"), new PropertyKey(0u));
/// BlendShapeIndex blendShapeIndex1 = new BlendShapeIndex(new PropertyKey("nodeName"), new PropertyKey("Target_1"));
Expand All @@ -38,7 +40,8 @@ namespace Tizen.NUI.Scene3D
/// blendShapeIndex2.ModelNodeId = new PropertyKey("nodeName");
/// blendShapeIndex2.BlendShapeId = new PropertyKey("Target_2");
/// </code>
///
/// </example>
/// <example>
/// Specially, if ModelNodeId is invalid and BlendShapeId is StringKey,
/// It will control all ModelNode that has the inputed blend shape name.
///
Expand All @@ -50,7 +53,7 @@ namespace Tizen.NUI.Scene3D
/// BlendShapeIndex blendShapeIndex0 = new BlendShapeIndex(new PropertyKey("node0"), new PropertyKey("Smile"));
/// BlendShapeIndex blendShapeIndex1 = new BlendShapeIndex(new PropertyKey("node1"), new PropertyKey("Smile"));
/// </code>
/// </summary>
/// </example>
[EditorBrowsable(EditorBrowsableState.Never)]
public class BlendShapeIndex : MotionIndex
{
Expand All @@ -64,23 +67,47 @@ public BlendShapeIndex() : this(Interop.MotionIndex.BlendShapeIndexNew(), true)
}

/// <summary>
/// Create an initialized blend shape index with invalid node id, and input blend shape id.
/// Create an initialized blend shape index with invalid node ID, and given blend shape ID.
/// </summary>
/// <param name="blendShapeId">Blend shape ID for this motion index</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public BlendShapeIndex(PropertyKey blendShapeId) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(blendShapeId)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// Create an initialized blend shape index with input node id, and input blend shape id.
/// Create an initialized blend shape index with given node ID and blend shape ID.
/// </summary>
/// <param name="modelNodeId">Node ID for this motion index</param>
/// <param name="blendShapeId">Blend shape ID for this motion index</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public BlendShapeIndex(PropertyKey modelNodeId, PropertyKey blendShapeId) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(modelNodeId), PropertyKey.getCPtr(blendShapeId)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// Create an initialized blend shape index with invalid node ID, and given blend shape string ID.
/// </summary>
/// <param name="blendShapeName">Blend shape string ID for this motion index</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public BlendShapeIndex(string blendShapeName) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(new PropertyKey(blendShapeName))), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// Create an initialized blend shape index with given node string ID and blend shape string ID.
/// </summary>
/// <param name="modelNodeName">Node string ID for this motion index</param>
/// <param name="blendShapeName">Blend shape string ID for this motion index</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public BlendShapeIndex(string modelNodeName, string blendShapeName) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(new PropertyKey(modelNodeName)), PropertyKey.getCPtr(new PropertyKey(blendShapeName))), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// Copy constructor.
/// </summary>
Expand Down
Loading

0 comments on commit 3c40fab

Please sign in to comment.