From 95c2e7539e23b8a7dfd47268f4fe222f3ba0f22e Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Fri, 16 Jun 2023 09:38:30 +0900 Subject: [PATCH] [NUI.Scene3D] Deprecate direct accessor to motion value list Signed-off-by: Eunki, Hong --- .../src/public/ModelMotion/MotionData.cs | 68 ++++++++++++++- test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs | 99 ++++++++++------------ 2 files changed, 110 insertions(+), 57 deletions(-) diff --git a/src/Tizen.NUI.Scene3D/src/public/ModelMotion/MotionData.cs b/src/Tizen.NUI.Scene3D/src/public/ModelMotion/MotionData.cs index 048eace..6651291 100644 --- a/src/Tizen.NUI.Scene3D/src/public/ModelMotion/MotionData.cs +++ b/src/Tizen.NUI.Scene3D/src/public/ModelMotion/MotionData.cs @@ -30,11 +30,72 @@ namespace Tizen.NUI.Scene3D [EditorBrowsable(EditorBrowsableState.Never)] public class MotionData : IDisposable { + private List<(MotionIndex, MotionValue)> motionValues { get; set; } = null; + /// /// Owned motion value list. /// [EditorBrowsable(EditorBrowsableState.Never)] - public List<(MotionIndex, MotionValue)> MotionValues { get; set; } = null; + [Obsolete("Do not use this MotionValues property directly. Use Add and GetIndex, GetValue instead.")] + public List<(MotionIndex, MotionValue)> MotionValues + { + get + { + return motionValues; + } + set + { + motionValues = value; + } + } + + /// + /// Append pair of MotionIndex and MotionValue end of list. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Add(MotionIndex index, MotionValue value) + { + if(motionValues == null) + { + motionValues = new List<(MotionIndex, MotionValue)>(); + } + motionValues.Add((index, value)); + } + + /// + /// Get MotionIndex at index'th. null if invalid index inputed + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public MotionIndex GetIndex(uint index) + { + if(motionValues != null && index < motionValues.Count) + { + return motionValues[(int)index].Item1; + } + return null; + } + + /// + /// Get MotionValue at index'th. null if invalid index inputed + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public MotionValue GetValue(uint index) + { + if(motionValues != null && index < motionValues.Count) + { + return motionValues[(int)index].Item2; + } + return null; + } + + /// + /// Clear all inputed values. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Clear() + { + motionValues = null; + } /// /// Create an initialized motion data. @@ -49,13 +110,14 @@ namespace Tizen.NUI.Scene3D [EditorBrowsable(EditorBrowsableState.Never)] public void Dispose() { - if (MotionValues != null) + if (motionValues != null) { - foreach (var indexValuePair in MotionValues) + foreach (var indexValuePair in motionValues) { indexValuePair.Item1?.Dispose(); indexValuePair.Item2?.Dispose(); } + motionValues = null; } } } diff --git a/test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs b/test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs index 283728c..06fa774 100644 --- a/test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs +++ b/test/Tizen.NUI.Scene3D.Sample/Scene3DSample.cs @@ -307,60 +307,51 @@ class Scene3DSample : NUIApplication mStaticRevertMotionData = new MotionData(); mAnimateMotionData = new MotionData(); - mStaticMotionData.MotionValues = new List<(MotionIndex, MotionValue)> - { - ( - new MotionTransformIndex() - { - ModelNodeId = new PropertyKey("Main"), - TransformType = MotionTransformIndex.TransformTypes.Orientation, - }, - new MotionValue() - { - Value = new PropertyValue(new Rotation(new Radian(new Degree(-45.0f)), Vector3.ZAxis)), - } - ), - }; - mStaticRevertMotionData.MotionValues = new List<(MotionIndex, MotionValue)> - { - ( - new MotionTransformIndex() - { - ModelNodeId = new PropertyKey("Main"), - TransformType = MotionTransformIndex.TransformTypes.Orientation, - }, - new MotionValue() - { - Value = new PropertyValue(new Rotation(new Radian(new Degree(0.0f)), Vector3.ZAxis)), - } - ), - ( - new MotionTransformIndex() - { - ModelNodeId = new PropertyKey("Main"), - TransformType = MotionTransformIndex.TransformTypes.Scale, - }, - new MotionValue() - { - Value = new PropertyValue(Vector3.One), - } - ), - }; + mStaticMotionData.Add( + new MotionTransformIndex() + { + ModelNodeId = new PropertyKey("Main"), + TransformType = MotionTransformIndex.TransformTypes.Orientation, + }, + new MotionValue() + { + Value = new PropertyValue(new Rotation(new Radian(new Degree(-45.0f)), Vector3.ZAxis)), + } + ); + mStaticRevertMotionData.Add( + new MotionTransformIndex() + { + ModelNodeId = new PropertyKey("Main"), + TransformType = MotionTransformIndex.TransformTypes.Orientation, + }, + new MotionValue() + { + Value = new PropertyValue(new Rotation(new Radian(new Degree(0.0f)), Vector3.ZAxis)), + } + ); + mStaticRevertMotionData.Add( + new MotionTransformIndex() + { + ModelNodeId = new PropertyKey("Main"), + TransformType = MotionTransformIndex.TransformTypes.Scale, + }, + new MotionValue() + { + Value = new PropertyValue(Vector3.One), + } + ); - mAnimateMotionData.MotionValues = new List<(MotionIndex, MotionValue)>() - { - ( - new MotionTransformIndex() - { - ModelNodeId = new PropertyKey("Main"), - TransformType = MotionTransformIndex.TransformTypes.Scale, - }, - new MotionValue() - { - Value = new PropertyValue(new Vector3(0.5f, 1.5f, 1.0f)), - } - ), - }; + mAnimateMotionData.Add( + new MotionTransformIndex() + { + ModelNodeId = new PropertyKey("Main"), + TransformType = MotionTransformIndex.TransformTypes.Scale, + }, + new MotionValue() + { + Value = new PropertyValue(new Vector3(0.5f, 1.5f, 1.0f)), + } + ); for (int i = 0; i < 8; ++i) { MotionIndex index = new BlendShapeIndex() @@ -375,7 +366,7 @@ class Scene3DSample : NUIApplication value.KeyFramesValue.Add(0.0f, 0.0f); value.KeyFramesValue.Add(1.0f, 1.0f * ((float)Math.Abs(i - 3.5f) + 0.5f) / 4.0f); - mAnimateMotionData.MotionValues.Add(ValueTuple.Create(index, value)); + mAnimateMotionData.Add(index, value); } } -- 2.7.4