[EditorBrowsable(EditorBrowsableState.Never)]
public class MotionData : IDisposable
{
+ private List<(MotionIndex, MotionValue)> motionValues { get; set; } = null;
+
/// <summary>
/// Owned motion value list.
/// </summary>
[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;
+ }
+ }
+
+ /// <summary>
+ /// Append pair of MotionIndex and MotionValue end of list.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Add(MotionIndex index, MotionValue value)
+ {
+ if(motionValues == null)
+ {
+ motionValues = new List<(MotionIndex, MotionValue)>();
+ }
+ motionValues.Add((index, value));
+ }
+
+ /// <summary>
+ /// Get MotionIndex at index'th. null if invalid index inputed
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public MotionIndex GetIndex(uint index)
+ {
+ if(motionValues != null && index < motionValues.Count)
+ {
+ return motionValues[(int)index].Item1;
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Get MotionValue at index'th. null if invalid index inputed
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public MotionValue GetValue(uint index)
+ {
+ if(motionValues != null && index < motionValues.Count)
+ {
+ return motionValues[(int)index].Item2;
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Clear all inputed values.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Clear()
+ {
+ motionValues = null;
+ }
/// <summary>
/// Create an initialized motion data.
[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;
}
}
}
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()
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);
}
}